diff options
| author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-10-03 11:01:22 -0400 |
|---|---|---|
| committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-10-08 07:00:17 -0400 |
| commit | b728666ba5244505a80d1e395194e4b90386d504 (patch) | |
| tree | aa39fba5e24c94834df5b0135b3228e32814ce68 | |
| parent | 2f4cf2c3a971c4d5154def8ef9ce4811d702852d (diff) | |
[media] saa7115: Fix standards detection
There are several bugs at saa7115 standards detection:
After the fix, the driver is returning the proper standards,
as tested with 3 different broadcast sources:
On an invalid channel (without any TV signal):
[ 4394.931630] saa7115 15-0021: Status byte 2 (0x1f)=0xe0
[ 4394.931635] saa7115 15-0021: detected std mask = 00ffffff
With a PAL/M signal:
[ 4410.836855] saa7115 15-0021: Status byte 2 (0x1f)=0xb1
[ 4410.837727] saa7115 15-0021: Status byte 1 (0x1e)=0x82
[ 4410.837731] saa7115 15-0021: detected std mask = 00000900
With a NTSC/M signal:
[ 4422.383893] saa7115 15-0021: Status byte 2 (0x1f)=0xb1
[ 4422.384768] saa7115 15-0021: Status byte 1 (0x1e)=0x81
[ 4422.384772] saa7115 15-0021: detected std mask = 0000b000
Tests were done with a WinTV PVR USB2 Model 29xx card.
Reviewed-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
| -rw-r--r-- | drivers/media/video/saa7115.c | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/drivers/media/video/saa7115.c b/drivers/media/video/saa7115.c index cee98ea0eca7..86627a8fdbfb 100644 --- a/drivers/media/video/saa7115.c +++ b/drivers/media/video/saa7115.c | |||
| @@ -1344,35 +1344,52 @@ static int saa711x_g_vbi_data(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_dat | |||
| 1344 | static int saa711x_querystd(struct v4l2_subdev *sd, v4l2_std_id *std) | 1344 | static int saa711x_querystd(struct v4l2_subdev *sd, v4l2_std_id *std) |
| 1345 | { | 1345 | { |
| 1346 | struct saa711x_state *state = to_state(sd); | 1346 | struct saa711x_state *state = to_state(sd); |
| 1347 | int reg1e; | 1347 | int reg1f, reg1e; |
| 1348 | 1348 | ||
| 1349 | *std = V4L2_STD_ALL; | 1349 | reg1f = saa711x_read(sd, R_1F_STATUS_BYTE_2_VD_DEC); |
| 1350 | if (state->ident != V4L2_IDENT_SAA7115) { | 1350 | v4l2_dbg(1, debug, sd, "Status byte 2 (0x1f)=0x%02x\n", reg1f); |
| 1351 | int reg1f = saa711x_read(sd, R_1F_STATUS_BYTE_2_VD_DEC); | 1351 | if (reg1f & 0x40) { |
| 1352 | 1352 | /* horizontal/vertical not locked */ | |
| 1353 | if (reg1f & 0x20) | 1353 | *std = V4L2_STD_ALL; |
| 1354 | *std = V4L2_STD_525_60; | 1354 | goto ret; |
| 1355 | else | ||
| 1356 | *std = V4L2_STD_625_50; | ||
| 1357 | |||
| 1358 | return 0; | ||
| 1359 | } | 1355 | } |
| 1356 | if (reg1f & 0x20) | ||
| 1357 | *std = V4L2_STD_525_60; | ||
| 1358 | else | ||
| 1359 | *std = V4L2_STD_625_50; | ||
| 1360 | |||
| 1361 | if (state->ident != V4L2_IDENT_SAA7115) | ||
| 1362 | goto ret; | ||
| 1360 | 1363 | ||
| 1361 | reg1e = saa711x_read(sd, R_1E_STATUS_BYTE_1_VD_DEC); | 1364 | reg1e = saa711x_read(sd, R_1E_STATUS_BYTE_1_VD_DEC); |
| 1362 | 1365 | ||
| 1363 | switch (reg1e & 0x03) { | 1366 | switch (reg1e & 0x03) { |
| 1364 | case 1: | 1367 | case 1: |
| 1365 | *std = V4L2_STD_NTSC; | 1368 | *std &= V4L2_STD_NTSC; |
| 1366 | break; | 1369 | break; |
| 1367 | case 2: | 1370 | case 2: |
| 1368 | *std = V4L2_STD_PAL; | 1371 | /* |
| 1372 | * V4L2_STD_PAL just cover the european PAL standards. | ||
| 1373 | * This is wrong, as the device could also be using an | ||
| 1374 | * other PAL standard. | ||
| 1375 | */ | ||
| 1376 | *std &= V4L2_STD_PAL | V4L2_STD_PAL_N | V4L2_STD_PAL_Nc | | ||
| 1377 | V4L2_STD_PAL_M | V4L2_STD_PAL_60; | ||
| 1369 | break; | 1378 | break; |
| 1370 | case 3: | 1379 | case 3: |
| 1371 | *std = V4L2_STD_SECAM; | 1380 | *std &= V4L2_STD_SECAM; |
| 1372 | break; | 1381 | break; |
| 1373 | default: | 1382 | default: |
| 1383 | /* Can't detect anything */ | ||
| 1384 | *std = V4L2_STD_ALL; | ||
| 1374 | break; | 1385 | break; |
| 1375 | } | 1386 | } |
| 1387 | |||
| 1388 | v4l2_dbg(1, debug, sd, "Status byte 1 (0x1e)=0x%02x\n", reg1e); | ||
| 1389 | |||
| 1390 | ret: | ||
| 1391 | v4l2_dbg(1, debug, sd, "detected std mask = %08Lx\n", *std); | ||
| 1392 | |||
| 1376 | return 0; | 1393 | return 0; |
| 1377 | } | 1394 | } |
| 1378 | 1395 | ||
