📄 tw2880.c
字号:
} if(tmp<0||tmp>4) { printk("TW2815A_CLEAR_MIX_MUTE_FAIL\n"); return TW2815_CLEAR_MIX_MUTE_FAIL; } clear_audio_mix_mute(TW2815A_I2C_ADDR,tmp); break; case TW2815_SET_VIDEO_MODE: if (copy_from_user(&tw2815_videomode, argp, sizeof(tw2815_videomode))) { printk("\ttw2815a_ERROR: WRONG cpy tmp is %x\n",tw2815_videomode.mode); return TW2815_SET_VIDEO_MODE_FAIL; } if((tw2815_videomode.mode != NTSC)&&(tw2815_videomode.mode !=PAL)&&(tw2815_videomode.mode !=AUTOMATICALLY)) { printk("set video mode %d error\n ",tw2815_videomode.mode); return TW2815_SET_VIDEO_MODE_FAIL; } tw2815_video_mode_init(TW2815A_I2C_ADDR,tw2815_videomode.mode,tw2815_videomode.ch); break; case TW2815_GET_VIDEO_MODE: if (copy_from_user(&tmp, argp, sizeof(tmp))) { printk("\ttw2815a_ERROR: WRONG cpy tmp is %x\n",tmp); return TW2815_GET_VIDEO_MODE_FAIL; } #if 0 tmp_help = tw2815_byte_read(TW2815A_I2C_ADDR,tmp*0x10+0x1); CLEAR_BIT(tmp_help,0x80); tw2815_byte_write(TW2815A_I2C_ADDR,tmp*0x10+0x01,tmp_help); #endif tmp_help = (tw2815_byte_read(TW2815A_I2C_ADDR,tmp*0x10+0x0))>>5; if(tmp_help <= 3) { tmp = PAL; } else { tmp = NTSC; } copy_to_user(argp,&tmp,sizeof(tmp)); break; case TW2815_REG_DUMP: tw2815_reg_dump(TW2815A_I2C_ADDR); break; case TW2815_SET_CHANNEL_SEQUENCE: if (copy_from_user(&tmp, argp, sizeof(tmp))) { printk("\ttw2815a_ERROR: WRONG cpy tmp is %x\n",tmp); return TW2815_SET_CHANNEL_SEQUENCE_FAIL; } if((tmp>3)||(tmp<0)) return TW2815_SET_CHANNEL_SEQUENCE_FAIL; channel_alloc(TW2815A_I2C_ADDR,tmp); break; case TW2815_SET_AUDIO_CASCAD: if (copy_from_user(&tmp, argp, sizeof(tmp))) { printk("\ttw2815a_ERROR: WRONG cpy tmp is %x\n",tmp); return TW2815_SET_AUDIO_CASCAD_FAIL; } if(tmp==SET_AUDIO_CASCAD) { set_audio_cascad(); } else if(tmp == SET_AUDIO_SINGLE) { set_single_chip(); }else return TW2815_SET_AUDIO_CASCAD_FAIL; break; case TW2815_HUE_CONTROL: if (copy_from_user(&tw2815_controlvalue, argp, sizeof(tw2815_controlvalue))) { printk("\ttw2815a_ERROR: WRONG cpy tmp is %x\n",tmp); return TW2815_HUE_CONTROL_FAIL; } hue_control(TW2815A_I2C_ADDR,tw2815_controlvalue.ch,tw2815_controlvalue.controlvalue); break; case TW2815_GET_HUE_SET: if (copy_from_user(&tw2815_controlvalue, argp, sizeof(tw2815_controlvalue))) { printk("\ttw2815a_ERROR: WRONG cpy tmp is %x\n",tmp); return TW2815_GET_HUE_SET_FAIL; } hue_control_get(TW2815A_I2C_ADDR,tw2815_controlvalue.ch,&tw2815_controlvalue.controlvalue); copy_to_user(argp,&tw2815_controlvalue, sizeof(tw2815_controlvalue)); break; case TW2815_SATURATION_CONTROL: if (copy_from_user(&tw2815_controlvalue, argp, sizeof(tw2815_controlvalue))) { printk("\ttw2815a_ERROR: WRONG cpy tmp is %x\n",tmp); return TW2815_SATURATION_CONTROL_FAIL; } saturation_control(TW2815A_I2C_ADDR,tw2815_controlvalue.ch,tw2815_controlvalue.controlvalue); break; case TW2815_GET_SATURATION_SET: if (copy_from_user(&tw2815_controlvalue, argp, sizeof(tw2815_controlvalue))) { printk("\ttw2815a_ERROR: WRONG cpy tmp is %x\n",tmp); return TW2815_GET_SATURATION_SET_FAIL; } saturation_control_get(TW2815A_I2C_ADDR,tw2815_controlvalue.ch,&tw2815_controlvalue.controlvalue); copy_to_user(argp,&tw2815_controlvalue, sizeof(tw2815_controlvalue)); break; case TW2815_CONTRAST_CONTROL: if (copy_from_user(&tw2815_controlvalue, argp, sizeof(tw2815_controlvalue))) { printk("\ttw2815a_ERROR: WRONG cpy tmp is %x\n",tmp); return TW2815_CONTRAST_CONTROL_FAIL; } contrast_control(TW2815A_I2C_ADDR,tw2815_controlvalue.ch,tw2815_controlvalue.controlvalue); break; case TW2815_GET_CONTRAST_SET: if (copy_from_user(&tw2815_controlvalue, argp, sizeof(tw2815_controlvalue))) { printk("\ttw2815a_ERROR: WRONG cpy tmp is %x\n",tmp); return TW2815_GET_CONTRAST_SET_FAIL; } contrast_control_get(TW2815A_I2C_ADDR,tw2815_controlvalue.ch,&tw2815_controlvalue.controlvalue); copy_to_user(argp,&tw2815_controlvalue, sizeof(tw2815_controlvalue)); break; case TW2815_BRIGHTNESS_CONTROL: if (copy_from_user(&tw2815_controlvalue, argp, sizeof(tw2815_controlvalue))) { printk("\ttw2815a_ERROR: WRONG cpy tmp is %x\n",tmp); return TW2815_BRIGHTNESS_CONTROL_FAIL; } brightness_control(TW2815A_I2C_ADDR,tw2815_controlvalue.ch,tw2815_controlvalue.controlvalue); break; case TW2815_GET_BRIGHTNESS_SET: if (copy_from_user(&tw2815_controlvalue, argp, sizeof(tw2815_controlvalue))) { printk("\ttw2815a_ERROR: WRONG cpy tmp is %x\n",tmp); return TW2815_GET_BRIGHTNESS_SET_FAIL; } brightness_control_get(TW2815A_I2C_ADDR,tw2815_controlvalue.ch,&tw2815_controlvalue.controlvalue); copy_to_user(argp,&tw2815_controlvalue, sizeof(tw2815_controlvalue)); break; case TW2815_LUMINANCE_PEAKING_CONTROL: if (copy_from_user(&tw2815_controlvalue, argp, sizeof(tw2815_controlvalue))) { printk("\ttw2815a_ERROR: WRONG cpy tmp is %x\n",tmp); return TW2815_LUMINANCE_PEAKING_FAIL; } if(0 != luminance_peaking_control(TW2815A_I2C_ADDR,tw2815_controlvalue.ch,tw2815_controlvalue.controlvalue)) { return TW2815_LUMINANCE_PEAKING_FAIL; } break; case TW2815_GET_LUMINANCE_PEAKING_SET: if (copy_from_user(&tw2815_controlvalue, argp, sizeof(tw2815_controlvalue))) { printk("\ttw2815a_ERROR: WRONG cpy tmp is %x\n",tmp); return TW2815_GET_LUMINANCE_PEAKING_SET_FAIL; } luminance_peaking_control_get(TW2815A_I2C_ADDR,tw2815_controlvalue.ch,&tw2815_controlvalue.controlvalue); copy_to_user(argp,&tw2815_controlvalue, sizeof(tw2815_controlvalue)); break; case TW2815_CTI_CONTROL: if (copy_from_user(&tw2815_controlvalue, argp, sizeof(tw2815_controlvalue))) { printk("\ttw2815a_ERROR: WRONG cpy tmp is %x\n",tmp); return TW2815_CTI_CONTROL_FAIL; } if(0 != cti_control(TW2815A_I2C_ADDR,tw2815_controlvalue.ch,tw2815_controlvalue.controlvalue)) { return TW2815_CTI_CONTROL_FAIL; } break; case TW2815_GET_CTI_SET: if (copy_from_user(&tw2815_controlvalue, argp, sizeof(tw2815_controlvalue))) { printk("\ttw2815a_ERROR: WRONG cpy tmp is %x\n",tmp); return TW2815_GET_CTI_SET_FAIL; } cti_control_get(TW2815A_I2C_ADDR,tw2815_controlvalue.ch,&tw2815_controlvalue.controlvalue); copy_to_user(argp,&tw2815_controlvalue, sizeof(tw2815_controlvalue)); break; case TW2815_SET_PLAYBACK_MODE: if (copy_from_user(&tmp, argp, sizeof(tmp))) { printk("\ttw2815a_ERROR: WRONG cpy tmp is %x\n",tmp); return TW2815_SET_PLAYBACK_MODE_FAIL; } tmp &= 0x1; tmp_help = (tw2815_byte_read(TW2815A_I2C_ADDR,SERIAL_PLAYBACK_CONTROL)&0xbf); tmp_help |=(tmp << 6); tw2815_byte_write(TW2815A_I2C_ADDR,SERIAL_PLAYBACK_CONTROL,tmp_help); case TW2815_SET_CLOCK_OUTPUT_DELAY: if (copy_from_user(&tmp, argp, sizeof(tmp))) { printk("\ttw2815a_ERROR: WRONG cpy tmp is %x\n",tmp); return TW2815_SET_CLOCK_OUTPUT_DELAY_FAIL; } tw2815_byte_write(TW2815A_I2C_ADDR,0x4d,tmp); default: break; } return TW2815_IOCTL_OK;}/* * tw2815b read routine. * do nothing. */ssize_t tw2815b_read(struct file * file, char __user * buf, size_t count, loff_t * offset){ return 0;}/* * tw2815b write routine. * do nothing. */ssize_t tw2815b_write(struct file * file, const char __user * buf, size_t count, loff_t * offset){ return 0;}/* * tw2834 open routine. * do nothing. */int tw2815b_open(struct inode * inode, struct file * file){ return 0;#if 0 if(tw2815b_dev_open_cnt) { printk("tw2815b_dev is still on"); return -EFAULT; } tw2815b_dev_open_cnt++; if(DEBUG_2815) { printk("tw2815b_dev open ok\n"); } return 0;#endif }/* * tw2815b close routine. * do nothing. */int tw2815b_close(struct inode * inode, struct file * file){ tw2815b_dev_open_cnt --; return 0;}Tw2815Ret tw2815b_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg){ unsigned int __user *argp = (unsigned int __user *)arg; unsigned int tmp,tmp_help,samplerate,ada_samplerate,bitwidth,ada_bitwidth,bitrate,ada_bitrate; tw2815_w_reg tw2815reg; tw2815_set_2d1 tw2815_2d1; tw2815_set_videomode tw2815_videomode; tw2815_set_controlvalue tw2815_controlvalue; switch(cmd) { case TW2815_READ_REG: if (copy_from_user(&tmp_help, argp, sizeof(tmp_help))) { printk("\ttw2815a_ERROR: WRONG cpy tmp is %x\n",tmp); return TW2815_READ_REG_FAIL; } tmp = tw2815_byte_read(TW2815B_I2C_ADDR,(u8)tmp_help); copy_to_user(argp, &tmp, sizeof(tmp)); break; case TW2815_WRITE_REG: if (copy_from_user(&tw2815reg, argp, sizeof(tw2815reg))) { printk("ttw2815b_ERROR"); return TW2815_WRITE_REG_FAIL; } tw2815_byte_write(TW2815B_I2C_ADDR,(u8)tw2815reg.addr,(u8)tw2815reg.value); break; case TW2815_SET_ADA_PLAYBACK_SAMPLERATE : if (copy_from_user(&tmp, argp, sizeof(tmp))) { printk("\ttw2815b_ERROR: WRONG cpy tmp is %x\n",tmp); return TW2815_SET_ADA_PLAYBACK_SAMPLERATE_FAIL; } samplerate = tmp; tw2815_set_ada_playback_samplerate(TW2815B_I2C_ADDR,SERIAL_PLAYBACK_CONTROL,(u8)samplerate); break; case TW2815_GET_ADA_PLAYBACK_SAMPLERATE : ada_samplerate = tw2815_byte_read(TW2815B_I2C_ADDR,SERIAL_PLAYBACK_CONTROL); if((ada_samplerate & 0x04)==0x04) { ada_samplerate = SET_16K_SAMPLERATE; } else { ada_samplerate = SET_8K_SAMPLERATE; } copy_to_user(argp,&ada_samplerate,sizeof(ada_samplerate)); break; case TW2815_SET_ADA_PLAYBACK_BITWIDTH: if (copy_from_user(&tmp, argp, sizeof(tmp))) { printk("\ttw2815b_ERROR: WRONG cpy tmp is %x\n",tmp); return TW2815_SET_ADA_PLAYBACK_BITWIDTH_FAIL; } bitwidth = tmp; tw2815_set_ada_playback_bitwidth(TW2815B_I2C_ADDR,SERIAL_PLAYBACK_CONTROL,(u8)bitwidth); break; case TW2815_GET_ADA_PLAYBACK_BITWIDTH : ada_bitwidth = tw2815_byte_read(TW2815B_I2C_ADDR,SERIAL_PLAYBACK_CONTROL); if((ada_bitwidth & 0x02)==0x02) { ada_bitwidth = SET_8_BITWIDTH; } else { ada_bitwidth = SET_16_BITWIDTH; } copy_to_user(argp,&ada_bitwidth,sizeof(ada_bitwidth)); break; case TW2815_SET_ADA_PLAYBACK_BITRATE: if (copy_from_user(&tmp, argp, sizeof(tmp))) { printk("\ttw2815a_ERROR: WRONG cpy tmp is %x\n",tmp); return TW2815_SET_ADA_PLAYBACK_BITRATE_FAIL; } bitrate= tmp; tw2815_set_ada_playback_bitrate(TW2815B_I2C_ADDR,SERIAL_PLAYBACK_CONTROL,bitrate); break; case TW2815_GET_ADA_PLAYBACK_BITRATE: ada_bitrate = tw2815_byte_read(TW2815B_I2C_ADDR,SERIAL_PLAYBACK_CONTROL); if((ada_bitrate & 0x10)==0x10) { ada_bitrate = SET_384_BITRATE;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -