28 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
30 #include <linux/kernel.h>
31 #include <linux/types.h>
35 #include <linux/poll.h>
43 u8 msg[5] = {
dev, reg >> 8, reg & 0xff, val >> 8 , val & 0xff };
44 struct i2c_msg msgs = { .
flags = 0, .len = 5, .buf = msg };
58 dprintk(1,
"dvb-ttpci: failed @ card %d, %u = %u\n",
67 u8 msg1[3] = {
dev, reg >> 8, reg & 0xff };
70 { .
flags = 0 , .len = 3, .buf = msg1 },
71 { .flags =
I2C_M_RD, .len = 2, .buf = msg2 }
88 dprintk(1,
"dvb-ttpci: failed @ card %d, %u\n",
92 *val = (msg2[0] << 8) | msg2[1];
108 .name =
"Television",
138 struct av7110 *av7110 = dev->
ext_priv;
151 struct av7110 *av7110 = dev->
ext_priv;
167 dprintk(4,
"freq: 0x%08x\n", freq);
173 buf[0] = (div >> 8) & 0x7f;
177 if (freq < (
u32) (16 * 168.25))
179 else if (freq < (
u32) (16 * 447.25))
187 return tuner_write(dev, 0x61, buf);
192 struct av7110 *av7110 = (
struct av7110*)dev->
ext_priv;
196 div = (freq + 38900000 + 31250) / 62500;
198 data[0] = (div >> 8) & 0x7f;
199 data[1] = div & 0xff;
204 else if (freq < 137000000)
206 else if (freq < 403000000)
208 else if (freq < 860000000)
213 if (av7110->
fe->ops.i2c_gate_ctrl)
214 av7110->
fe->ops.i2c_gate_ctrl(av7110->
fe, 1);
215 return tuner_write(dev, 0x63, data);
224 static struct v4l2_audio msp3400_v4l2_audio = {
226 .name =
"Television",
230 static int av7110_dvb_c_switch(
struct saa7146_fh *fh)
234 struct av7110 *av7110 = (
struct av7110*)dev->
ext_priv;
244 dprintk(2,
"suspending video failed\n");
250 dprintk(1,
"switching to analog TV:\n");
258 dprintk(1,
"switching SAA7113 to Analog Tuner Input\n");
267 if (ves1820_writereg(dev, 0x09, 0x0f, 0x60))
268 dprintk(1,
"setting band in demodulator failed\n");
277 dprintk(1,
"switching SAA7113 to Video AV CVBS Input\n");
282 dprintk(1,
"switching SAA7113 to Video AV Y/C Input\n");
287 dprintk(1,
"switching SAA7113 to Input: AV7110: SAA7113: invalid input\n");
294 dprintk(1,
"switching DVB mode\n");
303 if (ves1820_writereg(dev, 0x09, 0x0f, 0x20))
304 dprintk(1,
"setting band in demodulator failed\n");
313 dprintk(1,
"ADSwitch error\n");
328 struct av7110 *av7110 = (
struct av7110 *)dev->
ext_priv;
350 msp_readreg(av7110,
MSP_RD_DEM, 0x007e, &stereo_det);
351 dprintk(1,
"VIDIOC_G_TUNER: msp3400 TV standard detection: 0x%04x\n", stereo_det);
352 msp_readreg(av7110,
MSP_RD_DSP, 0x0018, &stereo_det);
353 dprintk(1,
"VIDIOC_G_TUNER: msp3400 stereo detection: 0x%04x\n", stereo_det);
354 stereo = (
s8)(stereo_det >> 8);
359 }
else if (stereo < -0x10) {
369 static int vidioc_s_tuner(
struct file *file,
void *fh,
struct v4l2_tuner *t)
372 struct av7110 *av7110 = (
struct av7110 *)dev->
ext_priv;
381 dprintk(2,
"VIDIOC_S_TUNER: V4L2_TUNER_MODE_STEREO\n");
386 dprintk(2,
"VIDIOC_S_TUNER: V4L2_TUNER_MODE_LANG1_LANG2\n");
391 dprintk(2,
"VIDIOC_S_TUNER: V4L2_TUNER_MODE_LANG1\n");
396 dprintk(2,
"VIDIOC_S_TUNER: V4L2_TUNER_MODE_LANG2\n");
401 dprintk(2,
"VIDIOC_S_TUNER: TDA9840_SET_MONO\n");
413 static int vidioc_g_frequency(
struct file *file,
void *fh,
struct v4l2_frequency *
f)
416 struct av7110 *av7110 = (
struct av7110 *)dev->
ext_priv;
429 static int vidioc_s_frequency(
struct file *file,
void *fh,
struct v4l2_frequency *f)
432 struct av7110 *av7110 = (
struct av7110 *)dev->
ext_priv;
459 static int vidioc_enum_input(
struct file *file,
void *fh,
struct v4l2_input *
i)
462 struct av7110 *av7110 = (
struct av7110 *)dev->
ext_priv;
479 static int vidioc_g_input(
struct file *file,
void *fh,
unsigned int *
input)
482 struct av7110 *av7110 = (
struct av7110 *)dev->
ext_priv;
485 dprintk(2,
"VIDIOC_G_INPUT: %d\n", *input);
489 static int vidioc_s_input(
struct file *file,
void *fh,
unsigned int input)
492 struct av7110 *av7110 = (
struct av7110 *)dev->
ext_priv;
494 dprintk(2,
"VIDIOC_S_INPUT: %d\n", input);
497 return input ? -
EINVAL : 0;
503 return av7110_dvb_c_switch(fh);
506 static int vidioc_enumaudio(
struct file *file,
void *fh,
struct v4l2_audio *
a)
511 *a = msp3400_v4l2_audio;
515 static int vidioc_g_audio(
struct file *file,
void *fh,
struct v4l2_audio *a)
518 struct av7110 *av7110 = (
struct av7110 *)dev->
ext_priv;
525 *a = msp3400_v4l2_audio;
529 static int vidioc_s_audio(
struct file *file,
void *fh,
const struct v4l2_audio *a)
532 struct av7110 *av7110 = (
struct av7110 *)dev->
ext_priv;
540 static int vidioc_g_sliced_vbi_cap(
struct file *file,
void *fh,
544 struct av7110 *av7110 = (
struct av7110 *)dev->
ext_priv;
546 dprintk(2,
"VIDIOC_G_SLICED_VBI_CAP\n");
556 static int vidioc_g_fmt_sliced_vbi_out(
struct file *file,
void *fh,
560 struct av7110 *av7110 = (
struct av7110 *)dev->
ext_priv;
574 static int vidioc_s_fmt_sliced_vbi_out(
struct file *file,
void *fh,
578 struct av7110 *av7110 = (
struct av7110 *)dev->
ext_priv;
603 static int av7110_vbi_reset(
struct file *file)
607 struct av7110 *av7110 = (
struct av7110*) dev->
ext_priv;
618 static ssize_t av7110_vbi_write(
struct file *file,
const char __user *data,
size_t count, loff_t *ppos)
622 struct av7110 *av7110 = (
struct av7110*) dev->
ext_priv;
634 av7110->
wssData = ((
d.data[1] << 8) & 0x3f00) |
d.data[0];
645 static u8 saa7113_init_regs[] = {
709 u16 version1, version2;
713 pr_info(
"DVB-C analog module @ card %d detected, initializing MSP3400\n",
716 }
else if (
i2c_writereg(av7110, 0x84, 0x0, 0x80) == 1 &&
718 pr_info(
"DVB-C analog module @ card %d detected, initializing MSP3415\n",
725 msp_readreg(av7110,
MSP_RD_DSP, 0x001e, &version1);
726 msp_readreg(av7110,
MSP_RD_DSP, 0x001f, &version2);
727 dprintk(1,
"dvb-ttpci: @ card %d MSP34xx version 0x%04x 0x%04x\n",
739 pr_info(
"saa7113 not accessible\n");
741 u8 *i = saa7113_init_regs;
743 if ((av7110->
dev->pci->subsystem_vendor == 0x110a) && (av7110->
dev->pci->subsystem_device == 0x0000)) {
746 }
else if ((av7110->
dev->pci->subsystem_vendor == 0x13c2) && (av7110->
dev->pci->subsystem_device == 0x0002)) {
749 }
else if ((av7110->
dev->pci->subsystem_vendor == 0x13c2) && (av7110->
dev->pci->subsystem_device == 0x000A)) {
756 if (ves1820_writereg(av7110->
dev, 0x09, 0x0f, 0x20))
757 dprintk(1,
"setting band in demodulator failed\n");
815 vv_data = &av7110_vv_data_c;
817 vv_data = &av7110_vv_data_st;
821 ERR(
"cannot init capture device. skipping\n");
824 vv_data->
vid_ops.vidioc_enum_input = vidioc_enum_input;
825 vv_data->
vid_ops.vidioc_g_input = vidioc_g_input;
826 vv_data->
vid_ops.vidioc_s_input = vidioc_s_input;
827 vv_data->
vid_ops.vidioc_g_tuner = vidioc_g_tuner;
828 vv_data->
vid_ops.vidioc_s_tuner = vidioc_s_tuner;
829 vv_data->
vid_ops.vidioc_g_frequency = vidioc_g_frequency;
830 vv_data->
vid_ops.vidioc_s_frequency = vidioc_s_frequency;
831 vv_data->
vid_ops.vidioc_enumaudio = vidioc_enumaudio;
832 vv_data->
vid_ops.vidioc_g_audio = vidioc_g_audio;
833 vv_data->
vid_ops.vidioc_s_audio = vidioc_s_audio;
836 vv_data->
vbi_ops.vidioc_g_tuner = vidioc_g_tuner;
837 vv_data->
vbi_ops.vidioc_s_tuner = vidioc_s_tuner;
838 vv_data->
vbi_ops.vidioc_g_frequency = vidioc_g_frequency;
839 vv_data->
vbi_ops.vidioc_s_frequency = vidioc_s_frequency;
841 vv_data->
vbi_ops.vidioc_g_sliced_vbi_cap = vidioc_g_sliced_vbi_cap;
842 vv_data->
vbi_ops.vidioc_g_fmt_sliced_vbi_out = vidioc_g_fmt_sliced_vbi_out;
843 vv_data->
vbi_ops.vidioc_s_fmt_sliced_vbi_out = vidioc_s_fmt_sliced_vbi_out;
849 ERR(
"cannot register capture device. skipping\n");
855 ERR(
"cannot register vbi v4l2 device. skipping\n");
879 .v_offset = 0x15, .v_field = 288,
880 .h_offset = 0x48, .h_pixels = 708,
881 .v_max_out = 576, .h_max_out = 768,
884 .v_offset = 0x10, .v_field = 244,
885 .h_offset = 0x40, .h_pixels = 708,
886 .v_max_out = 480, .h_max_out = 640,
893 .v_offset = 0x1b, .v_field = 288,
894 .h_offset = 0x08, .h_pixels = 708,
895 .v_max_out = 576, .h_max_out = 768,
898 .v_offset = 0x10, .v_field = 244,
899 .h_offset = 0x40, .h_pixels = 708,
900 .v_max_out = 480, .h_max_out = 640,
907 .v_offset = 0x14, .v_field = 288,
908 .h_offset = 0x48, .h_pixels = 708,
909 .v_max_out = 576, .h_max_out = 768,
912 .v_offset = 0x10, .v_field = 244,
913 .h_offset = 0x40, .h_pixels = 708,
914 .v_max_out = 480, .h_max_out = 640,
920 struct av7110 *av7110 = (
struct av7110*) dev->
ext_priv;
943 .stds = &standard[0],
947 .vbi_fops.open = av7110_vbi_reset,
948 .vbi_fops.release = av7110_vbi_reset,
949 .vbi_fops.write = av7110_vbi_write,
958 .stds = &standard[0],
962 .vbi_fops.open = av7110_vbi_reset,
963 .vbi_fops.release = av7110_vbi_reset,
964 .vbi_fops.write = av7110_vbi_write,