aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2010-02-20 06:07:51 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-02-26 13:11:05 -0500
commit340dde817a4f68af79453ed295ca0e8de7232669 (patch)
treed78799b73f3570f65ceacc7ddba9a95e2c66ff46 /drivers/media
parentcd7d9beb09d89d62bc3c6336e4cb9a2ee3da6163 (diff)
V4L/DVB: saa7115: fix saa7111a support
When the saa7111 driver was merged into saa7115 several bugs were introduced, in particular with the saa7111a support as is used in the mxb.c driver. This patch fixes the saa7111a support. This was tested with the mxb driver. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/mxb.c6
-rw-r--r--drivers/media/video/saa7115.c27
2 files changed, 19 insertions, 14 deletions
diff --git a/drivers/media/video/mxb.c b/drivers/media/video/mxb.c
index 823f126b89cc..9f01f14e4aa2 100644
--- a/drivers/media/video/mxb.c
+++ b/drivers/media/video/mxb.c
@@ -298,7 +298,7 @@ static int mxb_init_done(struct saa7146_dev* dev)
298 /* select tuner-output on saa7111a */ 298 /* select tuner-output on saa7111a */
299 i = 0; 299 i = 0;
300 saa7111a_call(mxb, video, s_routing, SAA7115_COMPOSITE0, 300 saa7111a_call(mxb, video, s_routing, SAA7115_COMPOSITE0,
301 SAA7111_FMT_CCIR | SAA7111_VBI_BYPASS, 0); 301 SAA7111_FMT_CCIR, 0);
302 302
303 /* select a tuner type */ 303 /* select a tuner type */
304 tun_setup.mode_mask = T_ANALOG_TV; 304 tun_setup.mode_mask = T_ANALOG_TV;
@@ -522,8 +522,8 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int input)
522 return err; 522 return err;
523 523
524 /* switch video in saa7111a */ 524 /* switch video in saa7111a */
525 if (saa7111a_call(mxb, video, s_routing, i, 0, 0)) 525 if (saa7111a_call(mxb, video, s_routing, i, SAA7111_FMT_CCIR, 0))
526 printk(KERN_ERR "VIDIOC_S_INPUT: could not address saa7111a #1.\n"); 526 printk(KERN_ERR "VIDIOC_S_INPUT: could not address saa7111a.\n");
527 527
528 /* switch the audio-source only if necessary */ 528 /* switch the audio-source only if necessary */
529 if (0 == mxb->cur_mute) 529 if (0 == mxb->cur_mute)
diff --git a/drivers/media/video/saa7115.c b/drivers/media/video/saa7115.c
index 44873a016c2c..c0a7f8a369f4 100644
--- a/drivers/media/video/saa7115.c
+++ b/drivers/media/video/saa7115.c
@@ -104,6 +104,10 @@ static int saa711x_has_reg(const int id, const u8 reg)
104 if (id == V4L2_IDENT_SAA7111) 104 if (id == V4L2_IDENT_SAA7111)
105 return reg < 0x20 && reg != 0x01 && reg != 0x0f && 105 return reg < 0x20 && reg != 0x01 && reg != 0x0f &&
106 (reg < 0x13 || reg > 0x19) && reg != 0x1d && reg != 0x1e; 106 (reg < 0x13 || reg > 0x19) && reg != 0x1d && reg != 0x1e;
107 if (id == V4L2_IDENT_SAA7111A)
108 return reg < 0x20 && reg != 0x01 && reg != 0x0f &&
109 reg != 0x14 && reg != 0x18 && reg != 0x19 &&
110 reg != 0x1d && reg != 0x1e;
107 111
108 /* common for saa7113/4/5/8 */ 112 /* common for saa7113/4/5/8 */
109 if (unlikely((reg >= 0x3b && reg <= 0x3f) || reg == 0x5c || reg == 0x5f || 113 if (unlikely((reg >= 0x3b && reg <= 0x3f) || reg == 0x5c || reg == 0x5f ||
@@ -954,8 +958,7 @@ static void saa711x_set_v4lstd(struct v4l2_subdev *sd, v4l2_std_id std)
954 011 NTSC N (3.58MHz) PAL M (3.58MHz) 958 011 NTSC N (3.58MHz) PAL M (3.58MHz)
955 100 reserved NTSC-Japan (3.58MHz) 959 100 reserved NTSC-Japan (3.58MHz)
956 */ 960 */
957 if (state->ident == V4L2_IDENT_SAA7111 || 961 if (state->ident <= V4L2_IDENT_SAA7113) {
958 state->ident == V4L2_IDENT_SAA7113) {
959 u8 reg = saa711x_read(sd, R_0E_CHROMA_CNTL_1) & 0x8f; 962 u8 reg = saa711x_read(sd, R_0E_CHROMA_CNTL_1) & 0x8f;
960 963
961 if (std == V4L2_STD_PAL_M) { 964 if (std == V4L2_STD_PAL_M) {
@@ -1232,22 +1235,19 @@ static int saa711x_s_routing(struct v4l2_subdev *sd,
1232 u32 input, u32 output, u32 config) 1235 u32 input, u32 output, u32 config)
1233{ 1236{
1234 struct saa711x_state *state = to_state(sd); 1237 struct saa711x_state *state = to_state(sd);
1235 u8 mask = (state->ident == V4L2_IDENT_SAA7111) ? 0xf8 : 0xf0; 1238 u8 mask = (state->ident <= V4L2_IDENT_SAA7111A) ? 0xf8 : 0xf0;
1236 1239
1237 v4l2_dbg(1, debug, sd, "decoder set input %d output %d\n", 1240 v4l2_dbg(1, debug, sd, "decoder set input %d output %d\n",
1238 input, output); 1241 input, output);
1239 1242
1240 /* saa7111/3 does not have these inputs */ 1243 /* saa7111/3 does not have these inputs */
1241 if ((state->ident == V4L2_IDENT_SAA7113 || 1244 if (state->ident <= V4L2_IDENT_SAA7113 &&
1242 state->ident == V4L2_IDENT_SAA7111) &&
1243 (input == SAA7115_COMPOSITE4 || 1245 (input == SAA7115_COMPOSITE4 ||
1244 input == SAA7115_COMPOSITE5)) { 1246 input == SAA7115_COMPOSITE5)) {
1245 return -EINVAL; 1247 return -EINVAL;
1246 } 1248 }
1247 if (input > SAA7115_SVIDEO3) 1249 if (input > SAA7115_SVIDEO3)
1248 return -EINVAL; 1250 return -EINVAL;
1249 if (output > SAA7115_IPORT_ON)
1250 return -EINVAL;
1251 if (state->input == input && state->output == output) 1251 if (state->input == input && state->output == output)
1252 return 0; 1252 return 0;
1253 v4l2_dbg(1, debug, sd, "now setting %s input %s output\n", 1253 v4l2_dbg(1, debug, sd, "now setting %s input %s output\n",
@@ -1256,7 +1256,7 @@ static int saa711x_s_routing(struct v4l2_subdev *sd,
1256 state->input = input; 1256 state->input = input;
1257 1257
1258 /* saa7111 has slightly different input numbering */ 1258 /* saa7111 has slightly different input numbering */
1259 if (state->ident == V4L2_IDENT_SAA7111) { 1259 if (state->ident <= V4L2_IDENT_SAA7111A) {
1260 if (input >= SAA7115_COMPOSITE4) 1260 if (input >= SAA7115_COMPOSITE4)
1261 input -= 2; 1261 input -= 2;
1262 /* saa7111 specific */ 1262 /* saa7111 specific */
@@ -1292,7 +1292,7 @@ static int saa711x_s_gpio(struct v4l2_subdev *sd, u32 val)
1292{ 1292{
1293 struct saa711x_state *state = to_state(sd); 1293 struct saa711x_state *state = to_state(sd);
1294 1294
1295 if (state->ident != V4L2_IDENT_SAA7111) 1295 if (state->ident > V4L2_IDENT_SAA7111A)
1296 return -EINVAL; 1296 return -EINVAL;
1297 saa711x_write(sd, 0x11, (saa711x_read(sd, 0x11) & 0x7f) | 1297 saa711x_write(sd, 0x11, (saa711x_read(sd, 0x11) & 0x7f) |
1298 (val ? 0x80 : 0)); 1298 (val ? 0x80 : 0));
@@ -1596,6 +1596,10 @@ static int saa711x_probe(struct i2c_client *client,
1596 switch (chip_id) { 1596 switch (chip_id) {
1597 case '1': 1597 case '1':
1598 state->ident = V4L2_IDENT_SAA7111; 1598 state->ident = V4L2_IDENT_SAA7111;
1599 if (saa711x_read(sd, R_00_CHIP_VERSION) & 0xf0) {
1600 v4l_info(client, "saa7111a variant found\n");
1601 state->ident = V4L2_IDENT_SAA7111A;
1602 }
1599 break; 1603 break;
1600 case '3': 1604 case '3':
1601 state->ident = V4L2_IDENT_SAA7113; 1605 state->ident = V4L2_IDENT_SAA7113;
@@ -1612,7 +1616,7 @@ static int saa711x_probe(struct i2c_client *client,
1612 default: 1616 default:
1613 state->ident = V4L2_IDENT_SAA7111; 1617 state->ident = V4L2_IDENT_SAA7111;
1614 v4l2_info(sd, "WARNING: Chip is not known - Falling back to saa7111\n"); 1618 v4l2_info(sd, "WARNING: Chip is not known - Falling back to saa7111\n");
1615 1619 break;
1616 } 1620 }
1617 1621
1618 state->audclk_freq = 48000; 1622 state->audclk_freq = 48000;
@@ -1623,6 +1627,7 @@ static int saa711x_probe(struct i2c_client *client,
1623 state->crystal_freq = SAA7115_FREQ_24_576_MHZ; 1627 state->crystal_freq = SAA7115_FREQ_24_576_MHZ;
1624 switch (state->ident) { 1628 switch (state->ident) {
1625 case V4L2_IDENT_SAA7111: 1629 case V4L2_IDENT_SAA7111:
1630 case V4L2_IDENT_SAA7111A:
1626 saa711x_writeregs(sd, saa7111_init); 1631 saa711x_writeregs(sd, saa7111_init);
1627 break; 1632 break;
1628 case V4L2_IDENT_SAA7113: 1633 case V4L2_IDENT_SAA7113:
@@ -1632,7 +1637,7 @@ static int saa711x_probe(struct i2c_client *client,
1632 state->crystal_freq = SAA7115_FREQ_32_11_MHZ; 1637 state->crystal_freq = SAA7115_FREQ_32_11_MHZ;
1633 saa711x_writeregs(sd, saa7115_init_auto_input); 1638 saa711x_writeregs(sd, saa7115_init_auto_input);
1634 } 1639 }
1635 if (state->ident != V4L2_IDENT_SAA7111) 1640 if (state->ident > V4L2_IDENT_SAA7111A)
1636 saa711x_writeregs(sd, saa7115_init_misc); 1641 saa711x_writeregs(sd, saa7115_init_misc);
1637 saa711x_set_v4lstd(sd, V4L2_STD_NTSC); 1642 saa711x_set_v4lstd(sd, V4L2_STD_NTSC);
1638 1643