aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/firewire/firedtv-avc.c
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
commitc71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch)
treeecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /drivers/media/dvb/firewire/firedtv-avc.c
parentea53c912f8a86a8567697115b6a0d8152beee5c8 (diff)
parent6a00f206debf8a5c8899055726ad127dbeeed098 (diff)
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts: litmus/sched_cedf.c
Diffstat (limited to 'drivers/media/dvb/firewire/firedtv-avc.c')
-rw-r--r--drivers/media/dvb/firewire/firedtv-avc.c89
1 files changed, 58 insertions, 31 deletions
diff --git a/drivers/media/dvb/firewire/firedtv-avc.c b/drivers/media/dvb/firewire/firedtv-avc.c
index 28294af752db..21c52e3b522e 100644
--- a/drivers/media/dvb/firewire/firedtv-avc.c
+++ b/drivers/media/dvb/firewire/firedtv-avc.c
@@ -24,6 +24,8 @@
24#include <linux/wait.h> 24#include <linux/wait.h>
25#include <linux/workqueue.h> 25#include <linux/workqueue.h>
26 26
27#include <dvb_frontend.h>
28
27#include "firedtv.h" 29#include "firedtv.h"
28 30
29#define FCP_COMMAND_REGISTER 0xfffff0000b00ULL 31#define FCP_COMMAND_REGISTER 0xfffff0000b00ULL
@@ -130,6 +132,20 @@ MODULE_PARM_DESC(debug, "Verbose logging (none = 0"
130 ", FCP payloads = " __stringify(AVC_DEBUG_FCP_PAYLOADS) 132 ", FCP payloads = " __stringify(AVC_DEBUG_FCP_PAYLOADS)
131 ", or a combination, or all = -1)"); 133 ", or a combination, or all = -1)");
132 134
135/*
136 * This is a workaround since there is no vendor specific command to retrieve
137 * ca_info using AVC. If this parameter is not used, ca_system_id will be
138 * filled with application_manufacturer from ca_app_info.
139 * Digital Everywhere have said that adding ca_info is on their TODO list.
140 */
141static unsigned int num_fake_ca_system_ids;
142static int fake_ca_system_ids[4] = { -1, -1, -1, -1 };
143module_param_array(fake_ca_system_ids, int, &num_fake_ca_system_ids, 0644);
144MODULE_PARM_DESC(fake_ca_system_ids, "If your CAM application manufacturer "
145 "does not have the same ca_system_id as your CAS, you can "
146 "override what ca_system_ids are presented to the "
147 "application by setting this field to an array of ids.");
148
133static const char *debug_fcp_ctype(unsigned int ctype) 149static const char *debug_fcp_ctype(unsigned int ctype)
134{ 150{
135 static const char *ctypes[] = { 151 static const char *ctypes[] = {
@@ -225,8 +241,8 @@ static int avc_write(struct firedtv *fdtv)
225 if (unlikely(avc_debug)) 241 if (unlikely(avc_debug))
226 debug_fcp(fdtv->avc_data, fdtv->avc_data_length); 242 debug_fcp(fdtv->avc_data, fdtv->avc_data_length);
227 243
228 err = fdtv->backend->write(fdtv, FCP_COMMAND_REGISTER, 244 err = fdtv_write(fdtv, FCP_COMMAND_REGISTER,
229 fdtv->avc_data, fdtv->avc_data_length); 245 fdtv->avc_data, fdtv->avc_data_length);
230 if (err) { 246 if (err) {
231 dev_err(fdtv->device, "FCP command write failed\n"); 247 dev_err(fdtv->device, "FCP command write failed\n");
232 248
@@ -368,10 +384,30 @@ static int avc_tuner_tuneqpsk(struct firedtv *fdtv,
368 c->operand[12] = 0; 384 c->operand[12] = 0;
369 385
370 if (fdtv->type == FIREDTV_DVB_S2) { 386 if (fdtv->type == FIREDTV_DVB_S2) {
371 c->operand[13] = 0x1; 387 if (fdtv->fe.dtv_property_cache.delivery_system == SYS_DVBS2) {
372 c->operand[14] = 0xff; 388 switch (fdtv->fe.dtv_property_cache.modulation) {
373 c->operand[15] = 0xff; 389 case QAM_16: c->operand[13] = 0x1; break;
374 390 case QPSK: c->operand[13] = 0x2; break;
391 case PSK_8: c->operand[13] = 0x3; break;
392 default: c->operand[13] = 0x2; break;
393 }
394 switch (fdtv->fe.dtv_property_cache.rolloff) {
395 case ROLLOFF_AUTO: c->operand[14] = 0x2; break;
396 case ROLLOFF_35: c->operand[14] = 0x2; break;
397 case ROLLOFF_20: c->operand[14] = 0x0; break;
398 case ROLLOFF_25: c->operand[14] = 0x1; break;
399 /* case ROLLOFF_NONE: c->operand[14] = 0xff; break; */
400 }
401 switch (fdtv->fe.dtv_property_cache.pilot) {
402 case PILOT_AUTO: c->operand[15] = 0x0; break;
403 case PILOT_OFF: c->operand[15] = 0x0; break;
404 case PILOT_ON: c->operand[15] = 0x1; break;
405 }
406 } else {
407 c->operand[13] = 0x1; /* auto modulation */
408 c->operand[14] = 0xff; /* disable rolloff */
409 c->operand[15] = 0xff; /* disable pilot */
410 }
375 return 16; 411 return 16;
376 } else { 412 } else {
377 return 13; 413 return 13;
@@ -977,7 +1013,7 @@ int avc_ca_info(struct firedtv *fdtv, char *app_info, unsigned int *len)
977{ 1013{
978 struct avc_command_frame *c = (void *)fdtv->avc_data; 1014 struct avc_command_frame *c = (void *)fdtv->avc_data;
979 struct avc_response_frame *r = (void *)fdtv->avc_data; 1015 struct avc_response_frame *r = (void *)fdtv->avc_data;
980 int pos, ret; 1016 int i, pos, ret;
981 1017
982 mutex_lock(&fdtv->avc_mutex); 1018 mutex_lock(&fdtv->avc_mutex);
983 1019
@@ -1004,9 +1040,18 @@ int avc_ca_info(struct firedtv *fdtv, char *app_info, unsigned int *len)
1004 app_info[0] = (EN50221_TAG_CA_INFO >> 16) & 0xff; 1040 app_info[0] = (EN50221_TAG_CA_INFO >> 16) & 0xff;
1005 app_info[1] = (EN50221_TAG_CA_INFO >> 8) & 0xff; 1041 app_info[1] = (EN50221_TAG_CA_INFO >> 8) & 0xff;
1006 app_info[2] = (EN50221_TAG_CA_INFO >> 0) & 0xff; 1042 app_info[2] = (EN50221_TAG_CA_INFO >> 0) & 0xff;
1007 app_info[3] = 2; 1043 if (num_fake_ca_system_ids == 0) {
1008 app_info[4] = r->operand[pos + 0]; 1044 app_info[3] = 2;
1009 app_info[5] = r->operand[pos + 1]; 1045 app_info[4] = r->operand[pos + 0];
1046 app_info[5] = r->operand[pos + 1];
1047 } else {
1048 app_info[3] = num_fake_ca_system_ids * 2;
1049 for (i = 0; i < num_fake_ca_system_ids; i++) {
1050 app_info[4 + i * 2] =
1051 (fake_ca_system_ids[i] >> 8) & 0xff;
1052 app_info[5 + i * 2] = fake_ca_system_ids[i] & 0xff;
1053 }
1054 }
1010 *len = app_info[3] + 4; 1055 *len = app_info[3] + 4;
1011out: 1056out:
1012 mutex_unlock(&fdtv->avc_mutex); 1057 mutex_unlock(&fdtv->avc_mutex);
@@ -1275,14 +1320,10 @@ static int cmp_read(struct firedtv *fdtv, u64 addr, __be32 *data)
1275{ 1320{
1276 int ret; 1321 int ret;
1277 1322
1278 mutex_lock(&fdtv->avc_mutex); 1323 ret = fdtv_read(fdtv, addr, data);
1279
1280 ret = fdtv->backend->read(fdtv, addr, data);
1281 if (ret < 0) 1324 if (ret < 0)
1282 dev_err(fdtv->device, "CMP: read I/O error\n"); 1325 dev_err(fdtv->device, "CMP: read I/O error\n");
1283 1326
1284 mutex_unlock(&fdtv->avc_mutex);
1285
1286 return ret; 1327 return ret;
1287} 1328}
1288 1329
@@ -1290,18 +1331,9 @@ static int cmp_lock(struct firedtv *fdtv, u64 addr, __be32 data[])
1290{ 1331{
1291 int ret; 1332 int ret;
1292 1333
1293 mutex_lock(&fdtv->avc_mutex); 1334 ret = fdtv_lock(fdtv, addr, data);
1294
1295 /* data[] is stack-allocated and should not be DMA-mapped. */
1296 memcpy(fdtv->avc_data, data, 8);
1297
1298 ret = fdtv->backend->lock(fdtv, addr, fdtv->avc_data);
1299 if (ret < 0) 1335 if (ret < 0)
1300 dev_err(fdtv->device, "CMP: lock I/O error\n"); 1336 dev_err(fdtv->device, "CMP: lock I/O error\n");
1301 else
1302 memcpy(data, fdtv->avc_data, 8);
1303
1304 mutex_unlock(&fdtv->avc_mutex);
1305 1337
1306 return ret; 1338 return ret;
1307} 1339}
@@ -1360,10 +1392,7 @@ repeat:
1360 /* FIXME: this is for the worst case - optimize */ 1392 /* FIXME: this is for the worst case - optimize */
1361 set_opcr_overhead_id(opcr, 0); 1393 set_opcr_overhead_id(opcr, 0);
1362 1394
1363 /* 1395 /* FIXME: allocate isochronous channel and bandwidth at IRM */
1364 * FIXME: allocate isochronous channel and bandwidth at IRM
1365 * fdtv->backend->alloc_resources(fdtv, channels_mask, bw);
1366 */
1367 } 1396 }
1368 1397
1369 set_opcr_p2p_connections(opcr, get_opcr_p2p_connections(*opcr) + 1); 1398 set_opcr_p2p_connections(opcr, get_opcr_p2p_connections(*opcr) + 1);
@@ -1379,8 +1408,6 @@ repeat:
1379 /* 1408 /*
1380 * FIXME: if old_opcr.P2P_Connections > 0, 1409 * FIXME: if old_opcr.P2P_Connections > 0,
1381 * deallocate isochronous channel and bandwidth at IRM 1410 * deallocate isochronous channel and bandwidth at IRM
1382 * if (...)
1383 * fdtv->backend->dealloc_resources(fdtv, channel, bw);
1384 */ 1411 */
1385 1412
1386 if (++attempts < 6) /* arbitrary limit */ 1413 if (++attempts < 6) /* arbitrary limit */