[media] tm6000: add tm6010 audio mode setup

add tm6010 audio mode setup

Signed-off-by: Stefan Ringel <stefan.ringel@arcor.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
Stefan Ringel 2011-05-09 16:53:50 -03:00 committed by Mauro Carvalho Chehab
parent 1416910743
commit 886a3c0b58
3 changed files with 107 additions and 78 deletions

View file

@ -22,6 +22,9 @@
#include "tm6000.h" #include "tm6000.h"
#include "tm6000-regs.h" #include "tm6000-regs.h"
static unsigned int tm6010_a_mode = 0;
module_param(tm6010_a_mode, int, 0644);
MODULE_PARM_DESC(tm6010_a_mode, "set tm6010 sif audio mode");
struct tm6000_reg_settings { struct tm6000_reg_settings {
unsigned char req; unsigned char req;
unsigned char reg; unsigned char reg;
@ -947,9 +950,8 @@ static int tm6000_set_audio_std(struct tm6000_core *dev,
enum tm6000_audio_std std) enum tm6000_audio_std std)
{ {
uint8_t areg_02 = 0x04; /* GC1 Fixed gain 0dB */ uint8_t areg_02 = 0x04; /* GC1 Fixed gain 0dB */
uint8_t areg_05 = 0x09; /* Auto 4.5 = M Japan, Auto 6.5 = DK */ uint8_t areg_05 = 0x01; /* Auto 4.5 = M Japan, Auto 6.5 = DK */
uint8_t areg_06 = 0x02; /* Auto de-emphasis, mannual channel mode */ uint8_t areg_06 = 0x02; /* Auto de-emphasis, mannual channel mode */
uint8_t mono_flag = 0; /* No mono */
uint8_t nicam_flag = 0; /* No NICAM */ uint8_t nicam_flag = 0; /* No NICAM */
if (dev->radio) { if (dev->radio) {
@ -958,82 +960,100 @@ static int tm6000_set_audio_std(struct tm6000_core *dev,
tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00); tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
tm6000_set_reg(dev, TM6010_REQ08_R04_A_SIF_AMP_CTRL, 0x80); tm6000_set_reg(dev, TM6010_REQ08_R04_A_SIF_AMP_CTRL, 0x80);
tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD, 0x0c); tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD, 0x0c);
tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x00); /* set mono or stereo */
if (dev->amode == V4L2_TUNER_MODE_MONO)
tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x00);
else if (dev->amode == V4L2_TUNER_MODE_STEREO)
tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x02);
tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL, 0x18); tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL, 0x18);
tm6000_set_reg(dev, TM6010_REQ08_R0C_A_ASD_THRES2, 0x0a); tm6000_set_reg(dev, TM6010_REQ08_R0C_A_ASD_THRES2, 0x0a);
tm6000_set_reg(dev, TM6010_REQ08_R0D_A_AMD_THRES, 0x40); tm6000_set_reg(dev, TM6010_REQ08_R0D_A_AMD_THRES, 0x40);
tm6000_set_reg(dev, TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc); tm6000_set_reg(dev, TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfe);
tm6000_set_reg(dev, TM6010_REQ08_R1E_A_GAIN_DEEMPH_OUT, 0x13); tm6000_set_reg(dev, TM6010_REQ08_R1E_A_GAIN_DEEMPH_OUT, 0x13);
tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80); tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
return 0; return 0;
} }
switch (std) { switch (tm6010_a_mode) {
#if 0 /* auto */
case DK_MONO: case 0:
mono_flag = 1; switch (dev->norm) {
case V4L2_STD_NTSC_M_KR:
areg_05 |= 0x00;
break;
case V4L2_STD_NTSC_M_JP:
areg_05 |= 0x40;
break;
case V4L2_STD_NTSC_M:
case V4L2_STD_PAL_M:
case V4L2_STD_PAL_N:
areg_05 |= 0x20;
break;
case V4L2_STD_PAL_Nc:
areg_05 |= 0x60;
break;
case V4L2_STD_SECAM_L:
areg_05 |= 0x00;
break;
case V4L2_STD_DK:
areg_05 |= 0x10;
break;
}
break; break;
case DK_A2_1: /* A2 */
case 1:
switch (dev->norm) {
case V4L2_STD_B:
case V4L2_STD_GH:
areg_05 = 0x05;
break;
case V4L2_STD_DK:
areg_05 = 0x09;
break;
}
break; break;
case DK_A2_3: /* NICAM */
areg_05 = 0x0b; case 2:
break; switch (dev->norm) {
case BG_MONO: case V4L2_STD_B:
mono_flag = 1; case V4L2_STD_GH:
areg_05 = 0x05; areg_05 = 0x07;
break; break;
#endif case V4L2_STD_DK:
case BG_NICAM: areg_05 = 0x06;
areg_05 = 0x07; break;
case V4L2_STD_PAL_I:
areg_05 = 0x08;
break;
case V4L2_STD_SECAM_L:
areg_05 = 0x0a;
areg_02 = 0x02;
break;
}
nicam_flag = 1; nicam_flag = 1;
break; break;
case BTSC: /* other */
areg_05 = 0x02; case 3:
break; switch (dev->norm) {
case BG_A2: /* DK3_A2 */
areg_05 = 0x05; case V4L2_STD_DK:
break; areg_05 = 0x0b;
case DK_NICAM: break;
areg_05 = 0x06; /* Korea */
nicam_flag = 1; case V4L2_STD_NTSC_M_KR:
break; areg_05 = 0x04;
case EIAJ: break;
areg_05 = 0x02; /* EIAJ */
break; case V4L2_STD_NTSC_M_JP:
case I_NICAM: areg_05 = 0x03;
areg_05 = 0x08; break;
nicam_flag = 1; default:
break; areg_05 = 0x02;
case KOREA_A2: break;
areg_05 = 0x04; }
break;
case L_NICAM:
areg_02 = 0x02; /* GC1 Fixed gain +12dB */
areg_05 = 0x0a;
nicam_flag = 1;
break;
default:
/* do nothink */
break; break;
} }
#if 0
switch (tv_audio_mode) {
case TV_MONO:
areg_06 = (nicam_flag) ? 0x03 : 0x00;
break;
case TV_LANG_A:
areg_06 = 0x00;
break;
case TV_LANG_B:
areg_06 = 0x01;
break;
}
#endif
if (mono_flag)
areg_06 = 0x00;
tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00); tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, areg_02); tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, areg_02);
tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00); tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
@ -1066,9 +1086,6 @@ static int tm6000_set_audio_std(struct tm6000_core *dev,
tm6000_set_reg(dev, TM6010_REQ08_R1E_A_GAIN_DEEMPH_OUT, 0x13); tm6000_set_reg(dev, TM6010_REQ08_R1E_A_GAIN_DEEMPH_OUT, 0x13);
tm6000_set_reg(dev, TM6010_REQ08_R1F_A_TEST_INTF_SEL, 0x00); tm6000_set_reg(dev, TM6010_REQ08_R1F_A_TEST_INTF_SEL, 0x00);
tm6000_set_reg(dev, TM6010_REQ08_R20_A_TEST_PIN_SEL, 0x00); tm6000_set_reg(dev, TM6010_REQ08_R20_A_TEST_PIN_SEL, 0x00);
tm6000_set_reg(dev, TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3);
tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x00);
tm6000_set_reg(dev, TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfc);
tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80); tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
return 0; return 0;

View file

@ -34,6 +34,7 @@
#include <linux/usb.h> #include <linux/usb.h>
#include <linux/videodev2.h> #include <linux/videodev2.h>
#include <media/v4l2-ioctl.h> #include <media/v4l2-ioctl.h>
#include <media/tuner.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/kthread.h> #include <linux/kthread.h>
#include <linux/highmem.h> #include <linux/highmem.h>
@ -883,14 +884,19 @@ static void res_free(struct tm6000_core *dev, struct tm6000_fh *fh)
static int vidioc_querycap(struct file *file, void *priv, static int vidioc_querycap(struct file *file, void *priv,
struct v4l2_capability *cap) struct v4l2_capability *cap)
{ {
struct tm6000_core *dev = ((struct tm6000_fh *)priv)->dev;
strlcpy(cap->driver, "tm6000", sizeof(cap->driver)); strlcpy(cap->driver, "tm6000", sizeof(cap->driver));
strlcpy(cap->card, "Trident TVMaster TM5600/6000/6010", sizeof(cap->card)); strlcpy(cap->card, "Trident TVMaster TM5600/6000/6010", sizeof(cap->card));
cap->version = TM6000_VERSION; cap->version = TM6000_VERSION;
cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | cap->capabilities = V4L2_CAP_VIDEO_CAPTURE |
V4L2_CAP_STREAMING | V4L2_CAP_STREAMING |
V4L2_CAP_TUNER | V4L2_CAP_AUDIO |
V4L2_CAP_READWRITE; V4L2_CAP_READWRITE;
if (dev->tuner_type != TUNER_ABSENT)
cap->capabilities |= V4L2_CAP_TUNER;
return 0; return 0;
} }
@ -1150,7 +1156,7 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int i)
return rc; return rc;
} }
/* --- controls ---------------------------------------------- */ /* --- controls ---------------------------------------------- */
static int vidioc_queryctrl(struct file *file, void *priv, static int vidioc_queryctrl(struct file *file, void *priv,
struct v4l2_queryctrl *qc) struct v4l2_queryctrl *qc)
{ {
@ -1251,7 +1257,11 @@ static int vidioc_g_tuner(struct file *file, void *priv,
t->type = V4L2_TUNER_ANALOG_TV; t->type = V4L2_TUNER_ANALOG_TV;
t->capability = V4L2_TUNER_CAP_NORM; t->capability = V4L2_TUNER_CAP_NORM;
t->rangehigh = 0xffffffffUL; t->rangehigh = 0xffffffffUL;
t->rxsubchans = V4L2_TUNER_SUB_MONO; t->rxsubchans = V4L2_TUNER_SUB_STEREO;
v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, g_tuner, t);
t->audmode = dev->amode;
return 0; return 0;
} }
@ -1267,6 +1277,10 @@ static int vidioc_s_tuner(struct file *file, void *priv,
if (0 != t->index) if (0 != t->index)
return -EINVAL; return -EINVAL;
dev->amode = t->audmode;
dprintk(dev, 3, "audio mode: %x\n", t->audmode);
v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_tuner, t);
return 0; return 0;
} }
@ -1320,7 +1334,11 @@ static int radio_querycap(struct file *file, void *priv,
le16_to_cpu(dev->udev->descriptor.idVendor), le16_to_cpu(dev->udev->descriptor.idVendor),
le16_to_cpu(dev->udev->descriptor.idProduct)); le16_to_cpu(dev->udev->descriptor.idProduct));
cap->version = dev->dev_type; cap->version = dev->dev_type;
cap->capabilities = V4L2_CAP_TUNER; cap->capabilities = V4L2_CAP_TUNER |
V4L2_CAP_AUDIO |
V4L2_CAP_RADIO |
V4L2_CAP_READWRITE |
V4L2_CAP_STREAMING;
return 0; return 0;
} }
@ -1337,17 +1355,10 @@ static int radio_g_tuner(struct file *file, void *priv,
memset(t, 0, sizeof(*t)); memset(t, 0, sizeof(*t));
strcpy(t->name, "Radio"); strcpy(t->name, "Radio");
t->type = V4L2_TUNER_RADIO; t->type = V4L2_TUNER_RADIO;
t->rxsubchans = V4L2_TUNER_SUB_STEREO;
v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, g_tuner, t); v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, g_tuner, t);
if ((dev->aradio == TM6000_AIP_LINE1) ||
(dev->aradio == TM6000_AIP_LINE2)) {
t->rxsubchans = V4L2_TUNER_SUB_MONO;
}
else {
t->rxsubchans = V4L2_TUNER_SUB_STEREO;
}
return 0; return 0;
} }

View file

@ -221,6 +221,7 @@ struct tm6000_core {
int ctl_mute; /* audio */ int ctl_mute; /* audio */
int ctl_volume; int ctl_volume;
int amode;
/* DVB-T support */ /* DVB-T support */
struct tm6000_dvb *dvb; struct tm6000_dvb *dvb;