diff options
author | Istvan Varga <istvan_v@mailbox.hu> | 2011-06-04 11:17:22 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-07-27 16:52:39 -0400 |
commit | 818a1776a45c230c4f230c8e4e2d0c7bdf5f8fa3 (patch) | |
tree | 1aa57c226331ce29af46787039269cb6eacf892c | |
parent | 923137a4037d1b9f19d175708eeced209dff9320 (diff) |
[media] xc4000: implemented analog TV and radio
The following patch implements support for analog TV and FM radio.
Signed-off-by: Istvan Varga <istvan_v@mailbox.hu>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/common/tuners/xc4000.c | 119 |
1 files changed, 100 insertions, 19 deletions
diff --git a/drivers/media/common/tuners/xc4000.c b/drivers/media/common/tuners/xc4000.c index 2a20d0e63da6..52375498257c 100644 --- a/drivers/media/common/tuners/xc4000.c +++ b/drivers/media/common/tuners/xc4000.c | |||
@@ -1283,69 +1283,150 @@ static int xc4000_set_analog_params(struct dvb_frontend *fe, | |||
1283 | struct analog_parameters *params) | 1283 | struct analog_parameters *params) |
1284 | { | 1284 | { |
1285 | struct xc4000_priv *priv = fe->tuner_priv; | 1285 | struct xc4000_priv *priv = fe->tuner_priv; |
1286 | unsigned int type = 0; | ||
1286 | int ret = -EREMOTEIO; | 1287 | int ret = -EREMOTEIO; |
1287 | 1288 | ||
1289 | if (params->mode == V4L2_TUNER_RADIO) { | ||
1290 | dprintk(1, "%s() frequency=%d (in units of 62.5Hz)\n", | ||
1291 | __func__, params->frequency); | ||
1292 | |||
1293 | mutex_lock(&priv->lock); | ||
1294 | |||
1295 | params->std = 0; | ||
1296 | priv->freq_hz = params->frequency * 125L / 2; | ||
1297 | |||
1298 | if (audio_std & XC4000_AUDIO_STD_INPUT1) { | ||
1299 | priv->video_standard = XC4000_FM_Radio_INPUT1; | ||
1300 | type = FM | INPUT1; | ||
1301 | } else { | ||
1302 | priv->video_standard = XC4000_FM_Radio_INPUT2; | ||
1303 | type = FM | INPUT2; | ||
1304 | } | ||
1305 | |||
1306 | goto tune_channel; | ||
1307 | } | ||
1308 | |||
1288 | dprintk(1, "%s() frequency=%d (in units of 62.5khz)\n", | 1309 | dprintk(1, "%s() frequency=%d (in units of 62.5khz)\n", |
1289 | __func__, params->frequency); | 1310 | __func__, params->frequency); |
1290 | 1311 | ||
1291 | mutex_lock(&priv->lock); | 1312 | mutex_lock(&priv->lock); |
1292 | 1313 | ||
1293 | /* Fix me: it could be air. */ | ||
1294 | priv->rf_mode = params->mode; | ||
1295 | if (params->mode > XC_RF_MODE_CABLE) | ||
1296 | priv->rf_mode = XC_RF_MODE_CABLE; | ||
1297 | |||
1298 | /* params->frequency is in units of 62.5khz */ | 1314 | /* params->frequency is in units of 62.5khz */ |
1299 | priv->freq_hz = params->frequency * 62500; | 1315 | priv->freq_hz = params->frequency * 62500; |
1300 | 1316 | ||
1301 | /* FIX ME: Some video standards may have several possible audio | 1317 | params->std &= V4L2_STD_ALL; |
1302 | standards. We simply default to one of them here. | 1318 | /* if std is not defined, choose one */ |
1303 | */ | 1319 | if (!params->std) |
1320 | params->std = V4L2_STD_PAL_BG; | ||
1321 | |||
1322 | if (audio_std & XC4000_AUDIO_STD_MONO) | ||
1323 | type = MONO; | ||
1324 | |||
1304 | if (params->std & V4L2_STD_MN) { | 1325 | if (params->std & V4L2_STD_MN) { |
1305 | /* default to BTSC audio standard */ | 1326 | params->std = V4L2_STD_MN; |
1306 | priv->video_standard = XC4000_MN_NTSC_PAL_BTSC; | 1327 | if (audio_std & XC4000_AUDIO_STD_MONO) { |
1328 | priv->video_standard = XC4000_MN_NTSC_PAL_Mono; | ||
1329 | } else if (audio_std & XC4000_AUDIO_STD_A2) { | ||
1330 | params->std |= V4L2_STD_A2; | ||
1331 | priv->video_standard = XC4000_MN_NTSC_PAL_A2; | ||
1332 | } else { | ||
1333 | params->std |= V4L2_STD_BTSC; | ||
1334 | priv->video_standard = XC4000_MN_NTSC_PAL_BTSC; | ||
1335 | } | ||
1307 | goto tune_channel; | 1336 | goto tune_channel; |
1308 | } | 1337 | } |
1309 | 1338 | ||
1310 | if (params->std & V4L2_STD_PAL_BG) { | 1339 | if (params->std & V4L2_STD_PAL_BG) { |
1311 | /* default to NICAM audio standard */ | 1340 | params->std = V4L2_STD_PAL_BG; |
1312 | priv->video_standard = XC4000_BG_PAL_NICAM; | 1341 | if (audio_std & XC4000_AUDIO_STD_MONO) { |
1342 | priv->video_standard = XC4000_BG_PAL_MONO; | ||
1343 | } else if (!(audio_std & XC4000_AUDIO_STD_A2)) { | ||
1344 | if (!(audio_std & XC4000_AUDIO_STD_B)) { | ||
1345 | params->std |= V4L2_STD_NICAM_A; | ||
1346 | priv->video_standard = XC4000_BG_PAL_NICAM; | ||
1347 | } else { | ||
1348 | params->std |= V4L2_STD_NICAM_B; | ||
1349 | priv->video_standard = XC4000_BG_PAL_NICAM; | ||
1350 | } | ||
1351 | } else { | ||
1352 | if (!(audio_std & XC4000_AUDIO_STD_B)) { | ||
1353 | params->std |= V4L2_STD_A2_A; | ||
1354 | priv->video_standard = XC4000_BG_PAL_A2; | ||
1355 | } else { | ||
1356 | params->std |= V4L2_STD_A2_B; | ||
1357 | priv->video_standard = XC4000_BG_PAL_A2; | ||
1358 | } | ||
1359 | } | ||
1313 | goto tune_channel; | 1360 | goto tune_channel; |
1314 | } | 1361 | } |
1315 | 1362 | ||
1316 | if (params->std & V4L2_STD_PAL_I) { | 1363 | if (params->std & V4L2_STD_PAL_I) { |
1317 | /* default to NICAM audio standard */ | 1364 | /* default to NICAM audio standard */ |
1318 | priv->video_standard = XC4000_I_PAL_NICAM; | 1365 | params->std = V4L2_STD_PAL_I | V4L2_STD_NICAM; |
1366 | if (audio_std & XC4000_AUDIO_STD_MONO) { | ||
1367 | priv->video_standard = XC4000_I_PAL_NICAM_MONO; | ||
1368 | } else { | ||
1369 | priv->video_standard = XC4000_I_PAL_NICAM; | ||
1370 | } | ||
1319 | goto tune_channel; | 1371 | goto tune_channel; |
1320 | } | 1372 | } |
1321 | 1373 | ||
1322 | if (params->std & V4L2_STD_PAL_DK) { | 1374 | if (params->std & V4L2_STD_PAL_DK) { |
1323 | /* default to NICAM audio standard */ | 1375 | params->std = V4L2_STD_PAL_DK; |
1324 | priv->video_standard = XC4000_DK_PAL_NICAM; | 1376 | if (audio_std & XC4000_AUDIO_STD_MONO) { |
1377 | priv->video_standard = XC4000_DK_PAL_MONO; | ||
1378 | } else if (audio_std & XC4000_AUDIO_STD_A2) { | ||
1379 | params->std |= V4L2_STD_A2; | ||
1380 | priv->video_standard = XC4000_DK_PAL_A2; | ||
1381 | } else { | ||
1382 | params->std |= V4L2_STD_NICAM; | ||
1383 | priv->video_standard = XC4000_DK_PAL_NICAM; | ||
1384 | } | ||
1325 | goto tune_channel; | 1385 | goto tune_channel; |
1326 | } | 1386 | } |
1327 | 1387 | ||
1328 | if (params->std & V4L2_STD_SECAM_DK) { | 1388 | if (params->std & V4L2_STD_SECAM_DK) { |
1329 | /* default to A2 DK1 audio standard */ | 1389 | /* default to A2 audio standard */ |
1330 | priv->video_standard = XC4000_DK_SECAM_A2DK1; | 1390 | params->std = V4L2_STD_SECAM_DK | V4L2_STD_A2; |
1391 | if (audio_std & XC4000_AUDIO_STD_L) { | ||
1392 | type = 0; | ||
1393 | priv->video_standard = XC4000_DK_SECAM_NICAM; | ||
1394 | } else if (audio_std & XC4000_AUDIO_STD_MONO) { | ||
1395 | priv->video_standard = XC4000_DK_SECAM_A2MONO; | ||
1396 | } else if (audio_std & XC4000_AUDIO_STD_K3) { | ||
1397 | params->std |= V4L2_STD_SECAM_K3; | ||
1398 | priv->video_standard = XC4000_DK_SECAM_A2LDK3; | ||
1399 | } else { | ||
1400 | priv->video_standard = XC4000_DK_SECAM_A2DK1; | ||
1401 | } | ||
1331 | goto tune_channel; | 1402 | goto tune_channel; |
1332 | } | 1403 | } |
1333 | 1404 | ||
1334 | if (params->std & V4L2_STD_SECAM_L) { | 1405 | if (params->std & V4L2_STD_SECAM_L) { |
1406 | /* default to NICAM audio standard */ | ||
1407 | type = 0; | ||
1408 | params->std = V4L2_STD_SECAM_L | V4L2_STD_NICAM; | ||
1335 | priv->video_standard = XC4000_L_SECAM_NICAM; | 1409 | priv->video_standard = XC4000_L_SECAM_NICAM; |
1336 | goto tune_channel; | 1410 | goto tune_channel; |
1337 | } | 1411 | } |
1338 | 1412 | ||
1339 | if (params->std & V4L2_STD_SECAM_LC) { | 1413 | if (params->std & V4L2_STD_SECAM_LC) { |
1414 | /* default to NICAM audio standard */ | ||
1415 | type = 0; | ||
1416 | params->std = V4L2_STD_SECAM_LC | V4L2_STD_NICAM; | ||
1340 | priv->video_standard = XC4000_LC_SECAM_NICAM; | 1417 | priv->video_standard = XC4000_LC_SECAM_NICAM; |
1341 | goto tune_channel; | 1418 | goto tune_channel; |
1342 | } | 1419 | } |
1343 | 1420 | ||
1344 | tune_channel: | 1421 | tune_channel: |
1422 | /* Fix me: it could be air. */ | ||
1423 | priv->rf_mode = XC_RF_MODE_CABLE; | ||
1345 | 1424 | ||
1346 | /* FIXME - firmware type not being set properly */ | 1425 | if (check_firmware(fe, type, params->std, |
1347 | if (check_firmware(fe, DTV8, 0, priv->if_khz) != XC_RESULT_SUCCESS) | 1426 | XC4000_Standard[priv->video_standard].int_freq) |
1427 | != XC_RESULT_SUCCESS) { | ||
1348 | goto fail; | 1428 | goto fail; |
1429 | } | ||
1349 | 1430 | ||
1350 | ret = xc_SetSignalSource(priv, priv->rf_mode); | 1431 | ret = xc_SetSignalSource(priv, priv->rf_mode); |
1351 | if (ret != XC_RESULT_SUCCESS) { | 1432 | if (ret != XC_RESULT_SUCCESS) { |