diff options
author | Tobias Lorenz <tobias.lorenz@gmx.net> | 2008-09-24 18:30:26 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2008-10-17 16:21:50 -0400 |
commit | 33632d4773b8256c29525b7151cd74226352f838 (patch) | |
tree | 6ce012949a25ad4f6b38900f9b78e90d2f27f917 | |
parent | eb6e3b860e36a3259d3694636ddce2660aabbd2c (diff) |
V4L/DVB (9216): si470x: tuner->type handling
The V4L2 specification says, when to check and when to return
tuner->type as constant value.
This patch corrects exactly this behavior, so that it is now conform to
the V4L2 specification.
Signed-off-by: Tobias Lorenz <tobias.lorenz@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/radio/radio-si470x.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/drivers/media/radio/radio-si470x.c b/drivers/media/radio/radio-si470x.c index 31da21a38f24..274d8464c02e 100644 --- a/drivers/media/radio/radio-si470x.c +++ b/drivers/media/radio/radio-si470x.c | |||
@@ -104,6 +104,7 @@ | |||
104 | * - hardware frequency seek support | 104 | * - hardware frequency seek support |
105 | * - afc indication | 105 | * - afc indication |
106 | * - more safety checks, let si470x_get_freq return errno | 106 | * - more safety checks, let si470x_get_freq return errno |
107 | * - vidioc behavior corrected according to v4l2 spec | ||
107 | * | 108 | * |
108 | * ToDo: | 109 | * ToDo: |
109 | * - add firmware download/update support | 110 | * - add firmware download/update support |
@@ -1418,7 +1419,7 @@ static int si470x_vidioc_g_tuner(struct file *file, void *priv, | |||
1418 | retval = -EIO; | 1419 | retval = -EIO; |
1419 | goto done; | 1420 | goto done; |
1420 | } | 1421 | } |
1421 | if ((tuner->index != 0) && (tuner->type != V4L2_TUNER_RADIO)) { | 1422 | if (tuner->index != 0) { |
1422 | retval = -EINVAL; | 1423 | retval = -EINVAL; |
1423 | goto done; | 1424 | goto done; |
1424 | } | 1425 | } |
@@ -1427,7 +1428,11 @@ static int si470x_vidioc_g_tuner(struct file *file, void *priv, | |||
1427 | if (retval < 0) | 1428 | if (retval < 0) |
1428 | goto done; | 1429 | goto done; |
1429 | 1430 | ||
1431 | /* driver constants */ | ||
1430 | strcpy(tuner->name, "FM"); | 1432 | strcpy(tuner->name, "FM"); |
1433 | tuner->type = V4L2_TUNER_RADIO; | ||
1434 | tuner->capability = V4L2_TUNER_CAP_LOW; | ||
1435 | |||
1431 | /* range limits */ | 1436 | /* range limits */ |
1432 | switch ((radio->registers[SYSCONFIG2] & SYSCONFIG2_BAND) >> 6) { | 1437 | switch ((radio->registers[SYSCONFIG2] & SYSCONFIG2_BAND) >> 6) { |
1433 | /* 0: 87.5 - 108 MHz (USA, Europe, default) */ | 1438 | /* 0: 87.5 - 108 MHz (USA, Europe, default) */ |
@@ -1447,7 +1452,6 @@ static int si470x_vidioc_g_tuner(struct file *file, void *priv, | |||
1447 | break; | 1452 | break; |
1448 | }; | 1453 | }; |
1449 | tuner->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO; | 1454 | tuner->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO; |
1450 | tuner->capability = V4L2_TUNER_CAP_LOW; | ||
1451 | 1455 | ||
1452 | /* Stereo indicator == Stereo (instead of Mono) */ | 1456 | /* Stereo indicator == Stereo (instead of Mono) */ |
1453 | if ((radio->registers[STATUSRSSI] & STATUSRSSI_ST) == 1) | 1457 | if ((radio->registers[STATUSRSSI] & STATUSRSSI_ST) == 1) |
@@ -1478,17 +1482,15 @@ static int si470x_vidioc_s_tuner(struct file *file, void *priv, | |||
1478 | struct v4l2_tuner *tuner) | 1482 | struct v4l2_tuner *tuner) |
1479 | { | 1483 | { |
1480 | struct si470x_device *radio = video_drvdata(file); | 1484 | struct si470x_device *radio = video_drvdata(file); |
1481 | int retval = 0; | 1485 | int retval = -EINVAL; |
1482 | 1486 | ||
1483 | /* safety checks */ | 1487 | /* safety checks */ |
1484 | if (radio->disconnected) { | 1488 | if (radio->disconnected) { |
1485 | retval = -EIO; | 1489 | retval = -EIO; |
1486 | goto done; | 1490 | goto done; |
1487 | } | 1491 | } |
1488 | if ((tuner->index != 0) && (tuner->type != V4L2_TUNER_RADIO)) { | 1492 | if (tuner->index != 0) |
1489 | retval = -EINVAL; | ||
1490 | goto done; | 1493 | goto done; |
1491 | } | ||
1492 | 1494 | ||
1493 | if (tuner->audmode == V4L2_TUNER_MODE_MONO) | 1495 | if (tuner->audmode == V4L2_TUNER_MODE_MONO) |
1494 | radio->registers[POWERCFG] |= POWERCFG_MONO; /* force mono */ | 1496 | radio->registers[POWERCFG] |= POWERCFG_MONO; /* force mono */ |
@@ -1519,11 +1521,12 @@ static int si470x_vidioc_g_frequency(struct file *file, void *priv, | |||
1519 | retval = -EIO; | 1521 | retval = -EIO; |
1520 | goto done; | 1522 | goto done; |
1521 | } | 1523 | } |
1522 | if ((freq->tuner != 0) && (freq->type != V4L2_TUNER_RADIO)) { | 1524 | if (freq->tuner != 0) { |
1523 | retval = -EINVAL; | 1525 | retval = -EINVAL; |
1524 | goto done; | 1526 | goto done; |
1525 | } | 1527 | } |
1526 | 1528 | ||
1529 | freq->type = V4L2_TUNER_RADIO; | ||
1527 | retval = si470x_get_freq(radio, &freq->frequency); | 1530 | retval = si470x_get_freq(radio, &freq->frequency); |
1528 | 1531 | ||
1529 | done: | 1532 | done: |
@@ -1548,7 +1551,7 @@ static int si470x_vidioc_s_frequency(struct file *file, void *priv, | |||
1548 | retval = -EIO; | 1551 | retval = -EIO; |
1549 | goto done; | 1552 | goto done; |
1550 | } | 1553 | } |
1551 | if ((freq->tuner != 0) && (freq->type != V4L2_TUNER_RADIO)) { | 1554 | if (freq->tuner != 0) { |
1552 | retval = -EINVAL; | 1555 | retval = -EINVAL; |
1553 | goto done; | 1556 | goto done; |
1554 | } | 1557 | } |
@@ -1577,7 +1580,7 @@ static int si470x_vidioc_s_hw_freq_seek(struct file *file, void *priv, | |||
1577 | retval = -EIO; | 1580 | retval = -EIO; |
1578 | goto done; | 1581 | goto done; |
1579 | } | 1582 | } |
1580 | if ((seek->tuner != 0) && (seek->type != V4L2_TUNER_RADIO)) { | 1583 | if (seek->tuner != 0) { |
1581 | retval = -EINVAL; | 1584 | retval = -EINVAL; |
1582 | goto done; | 1585 | goto done; |
1583 | } | 1586 | } |