tw2880.c
来自「tw2880的初始化配置」· C语言 代码 · 共 1,825 行 · 第 1/5 页
C
1,825 行
temp = tw2815_byte_read(chip_addr,0x75); CLEAR_BIT(temp,0xf); SET_BIT(temp,0x1<<ch); tw2815_byte_write(chip_addr,0x75,temp); temp = tw2815_byte_read(chip_addr,0x71); CLEAR_BIT(temp,0x40); tw2815_byte_write(chip_addr,0x71,temp); temp = tw2815_byte_read(chip_addr,0x43); SET_BIT(temp,0x03); tw2815_byte_write(chip_addr,0x43,temp); printk("set_4half_d1 ok\n"); return;}static void set_4cif(unsigned char chip_addr,unsigned char ch){ unsigned char temp = 0; temp = tw2815_byte_read(chip_addr,0x4d); CLEAR_BIT(temp,0x33); SET_BIT(temp,0x88); tw2815_byte_write(chip_addr,0x4d,temp); temp = tw2815_byte_read(chip_addr,0x0d+ch*0x10); CLEAR_BIT(temp,0x7); tw2815_byte_write(chip_addr,0x0d+ch*0x10,temp); temp = tw2815_byte_read(chip_addr,0x75); CLEAR_BIT(temp,0xf); SET_BIT(temp,0x1<<ch); tw2815_byte_write(chip_addr,0x75,temp); temp = tw2815_byte_read(chip_addr,0x71); CLEAR_BIT(temp,0x40); //SET_BIT(temp,0x20); //skip sync code as cif tw2815_byte_write(chip_addr,0x71,temp); temp = tw2815_byte_read(chip_addr,0x43); SET_BIT(temp,0x03); tw2815_byte_write(chip_addr,0x43,temp); return;}/*set samplerate control_reg = serial_playback_control(playback control)(0x6c)control_reg = serial_control(normal control)(0x62)tmp = SET_8K_SAMPLERATEtmp = SET_16K_SAMPLERATE*/static void tw2815_set_ada_playback_samplerate(unsigned char chip_addr,unsigned char control_reg,unsigned char samplerate){ unsigned int ada_samplerate = 0; switch(samplerate) { case SET_8K_SAMPLERATE: ada_samplerate = tw2815_byte_read(chip_addr,control_reg); CLEAR_BIT(ada_samplerate,0x04); tw2815_byte_write(chip_addr,control_reg,ada_samplerate); break; case SET_16K_SAMPLERATE: ada_samplerate = tw2815_byte_read(chip_addr,control_reg); SET_BIT(ada_samplerate,0x04); tw2815_byte_write(chip_addr,control_reg,ada_samplerate); break; default: break; } printk("tw2815 set samplerate ok\n"); return; }/*set bitwidth control_reg = serial_playback_control(playback control)control_reg = serial_control(normal control)tmp = SET_8_BITWIDTHtmp = SET_16_BITWIDTH*/static void tw2815_set_ada_playback_bitwidth(unsigned char chip_addr,unsigned char control_reg,unsigned char bitwidth){ unsigned int ada_bitwidth = 0; switch(bitwidth) { case SET_8_BITWIDTH: ada_bitwidth = tw2815_byte_read(chip_addr,control_reg); SET_BIT(ada_bitwidth,0x02); tw2815_byte_write(chip_addr,control_reg,ada_bitwidth); break; case SET_16_BITWIDTH: ada_bitwidth = tw2815_byte_read(chip_addr,control_reg); CLEAR_BIT(ada_bitwidth,0x02); tw2815_byte_write(chip_addr,control_reg,ada_bitwidth); break; default: break; } printk("tw2815 set bitwidth ok\n"); return; }/*control_reg = serial_playback_control(playback control)control_reg = serial_control(normal control)tmp = SET_256_BITRATE(0)tmp = SET_384_BITRATE(1)*/static void tw2815_set_ada_playback_bitrate(unsigned char chip_addr,unsigned char control_reg,unsigned char bitrate){ unsigned int ada_bitrate = 0; switch(bitrate) { case SET_256_BITRATE: ada_bitrate = tw2815_byte_read(chip_addr,control_reg); CLEAR_BIT(ada_bitrate,0x10); tw2815_byte_write(chip_addr,control_reg,ada_bitrate); break; case SET_384_BITRATE: ada_bitrate = tw2815_byte_read(chip_addr,control_reg); SET_BIT(ada_bitrate,0x10); tw2815_byte_write(chip_addr,control_reg,ada_bitrate); break; default: break; } printk("tw2815 set bitrate ok\n"); return; }static void set_audio_output(unsigned char chip_addr,unsigned char num_path){ unsigned char temp = 0; unsigned char help = 0; #if 0 if(cascad_judge) { return; } #endif if(0 < num_path && num_path <=2) help = 0; else if(2 < num_path && num_path <= 4) help = 1; else if(4 < num_path && num_path <= 8) help = 2; else if(8 <num_path && num_path <=16) help = 3; else { printk("tw2815a audio path choice error\n"); return; } temp = tw2815_byte_read(chip_addr,0x63); CLEAR_BIT(temp,0x3); SET_BIT(temp,help); tw2815_byte_write(chip_addr,0x63,temp); printk("tw2815 set output path=%d ok\n",num_path); return; }/*set cascad*/static void set_audio_cascad(void){ unsigned char temp = 0; temp = tw2815_byte_read(0x50,0x62); CLEAR_BIT(temp,0xc0); SET_BIT(temp,0x40); tw2815_byte_write(0x50,0x62,temp); temp = tw2815_byte_read(0x52,0x62); CLEAR_BIT(temp,0xc0); SET_BIT(temp,0x80); tw2815_byte_write(0x52,0x62,temp); temp = tw2815_byte_read(0x52,0x5b); CLEAR_BIT(temp,0xff); tw2815_byte_write(0x52,0x5b,temp); temp = tw2815_byte_read(0x52,0x5c); CLEAR_BIT(temp,0x0); SET_BIT(temp,0xa0); tw2815_byte_write(0x52,0x5c,temp); set_audio_output(0x52,4); set_audio_output(0x50,8); cascad_judge = 1; printk("tw2815 set cascad ok\n"); }static void set_audio_mix_out(unsigned char chip_addr,unsigned char ch){ unsigned char temp = 0; temp = tw2815_byte_read(chip_addr,0x63); CLEAR_BIT(temp,0x04); tw2815_byte_write(chip_addr,0x63,temp); temp = tw2815_byte_read(chip_addr,0x71); CLEAR_BIT(temp,0x1f); SET_BIT(temp,ch); tw2815_byte_write(chip_addr,0x71,temp); if(ch == 16) printk("tw2815 select playback audio out\n"); if(ch == 17) printk("tw2815 select mix digital and analog audio data\n"); printk("set_audio_mix_out ok\n"); return;}/*single chip*/static void set_single_chip(void){ unsigned char temp = 0; temp = tw2815_byte_read(0x50,0x62); CLEAR_BIT(temp,0xc0); SET_BIT(temp,0xc0); tw2815_byte_write(0x50,0x62,temp); temp = tw2815_byte_read(0x52,0x62); CLEAR_BIT(temp,0xc0); SET_BIT(temp,0xc0); tw2815_byte_write(0x52,0x62,temp); temp = tw2815_byte_read(0x52,0x5b); SET_BIT(temp,0xff); tw2815_byte_write(0x52,0x5b,temp); temp = tw2815_byte_read(0x52,0x5c); CLEAR_BIT(temp,0x0); SET_BIT(temp,0x2f); tw2815_byte_write(0x52,0x5c,temp); cascad_judge = 0; printk("set_single_chip ok\n");}static void set_audio_record_m(unsigned char chip_addr,unsigned char num_path){ unsigned char temp =0 ,help =0; temp = tw2815_byte_read(chip_addr,0x63); SET_BIT(temp,0x04); CLEAR_BIT(temp,0x3); if(0 < num_path && num_path <=2) help = 0; else if(2 < num_path && num_path <= 4) help = 1; else if(4 < num_path && num_path <= 8) help = 2; else if(8 <num_path && num_path <=16) help = 3; else { printk("tw2815a audio path choice error\n"); return; } SET_BIT(temp,help); tw2815_byte_write(chip_addr,0x63,temp); printk("set_audio_record_m ok"); return; }static void set_audio_mix_mute(unsigned char chip_addr,unsigned char ch) { unsigned char temp = 0 ; temp = tw2815_byte_read(chip_addr,0x6d); SET_BIT(temp,1<<ch); tw2815_byte_write(chip_addr,0x6d,temp); printk("set_audio_mix_mute ch =%d ok\n",ch); return;}static void clear_audio_mix_mute(unsigned char chip_addr,unsigned char ch){ unsigned char temp = 0; temp = tw2815_byte_read(chip_addr,0x6d); CLEAR_BIT(temp,1<<ch); tw2815_byte_write(chip_addr,0x6d,temp); printk("tw2815 clear mute ch = %d ok\n",ch); return;}static void hue_control(unsigned char chip_addr,unsigned char ch ,unsigned char hue_value){ tw2815_byte_write(chip_addr,ch*0x10+0x7,hue_value);}static void hue_control_get(unsigned char chip_addr,unsigned char ch ,unsigned int *hue_value){ *hue_value = tw2815_byte_read(chip_addr,ch*0x10+0x7);}static void saturation_control(unsigned char chip_addr,unsigned char ch ,unsigned char saturation_value){ tw2815_byte_write(chip_addr,ch*0x10+0x8,saturation_value);}static void saturation_control_get(unsigned char chip_addr,unsigned char ch ,unsigned int *saturation_value){ *saturation_value = tw2815_byte_read(chip_addr,ch*0x10+0x8);}static void contrast_control(unsigned char chip_addr,unsigned char ch ,unsigned char contrast_value){ tw2815_byte_write(chip_addr,ch*0x10+0x9,contrast_value);}static void contrast_control_get(unsigned char chip_addr,unsigned char ch ,unsigned int *contrast_value){ *contrast_value = tw2815_byte_read(chip_addr,ch*0x10+0x9);}static void brightness_control(unsigned char chip_addr,unsigned char ch ,unsigned char brightness_value){ tw2815_byte_write(chip_addr,ch*0x10+0xa,brightness_value);}static void brightness_control_get(unsigned char chip_addr,unsigned char ch ,unsigned int *brightness_value){ *brightness_value = tw2815_byte_read(chip_addr,ch*0x10+0xa);}static int luminance_peaking_control(unsigned char chip_addr,unsigned char ch ,unsigned char luminance_peaking_value){ unsigned char temp = 0; if(luminance_peaking_value > 15) { return -1; } temp = tw2815_byte_read(chip_addr,ch*0x10+0xb); CLEAR_BIT(temp,0xf); SET_BIT(temp,luminance_peaking_value); tw2815_byte_write(chip_addr,ch*0x10+0xb,temp); return 0;}static void luminance_peaking_control_get(unsigned char chip_addr,unsigned char ch ,unsigned int *luminance_peaking_value){ *luminance_peaking_value = (tw2815_byte_read(chip_addr,ch*0x10+0xb)&0x0f);}static int cti_control(unsigned char chip_addr,unsigned char ch ,unsigned char cti_value){ unsigned char temp = 0; if(cti_value > 15) { return -1;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?