aboutsummaryrefslogtreecommitdiff
path: root/drivers/media/dvb/firesat/avc_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb/firesat/avc_api.c')
-rw-r--r--drivers/media/dvb/firesat/avc_api.c1074
1 files changed, 416 insertions, 658 deletions
diff --git a/drivers/media/dvb/firesat/avc_api.c b/drivers/media/dvb/firesat/avc_api.c
index 6337f9f21d0..56911f3df7f 100644
--- a/drivers/media/dvb/firesat/avc_api.c
+++ b/drivers/media/dvb/firesat/avc_api.c
@@ -11,14 +11,16 @@
* the License, or (at your option) any later version.
*/
+#include <linux/bug.h>
#include <linux/crc32.h>
#include <linux/delay.h>
+#include <linux/device.h>
#include <linux/kernel.h>
#include <linux/moduleparam.h>
#include <linux/mutex.h>
+#include <linux/string.h>
#include <linux/wait.h>
#include <linux/workqueue.h>
-#include <asm/atomic.h>
#include <ieee1394_transactions.h>
#include <nodemgr.h>
@@ -27,230 +29,61 @@
#include "firesat.h"
#include "firesat-rc.h"
-#define RESPONSE_REGISTER 0xFFFFF0000D00ULL
-#define COMMAND_REGISTER 0xFFFFF0000B00ULL
-#define PCR_BASE_ADDRESS 0xFFFFF0000900ULL
+#define FCP_COMMAND_REGISTER 0xfffff0000b00ULL
-static unsigned int avc_comm_debug = 0;
-module_param(avc_comm_debug, int, 0644);
-MODULE_PARM_DESC(avc_comm_debug, "debug logging level [0..2] of AV/C communication, default is 0 (no)");
-
-/* Frees an allocated packet */
-static void avc_free_packet(struct hpsb_packet *packet)
-{
- hpsb_free_tlabel(packet);
- hpsb_free_packet(packet);
-}
-
-static const char* get_ctype_string(__u8 ctype)
-{
- switch(ctype)
- {
- case 0:
- return "CONTROL";
- case 1:
- return "STATUS";
- case 2:
- return "SPECIFIC_INQUIRY";
- case 3:
- return "NOTIFY";
- case 4:
- return "GENERAL_INQUIRY";
- }
- return "UNKNOWN";
-}
-
-static const char* get_resp_string(__u8 ctype)
-{
- switch(ctype)
- {
- case 8:
- return "NOT_IMPLEMENTED";
- case 9:
- return "ACCEPTED";
- case 10:
- return "REJECTED";
- case 11:
- return "IN_TRANSITION";
- case 12:
- return "IMPLEMENTED_STABLE";
- case 13:
- return "CHANGED";
- case 15:
- return "INTERIM";
- }
- return "UNKNOWN";
-}
-
-static const char* get_subunit_address(__u8 subunit_id, __u8 subunit_type)
-{
- if (subunit_id == 7 && subunit_type == 0x1F)
- return "Unit";
- if (subunit_id == 0 && subunit_type == 0x05)
- return "Tuner(0)";
- return "Unsupported";
-}
-
-static const char* get_opcode_string(__u8 opcode)
-{
- switch(opcode)
- {
- case 0x02:
- return "PlugInfo";
- case 0x08:
- return "OpenDescriptor";
- case 0x09:
- return "ReadDescriptor";
- case 0x18:
- return "OutputPlugSignalFormat";
- case 0x31:
- return "SubunitInfo";
- case 0x30:
- return "UnitInfo";
- case 0xB2:
- return "Power";
- case 0xC8:
- return "DirectSelectInformationType";
- case 0xCB:
- return "DirectSelectData";
- case 0x00:
- return "Vendor";
-
- }
- return "Unknown";
-}
-
-static void log_command_frame(const AVCCmdFrm *CmdFrm)
-{
- int k;
- printk(KERN_INFO "AV/C Command Frame:\n");
- printk(KERN_INFO "CommandType=%s, Address=%s(0x%02X,0x%02X), "
- "opcode=%s(0x%02X), length=%d\n",
- get_ctype_string(CmdFrm->ctype),
- get_subunit_address(CmdFrm->suid, CmdFrm->sutyp),
- CmdFrm->suid, CmdFrm->sutyp, get_opcode_string(CmdFrm->opcode),
- CmdFrm->opcode, CmdFrm->length);
- if (avc_comm_debug > 1) {
- for(k = 0; k < CmdFrm->length - 3; k++) {
- if (k % 5 != 0)
- printk(", ");
- else if (k != 0)
- printk("\n");
- printk(KERN_INFO "operand[%d] = %02X", k,
- CmdFrm->operand[k]);
- }
- printk(KERN_INFO "\n");
- }
-}
-
-static void log_response_frame(const AVCRspFrm *RspFrm)
+static int __avc_write(struct firesat *firesat,
+ const AVCCmdFrm *CmdFrm, AVCRspFrm *RspFrm)
{
- int k;
- printk(KERN_INFO "AV/C Response Frame:\n");
- printk(KERN_INFO "Response=%s, Address=%s(0x%02X,0x%02X), "
- "opcode=%s(0x%02X), length=%d\n", get_resp_string(RspFrm->resp),
- get_subunit_address(RspFrm->suid, RspFrm->sutyp),
- RspFrm->suid, RspFrm->sutyp, get_opcode_string(RspFrm->opcode),
- RspFrm->opcode, RspFrm->length);
- if (avc_comm_debug > 1) {
- for(k = 0; k < RspFrm->length - 3; k++) {
- if (k % 5 != 0)
- printk(KERN_INFO ", ");
- else if (k != 0)
- printk(KERN_INFO "\n");
- printk(KERN_INFO "operand[%d] = %02X", k,
- RspFrm->operand[k]);
+ int err, retry;
+
+ if (RspFrm)
+ firesat->avc_reply_received = false;
+
+ for (retry = 0; retry < 6; retry++) {
+ err = hpsb_node_write(firesat->ud->ne, FCP_COMMAND_REGISTER,
+ (quadlet_t *)CmdFrm, CmdFrm->length);
+ if (err) {
+ firesat->avc_reply_received = true;
+ dev_err(&firesat->ud->device,
+ "FCP command write failed\n");
+ return err;
}
- printk(KERN_INFO "\n");
- }
-}
-
-static int __AVCWrite(struct firesat *firesat, const AVCCmdFrm *CmdFrm,
- AVCRspFrm *RspFrm) {
- struct hpsb_packet *packet;
- struct node_entry *ne;
- int num_tries = 0;
- int packet_ok = 0;
-
- ne = firesat->nodeentry;
- if(!ne) {
- printk(KERN_ERR "%s: lost node!\n",__func__);
- return -EIO;
- }
-
- /* need all input data */
- if(!firesat || !ne || !CmdFrm) {
- printk(KERN_ERR "%s: missing input data!\n",__func__);
- return -EINVAL;
- }
- if (avc_comm_debug > 0) {
- log_command_frame(CmdFrm);
- }
+ if (!RspFrm)
+ return 0;
- if(RspFrm)
- atomic_set(&firesat->avc_reply_received, 0);
-
- while (packet_ok == 0 && num_tries < 6) {
- num_tries++;
- packet_ok = 1;
- packet = hpsb_make_writepacket(ne->host, ne->nodeid,
- COMMAND_REGISTER,
- (quadlet_t*)CmdFrm,
- CmdFrm->length);
- hpsb_set_packet_complete_task(packet,
- (void (*)(void*))avc_free_packet,
- packet);
- hpsb_node_fill_packet(ne, packet);
-
- if (hpsb_send_packet(packet) < 0) {
- avc_free_packet(packet);
- atomic_set(&firesat->avc_reply_received, 1);
- printk(KERN_ERR "%s: send failed!\n",__func__);
- return -EIO;
- }
+ /*
+ * AV/C specs say that answers should be sent within 150 ms.
+ * Time out after 200 ms.
+ */
+ if (wait_event_timeout(firesat->avc_wait,
+ firesat->avc_reply_received,
+ HZ / 5) != 0) {
+ memcpy(RspFrm, firesat->respfrm, firesat->resp_length);
+ RspFrm->length = firesat->resp_length;
- if(RspFrm) {
- // AV/C specs say that answers should be send within
- // 150 ms so let's time out after 200 ms
- if (wait_event_timeout(firesat->avc_wait,
- atomic_read(&firesat->avc_reply_received) == 1,
- HZ / 5) == 0) {
- packet_ok = 0;
- }
- else {
- memcpy(RspFrm, firesat->respfrm,
- firesat->resp_length);
- RspFrm->length = firesat->resp_length;
- if (avc_comm_debug > 0) {
- log_response_frame(RspFrm);
- }
- }
+ return 0;
}
}
- if (packet_ok == 0) {
- printk(KERN_ERR "%s: AV/C response timed out 6 times.\n",
- __func__);
- return -ETIMEDOUT;
- }
-
- return 0;
+ dev_err(&firesat->ud->device, "FCP response timed out\n");
+ return -ETIMEDOUT;
}
-int AVCWrite(struct firesat*firesat, const AVCCmdFrm *CmdFrm, AVCRspFrm *RspFrm)
+static int avc_write(struct firesat *firesat,
+ const AVCCmdFrm *CmdFrm, AVCRspFrm *RspFrm)
{
int ret;
if (mutex_lock_interruptible(&firesat->avc_mutex))
return -EINTR;
- ret = __AVCWrite(firesat, CmdFrm, RspFrm);
+ ret = __avc_write(firesat, CmdFrm, RspFrm);
mutex_unlock(&firesat->avc_mutex);
return ret;
}
-int AVCRecv(struct firesat *firesat, u8 *data, size_t length)
+int avc_recv(struct firesat *firesat, u8 *data, size_t length)
{
AVCRspFrm *RspFrm = (AVCRspFrm *)data;
@@ -260,87 +93,64 @@ int AVCRecv(struct firesat *firesat, u8 *data, size_t length)
RspFrm->operand[2] == SFE_VENDOR_DE_COMPANYID_2 &&
RspFrm->operand[3] == SFE_VENDOR_OPCODE_REGISTER_REMOTE_CONTROL) {
if (RspFrm->resp == CHANGED) {
- firesat_handle_rc(RspFrm->operand[4] << 8 |
- RspFrm->operand[5]);
+ firesat_handle_rc(firesat,
+ RspFrm->operand[4] << 8 | RspFrm->operand[5]);
schedule_work(&firesat->remote_ctrl_work);
} else if (RspFrm->resp != INTERIM) {
- printk(KERN_INFO "firedtv: remote control result = "
- "%d\n", RspFrm->resp);
+ dev_info(&firesat->ud->device,
+ "remote control result = %d\n", RspFrm->resp);
}
return 0;
}
- if(atomic_read(&firesat->avc_reply_received) == 1) {
- printk(KERN_ERR "%s: received out-of-order AVC response, "
- "ignored\n",__func__);
- return -EINVAL;
+ if (firesat->avc_reply_received) {
+ dev_err(&firesat->ud->device,
+ "received out-of-order AVC response, ignored\n");
+ return -EIO;
}
-// AVCRspFrm *resp=(AVCRspFrm *)data;
-// int k;
-
-// printk(KERN_INFO "resp=0x%x\n",resp->resp);
-// printk(KERN_INFO "cts=0x%x\n",resp->cts);
-// printk(KERN_INFO "suid=0x%x\n",resp->suid);
-// printk(KERN_INFO "sutyp=0x%x\n",resp->sutyp);
-// printk(KERN_INFO "opcode=0x%x\n",resp->opcode);
-// printk(KERN_INFO "length=%d\n",resp->length);
-// for(k=0;k<2;k++)
-// printk(KERN_INFO "operand[%d]=%02x\n",k,resp->operand[k]);
+ memcpy(firesat->respfrm, data, length);
+ firesat->resp_length = length;
- memcpy(firesat->respfrm,data,length);
- firesat->resp_length=length;
-
- atomic_set(&firesat->avc_reply_received, 1);
+ firesat->avc_reply_received = true;
wake_up(&firesat->avc_wait);
return 0;
}
-// tuning command for setting the relative LNB frequency (not supported by the AVC standard)
-static void AVCTuner_tuneQPSK(struct firesat *firesat, struct dvb_frontend_parameters *params, AVCCmdFrm *CmdFrm) {
-
- memset(CmdFrm, 0, sizeof(AVCCmdFrm));
-
- CmdFrm->cts = AVC;
- CmdFrm->ctype = CONTROL;
- CmdFrm->sutyp = 0x5;
- CmdFrm->suid = firesat->subunit;
+/*
+ * tuning command for setting the relative LNB frequency
+ * (not supported by the AVC standard)
+ */
+static void avc_tuner_tuneqpsk(struct firesat *firesat,
+ struct dvb_frontend_parameters *params, AVCCmdFrm *CmdFrm)
+{
CmdFrm->opcode = VENDOR;
- CmdFrm->operand[0]=SFE_VENDOR_DE_COMPANYID_0;
- CmdFrm->operand[1]=SFE_VENDOR_DE_COMPANYID_1;
- CmdFrm->operand[2]=SFE_VENDOR_DE_COMPANYID_2;
- CmdFrm->operand[3]=SFE_VENDOR_OPCODE_TUNE_QPSK;
-
- printk(KERN_INFO "%s: tuning to frequency %u\n",__func__,params->frequency);
-
- CmdFrm->operand[4] = (params->frequency >> 24) & 0xFF;
- CmdFrm->operand[5] = (params->frequency >> 16) & 0xFF;
- CmdFrm->operand[6] = (params->frequency >> 8) & 0xFF;
- CmdFrm->operand[7] = params->frequency & 0xFF;
+ CmdFrm->operand[0] = SFE_VENDOR_DE_COMPANYID_0;
+ CmdFrm->operand[1] = SFE_VENDOR_DE_COMPANYID_1;
+ CmdFrm->operand[2] = SFE_VENDOR_DE_COMPANYID_2;
+ CmdFrm->operand[3] = SFE_VENDOR_OPCODE_TUNE_QPSK;
- printk(KERN_INFO "%s: symbol rate = %uBd\n",__func__,params->u.qpsk.symbol_rate);
+ CmdFrm->operand[4] = (params->frequency >> 24) & 0xff;
+ CmdFrm->operand[5] = (params->frequency >> 16) & 0xff;
+ CmdFrm->operand[6] = (params->frequency >> 8) & 0xff;
+ CmdFrm->operand[7] = params->frequency & 0xff;
- CmdFrm->operand[8] = ((params->u.qpsk.symbol_rate/1000) >> 8) & 0xFF;
- CmdFrm->operand[9] = (params->u.qpsk.symbol_rate/1000) & 0xFF;
+ CmdFrm->operand[8] = ((params->u.qpsk.symbol_rate / 1000) >> 8) & 0xff;
+ CmdFrm->operand[9] = (params->u.qpsk.symbol_rate / 1000) & 0xff;
switch(params->u.qpsk.fec_inner) {
case FEC_1_2:
- CmdFrm->operand[10] = 0x1;
- break;
+ CmdFrm->operand[10] = 0x1; break;
case FEC_2_3:
- CmdFrm->operand[10] = 0x2;
- break;
+ CmdFrm->operand[10] = 0x2; break;
case FEC_3_4:
- CmdFrm->operand[10] = 0x3;
- break;
+ CmdFrm->operand[10] = 0x3; break;
case FEC_5_6:
- CmdFrm->operand[10] = 0x4;
- break;
+ CmdFrm->operand[10] = 0x4; break;
case FEC_7_8:
- CmdFrm->operand[10] = 0x5;
- break;
+ CmdFrm->operand[10] = 0x5; break;
case FEC_4_5:
case FEC_8_9:
case FEC_AUTO:
@@ -348,278 +158,287 @@ static void AVCTuner_tuneQPSK(struct firesat *firesat, struct dvb_frontend_param
CmdFrm->operand[10] = 0x0;
}
- if(firesat->voltage == 0xff)
+ if (firesat->voltage == 0xff)
CmdFrm->operand[11] = 0xff;
+ else if (firesat->voltage == SEC_VOLTAGE_18) /* polarisation */
+ CmdFrm->operand[11] = 0;
else
- CmdFrm->operand[11] = (firesat->voltage==SEC_VOLTAGE_18)?0:1; // polarisation
- if(firesat->tone == 0xff)
+ CmdFrm->operand[11] = 1;
+
+ if (firesat->tone == 0xff)
CmdFrm->operand[12] = 0xff;
+ else if (firesat->tone == SEC_TONE_ON) /* band */
+ CmdFrm->operand[12] = 1;
else
- CmdFrm->operand[12] = (firesat->tone==SEC_TONE_ON)?1:0; // band
+ CmdFrm->operand[12] = 0;
if (firesat->type == FireSAT_DVB_S2) {
CmdFrm->operand[13] = 0x1;
- CmdFrm->operand[14] = 0xFF;
- CmdFrm->operand[15] = 0xFF;
+ CmdFrm->operand[14] = 0xff;
+ CmdFrm->operand[15] = 0xff;
+ CmdFrm->length = 20;
+ } else {
+ CmdFrm->length = 16;
}
+}
+
+static void avc_tuner_dsd_dvb_c(struct dvb_frontend_parameters *params,
+ AVCCmdFrm *CmdFrm)
+{
+ M_VALID_FLAGS flags;
- CmdFrm->length = 16;
+ flags.Bits.Modulation = params->u.qam.modulation != QAM_AUTO;
+ flags.Bits.FEC_inner = params->u.qam.fec_inner != FEC_AUTO;
+ flags.Bits.FEC_outer = 0;
+ flags.Bits.Symbol_Rate = 1;
+ flags.Bits.Frequency = 1;
+ flags.Bits.Orbital_Pos = 0;
+ flags.Bits.Polarisation = 0;
+ flags.Bits.reserved_fields = 0;
+ flags.Bits.reserved1 = 0;
+ flags.Bits.Network_ID = 0;
+
+ CmdFrm->opcode = DSD;
+
+ CmdFrm->operand[0] = 0; /* source plug */
+ CmdFrm->operand[1] = 0xd2; /* subfunction replace */
+ CmdFrm->operand[2] = 0x20; /* system id = DVB */
+ CmdFrm->operand[3] = 0x00; /* antenna number */
+ /* system_specific_multiplex selection_length */
+ CmdFrm->operand[4] = 0x11;
+ CmdFrm->operand[5] = flags.Valid_Word.ByteHi; /* valid_flags [0] */
+ CmdFrm->operand[6] = flags.Valid_Word.ByteLo; /* valid_flags [1] */
+ CmdFrm->operand[7] = 0x00;
+ CmdFrm->operand[8] = 0x00;
+ CmdFrm->operand[9] = 0x00;
+ CmdFrm->operand[10] = 0x00;
+
+ CmdFrm->operand[11] =
+ (((params->frequency / 4000) >> 16) & 0xff) | (2 << 6);
+ CmdFrm->operand[12] =
+ ((params->frequency / 4000) >> 8) & 0xff;
+ CmdFrm->operand[13] = (params->frequency / 4000) & 0xff;
+ CmdFrm->operand[14] =
+ ((params->u.qpsk.symbol_rate / 1000) >> 12) & 0xff;
+ CmdFrm->operand[15] =
+ ((params->u.qpsk.symbol_rate / 1000) >> 4) & 0xff;
+ CmdFrm->operand[16] =
+ ((params->u.qpsk.symbol_rate / 1000) << 4) & 0xf0;
+ CmdFrm->operand[17] = 0x00;
+
+ switch (params->u.qpsk.fec_inner) {
+ case FEC_1_2:
+ CmdFrm->operand[18] = 0x1; break;
+ case FEC_2_3:
+ CmdFrm->operand[18] = 0x2; break;
+ case FEC_3_4:
+ CmdFrm->operand[18] = 0x3; break;
+ case FEC_5_6:
+ CmdFrm->operand[18] = 0x4; break;
+ case FEC_7_8:
+ CmdFrm->operand[18] = 0x5; break;
+ case FEC_8_9:
+ CmdFrm->operand[18] = 0x6; break;
+ case FEC_4_5:
+ CmdFrm->operand[18] = 0x8; break;
+ case FEC_AUTO:
+ default:
+ CmdFrm->operand[18] = 0x0;
+ }
+ switch (params->u.qam.modulation) {
+ case QAM_16:
+ CmdFrm->operand[19] = 0x08; break;
+ case QAM_32:
+ CmdFrm->operand[19] = 0x10; break;
+ case QAM_64:
+ CmdFrm->operand[19] = 0x18; break;
+ case QAM_128:
+ CmdFrm->operand[19] = 0x20; break;
+ case QAM_256:
+ CmdFrm->operand[19] = 0x28; break;
+ case QAM_AUTO:
+ default:
+ CmdFrm->operand[19] = 0x00;
+ }
+ CmdFrm->operand[20] = 0x00;
+ CmdFrm->operand[21] = 0x00;
+ /* Nr_of_dsd_sel_specs = 0 -> no PIDs are transmitted */
+ CmdFrm->operand[22] = 0x00;
+
+ CmdFrm->length = 28;
}
-int AVCTuner_DSD(struct firesat *firesat, struct dvb_frontend_parameters *params, __u8 *status) {
+static void avc_tuner_dsd_dvb_t(struct dvb_frontend_parameters *params,
+ AVCCmdFrm *CmdFrm)
+{
+ M_VALID_FLAGS flags;
+
+ flags.Bits_T.GuardInterval =
+ params->u.ofdm.guard_interval != GUARD_INTERVAL_AUTO;
+ flags.Bits_T.CodeRateLPStream =
+ params->u.ofdm.code_rate_LP != FEC_AUTO;
+ flags.Bits_T.CodeRateHPStream =
+ params->u.ofdm.code_rate_HP != FEC_AUTO;
+ flags.Bits_T.HierarchyInfo =
+ params->u.ofdm.hierarchy_information != HIERARCHY_AUTO;
+ flags.Bits_T.Constellation =
+ params->u.ofdm.constellation != QAM_AUTO;
+ flags.Bits_T.Bandwidth =
+ params->u.ofdm.bandwidth != BANDWIDTH_AUTO;
+ flags.Bits_T.CenterFrequency = 1;
+ flags.Bits_T.reserved1 = 0;
+ flags.Bits_T.reserved2 = 0;
+ flags.Bits_T.OtherFrequencyFlag = 0;
+ flags.Bits_T.TransmissionMode =
+ params->u.ofdm.transmission_mode != TRANSMISSION_MODE_AUTO;
+ flags.Bits_T.NetworkId = 0;
+
+ CmdFrm->opcode = DSD;
+
+ CmdFrm->operand[0] = 0; /* source plug */
+ CmdFrm->operand[1] = 0xd2; /* subfunction replace */
+ CmdFrm->operand[2] = 0x20; /* system id = DVB */
+ CmdFrm->operand[3] = 0x00; /* antenna number */
+ /* system_specific_multiplex selection_length */
+ CmdFrm->operand[4] = 0x0c;
+ CmdFrm->operand[5] = flags.Valid_Word.ByteHi; /* valid_flags [0] */
+ CmdFrm->operand[6] = flags.Valid_Word.ByteLo; /* valid_flags [1] */
+ CmdFrm->operand[7] = 0x0;
+ CmdFrm->operand[8] = (params->frequency / 10) >> 24;
+ CmdFrm->operand[9] = ((params->frequency / 10) >> 16) & 0xff;
+ CmdFrm->operand[10] = ((params->frequency / 10) >> 8) & 0xff;
+ CmdFrm->operand[11] = (params->frequency / 10) & 0xff;
+
+ switch (params->u.ofdm.bandwidth) {
+ case BANDWIDTH_7_MHZ:
+ CmdFrm->operand[12] = 0x20; break;
+ case BANDWIDTH_8_MHZ:
+ case BANDWIDTH_6_MHZ: /* not defined by AVC spec */
+ case BANDWIDTH_AUTO:
+ default:
+ CmdFrm->operand[12] = 0x00;
+ }
+ switch (params->u.ofdm.constellation) {
+ case QAM_16:
+ CmdFrm->operand[13] = 1 << 6; break;
+ case QAM_64:
+ CmdFrm->operand[13] = 2 << 6; break;
+ case QPSK:
+ default:
+ CmdFrm->operand[13] = 0x00;
+ }
+ switch (params->u.ofdm.hierarchy_information) {
+ case HIERARCHY_1:
+ CmdFrm->operand[13] |= 1 << 3; break;
+ case HIERARCHY_2:
+ CmdFrm->operand[13] |= 2 << 3; break;
+ case HIERARCHY_4:
+ CmdFrm->operand[13] |= 3 << 3; break;
+ case HIERARCHY_AUTO:
+ case HIERARCHY_NONE:
+ default:
+ break;
+ }
+ switch (params->u.ofdm.code_rate_HP) {
+ case FEC_2_3:
+ CmdFrm->operand[13] |= 1; break;
+ case FEC_3_4:
+ CmdFrm->operand[13] |= 2; break;
+ case FEC_5_6:
+ CmdFrm->operand[13] |= 3; break;
+ case FEC_7_8:
+ CmdFrm->operand[13] |= 4; break;
+ case FEC_1_2:
+ default:
+ break;
+ }
+ switch (params->u.ofdm.code_rate_LP) {
+ case FEC_2_3:
+ CmdFrm->operand[14] = 1 << 5; break;
+ case FEC_3_4:
+ CmdFrm->operand[14] = 2 << 5; break;
+ case FEC_5_6:
+ CmdFrm->operand[14] = 3 << 5; break;
+ case FEC_7_8:
+ CmdFrm->operand[14] = 4 << 5; break;
+ case FEC_1_2:
+ default:
+ CmdFrm->operand[14] = 0x00; break;
+ }
+ switch (params->u.ofdm.guard_interval) {
+ case GUARD_INTERVAL_1_16:
+ CmdFrm->operand[14] |= 1 << 3; break;
+ case GUARD_INTERVAL_1_8:
+ CmdFrm->operand[14] |= 2 << 3; break;
+ case GUARD_INTERVAL_1_4:
+ CmdFrm->operand[14] |= 3 << 3; break;
+ case GUARD_INTERVAL_1_32:
+ case GUARD_INTERVAL_AUTO:
+ default:
+ break;
+ }
+ switch (params->u.ofdm.transmission_mode) {
+ case TRANSMISSION_MODE_8K:
+ CmdFrm->operand[14] |= 1 << 1; break;
+ case TRANSMISSION_MODE_2K:
+ case TRANSMISSION_MODE_AUTO:
+ default:
+ break;
+ }
+
+ CmdFrm->operand[15] = 0x00; /* network_ID[0] */
+ CmdFrm->operand[16] = 0x00; /* network_ID[1] */
+ /* Nr_of_dsd_sel_specs = 0 -> no PIDs are transmitted */
+ CmdFrm->operand[17] = 0x00;
+
+ CmdFrm->length = 24;
+}
+
+int avc_tuner_dsd(struct firesat *firesat,
+ struct dvb_frontend_parameters *params)
+{
AVCCmdFrm CmdFrm;
AVCRspFrm RspFrm;
- M_VALID_FLAGS flags;
- int k;
-
-// printk(KERN_INFO "%s\n", __func__);
-
- if (firesat->type == FireSAT_DVB_S || firesat->type == FireSAT_DVB_S2)
- AVCTuner_tuneQPSK(firesat, params, &CmdFrm);
- else {
- if(firesat->type == FireSAT_DVB_T) {
- flags.Bits_T.GuardInterval = (params->u.ofdm.guard_interval != GUARD_INTERVAL_AUTO);
- flags.Bits_T.CodeRateLPStream = (params->u.ofdm.code_rate_LP != FEC_AUTO);
- flags.Bits_T.CodeRateHPStream = (params->u.ofdm.code_rate_HP != FEC_AUTO);
- flags.Bits_T.HierarchyInfo = (params->u.ofdm.hierarchy_information != HIERARCHY_AUTO);
- flags.Bits_T.Constellation = (params->u.ofdm.constellation != QAM_AUTO);
- flags.Bits_T.Bandwidth = (params->u.ofdm.bandwidth != BANDWIDTH_AUTO);
- flags.Bits_T.CenterFrequency = 1;
- flags.Bits_T.reserved1 = 0;
- flags.Bits_T.reserved2 = 0;
- flags.Bits_T.OtherFrequencyFlag = 0;
- flags.Bits_T.TransmissionMode = (params->u.ofdm.transmission_mode != TRANSMISSION_MODE_AUTO);
- flags.Bits_T.NetworkId = 0;
- } else {
- flags.Bits.Modulation =
- (params->u.qam.modulation != QAM_AUTO);
- flags.Bits.FEC_inner =
- (params->u.qam.fec_inner != FEC_AUTO);
- flags.Bits.FEC_outer = 0;
- flags.Bits.Symbol_Rate = 1;
- flags.Bits.Frequency = 1;
- flags.Bits.Orbital_Pos = 0;
- flags.Bits.Polarisation = 0;
- flags.Bits.reserved_fields = 0;
- flags.Bits.reserved1 = 0;
- flags.Bits.Network_ID = 0;
- }
- memset(&CmdFrm, 0, sizeof(AVCCmdFrm));
-
- CmdFrm.cts = AVC;
- CmdFrm.ctype = CONTROL;
- CmdFrm.sutyp = 0x5;
- CmdFrm.suid = firesat->subunit;
- CmdFrm.opcode = DSD;
-
- CmdFrm.operand[0] = 0; // source plug
- CmdFrm.operand[1] = 0xD2; // subfunction replace
- CmdFrm.operand[2] = 0x20; // system id = DVB
- CmdFrm.operand[3] = 0x00; // antenna number
- // system_specific_multiplex selection_length
- CmdFrm.operand[4] = (firesat->type == FireSAT_DVB_T)?0x0c:0x11;
- CmdFrm.operand[5] = flags.Valid_Word.ByteHi; // valid_flags [0]
- CmdFrm.operand[6] = flags.Valid_Word.ByteLo; // valid_flags [1]
-
- if(firesat->type == FireSAT_DVB_T) {
- CmdFrm.operand[7] = 0x0;
- CmdFrm.operand[8] = (params->frequency/10) >> 24;
- CmdFrm.operand[9] =
- ((params->frequency/10) >> 16) & 0xFF;
- CmdFrm.operand[10] =
- ((params->frequency/10) >> 8) & 0xFF;
- CmdFrm.operand[11] = (params->frequency/10) & 0xFF;
- switch(params->u.ofdm.bandwidth) {
- case BANDWIDTH_7_MHZ:
- CmdFrm.operand[12] = 0x20;
- break;
- case BANDWIDTH_8_MHZ:
- case BANDWIDTH_6_MHZ: // not defined by AVC spec
- case BANDWIDTH_AUTO:
- default:
- CmdFrm.operand[12] = 0x00;
- }
- switch(params->u.ofdm.constellation) {
- case QAM_16:
- CmdFrm.operand[13] = 1 << 6;
- break;
- case QAM_64:
- CmdFrm.operand[13] = 2 << 6;
- break;
- case QPSK:
- default:
- CmdFrm.operand[13] = 0x00;
- }
- switch(params->u.ofdm.hierarchy_information) {
- case HIERARCHY_1:
- CmdFrm.operand[13] |= 1 << 3;
- break;
- case HIERARCHY_2:
- CmdFrm.operand[13] |= 2 << 3;
- break;
- case HIERARCHY_4:
- CmdFrm.operand[13] |= 3 << 3;
- break;
- case HIERARCHY_AUTO:
- case HIERARCHY_NONE:
- default:
- break;
- }
- switch(params->u.ofdm.code_rate_HP) {
- case FEC_2_3:
- CmdFrm.operand[13] |= 1;
- break;
- case FEC_3_4:
- CmdFrm.operand[13] |= 2;
- break;
- case FEC_5_6:
- CmdFrm.operand[13] |= 3;
- break;
- case FEC_7_8:
- CmdFrm.operand[13] |= 4;
- break;
- case FEC_1_2:
- default:
- break;
- }
- switch(params->u.ofdm.code_rate_LP) {
- case FEC_2_3:
- CmdFrm.operand[14] = 1 << 5;
- break;
- case FEC_3_4:
- CmdFrm.operand[14] = 2 << 5;
- break;
- case FEC_5_6:
- CmdFrm.operand[14] = 3 << 5;
- break;
- case FEC_7_8:
- CmdFrm.operand[14] = 4 << 5;
- break;
- case FEC_1_2:
- default:
- CmdFrm.operand[14] = 0x00;
- break;
- }
- switch(params->u.ofdm.guard_interval) {
- case GUARD_INTERVAL_1_16:
- CmdFrm.operand[14] |= 1 << 3;
- break;
- case GUARD_INTERVAL_1_8:
- CmdFrm.operand[14] |= 2 << 3;
- break;
- case GUARD_INTERVAL_1_4:
- CmdFrm.operand[14] |= 3 << 3;
- break;
- case GUARD_INTERVAL_1_32:
- case GUARD_INTERVAL_AUTO:
- default:
- break;
- }
- switch(params->u.ofdm.transmission_mode) {
- case TRANSMISSION_MODE_8K:
- CmdFrm.operand[14] |= 1 << 1;
- break;
- case TRANSMISSION_MODE_2K:
- case TRANSMISSION_MODE_AUTO:
- default:
- break;
- }
-
- CmdFrm.operand[15] = 0x00; // network_ID[0]
- CmdFrm.operand[16] = 0x00; // network_ID[1]
- CmdFrm.operand[17] = 0x00; // Nr_of_dsd_sel_specs = 0 - > No PIDs are transmitted
-
- CmdFrm.length = 24;
- } else {
- CmdFrm.operand[7] = 0x00;
- CmdFrm.operand[8] = 0x00;
- CmdFrm.operand[9] = 0x00;
- CmdFrm.operand[10] = 0x00;
-
- CmdFrm.operand[11] =
- (((params->frequency/4000) >> 16) & 0xFF) | (2 << 6);
- CmdFrm.operand[12] =
- ((params->frequency/4000) >> 8) & 0xFF;
- CmdFrm.operand[13] = (params->frequency/4000) & 0xFF;
- CmdFrm.operand[14] =
- ((params->u.qpsk.symbol_rate/1000) >> 12) & 0xFF;
- CmdFrm.operand[15] =
- ((params->u.qpsk.symbol_rate/1000) >> 4) & 0xFF;
- CmdFrm.operand[16] =
- ((params->u.qpsk.symbol_rate/1000) << 4) & 0xF0;
- CmdFrm.operand[17] = 0x00;
- switch(params->u.qpsk.fec_inner) {
- case FEC_1_2:
- CmdFrm.operand[18] = 0x1;
- break;
- case FEC_2_3:
- CmdFrm.operand[18] = 0x2;
- break;
- case FEC_3_4:
- CmdFrm.operand[18] = 0x3;
- break;
- case FEC_5_6:
- CmdFrm.operand[18] = 0x4;
- break;
- case FEC_7_8:
- CmdFrm.operand[18] = 0x5;
- break;
- case FEC_8_9:
- CmdFrm.operand[18] = 0x6;
- break;
- case FEC_4_5:
- CmdFrm.operand[18] = 0x8;
- break;
- case FEC_AUTO:
- default:
- CmdFrm.operand[18] = 0x0;
- }
- switch(params->u.qam.modulation) {
- case QAM_16:
- CmdFrm.operand[19] = 0x08; // modulation
- break;
- case QAM_32:
- CmdFrm.operand[19] = 0x10; // modulation
- break;
- case QAM_64:
- CmdFrm.operand[19] = 0x18; // modulation
- break;
- case QAM_128:
- CmdFrm.operand[19] = 0x20; // modulation
- break;
- case QAM_256:
- CmdFrm.operand[19] = 0x28; // modulation
- break;
- case QAM_AUTO:
- default:
- CmdFrm.operand[19] = 0x00; // modulation
- }
- CmdFrm.operand[20] = 0x00;
- CmdFrm.operand[21] = 0x00;
- CmdFrm.operand[22] = 0x00; // Nr_of_dsd_sel_specs = 0 - > No PIDs are transmitted
-
- CmdFrm.length=28;
- }
- } // AVCTuner_DSD_direct
+ memset(&CmdFrm, 0, sizeof(AVCCmdFrm));
- if((k=AVCWrite(firesat,&CmdFrm,&RspFrm)))
- return k;
+ CmdFrm.cts = AVC;
+ CmdFrm.ctype = CONTROL;
+ CmdFrm.sutyp = 0x5;
+ CmdFrm.suid = firesat->subunit;
- mdelay(500);
+ switch (firesat->type) {
+ case FireSAT_DVB_S:
+ case FireSAT_DVB_S2:
+ avc_tuner_tuneqpsk(firesat, params, &CmdFrm); break;
+ case FireSAT_DVB_C:
+ avc_tuner_dsd_dvb_c(params, &CmdFrm); break;
+ case FireSAT_DVB_T:
+ avc_tuner_dsd_dvb_t(params, &CmdFrm); break;
+ default:
+ BUG();
+ }
+ if (avc_write(firesat, &CmdFrm, &RspFrm) < 0)
+ return -EIO;
+
+ msleep(500);
+#if 0
+ /* FIXME: */
+ /* u8 *status was an out-parameter of avc_tuner_dsd, unused by caller */
if(status)
*status=RspFrm.operand[2];
+#endif
return 0;
}
-int AVCTuner_SetPIDs(struct firesat *firesat, unsigned char pidc, u16 pid[])
+int avc_tuner_set_pids(struct firesat *firesat, unsigned char pidc, u16 pid[])
{
AVCCmdFrm CmdFrm;
AVCRspFrm RspFrm;
- int pos,k;
+ int pos, k;
- if(pidc > 16 && pidc != 0xFF)
+ if (pidc > 16 && pidc != 0xff)
return -EINVAL;
memset(&CmdFrm, 0, sizeof(AVCCmdFrm));
@@ -637,9 +456,9 @@ int AVCTuner_SetPIDs(struct firesat *firesat, unsigned char pidc, u16 pid[])
CmdFrm.operand[4] = 0x00; // system_specific_multiplex selection_length
CmdFrm.operand[5] = pidc; // Nr_of_dsd_sel_specs
- pos=6;
- if(pidc != 0xFF) {
- for(k=0;k<pidc;k++) {
+ pos = 6;
+ if (pidc != 0xff)
+ for (k = 0; k < pidc; k++) {
CmdFrm.operand[pos++] = 0x13; // flowfunction relay
CmdFrm.operand[pos++] = 0x80; // dsd_sel_spec_valid_flags -> PID
CmdFrm.operand[pos++] = (pid[k] >> 8) & 0x1F;
@@ -647,25 +466,20 @@ int AVCTuner_SetPIDs(struct firesat *firesat, unsigned char pidc, u16 pid[])
CmdFrm.operand[pos++] = 0x00; // tableID
CmdFrm.operand[pos++] = 0x00; // filter_length
}
- }
- CmdFrm.length = pos+3;
- if((pos+3)%4)
- CmdFrm.length += 4 - ((pos+3)%4);
+ CmdFrm.length = ALIGN(3 + pos, 4);
- if((k=AVCWrite(firesat,&CmdFrm,&RspFrm)))
- return k;
+ if (avc_write(firesat, &CmdFrm, &RspFrm) < 0)
+ return -EIO;
- mdelay(50);
+ msleep(50);
return 0;
}
-int AVCTuner_GetTS(struct firesat *firesat){
+int avc_tuner_get_ts(struct firesat *firesat)
+{
AVCCmdFrm CmdFrm;
AVCRspFrm RspFrm;
- int k;
-
- //printk(KERN_INFO "%s\n", __func__);
memset(&CmdFrm, 0, sizeof(AVCCmdFrm));
@@ -688,14 +502,14 @@ int AVCTuner_GetTS(struct firesat *firesat){
CmdFrm.length = (firesat->type == FireSAT_DVB_T)?24:28;
- if ((k=AVCWrite(firesat, &CmdFrm, &RspFrm)))
- return k;
+ if (avc_write(firesat, &CmdFrm, &RspFrm) < 0)
+ return -EIO;
- mdelay(250);
+ msleep(250);
return 0;
}
-int AVCIdentifySubunit(struct firesat *firesat)
+int avc_identify_subunit(struct firesat *firesat)
{
AVCCmdFrm CmdFrm;
AVCRspFrm RspFrm;
@@ -718,22 +532,21 @@ int AVCIdentifySubunit(struct firesat *firesat)
CmdFrm.length=12;
- if(AVCWrite(firesat,&CmdFrm,&RspFrm)<0)
+ if (avc_write(firesat, &CmdFrm, &RspFrm) < 0)
return -EIO;
- if(RspFrm.resp != STABLE && RspFrm.resp != ACCEPTED) {
- printk(KERN_ERR "%s: AVCWrite returned error code %d\n",
- __func__, RspFrm.resp);
- return -EINVAL;
- }
- if(((RspFrm.operand[3] << 8) + RspFrm.operand[4]) != 8) {
- printk(KERN_ERR "%s: Invalid response length\n", __func__);
+ if ((RspFrm.resp != STABLE && RspFrm.resp != ACCEPTED) ||
+ (RspFrm.operand[3] << 8) + RspFrm.operand[4] != 8) {
+ dev_err(&firesat->ud->device,
+ "cannot read subunit identifier\n");
return -EINVAL;
}
return 0;
}
-int AVCTunerStatus(struct firesat *firesat, ANTENNA_INPUT_INFO *antenna_input_info) {
+int avc_tuner_status(struct firesat *firesat,
+ ANTENNA_INPUT_INFO *antenna_input_info)
+{
AVCCmdFrm CmdFrm;
AVCRspFrm RspFrm;
int length;
@@ -754,37 +567,32 @@ int AVCTunerStatus(struct firesat *firesat, ANTENNA_INPUT_INFO *antenna_input_in
CmdFrm.operand[5]=0x00;
CmdFrm.operand[6]=0x00;
CmdFrm.length=12;
- if (AVCWrite(firesat,&CmdFrm,&RspFrm) < 0)
+
+ if (avc_write(firesat, &CmdFrm, &RspFrm) < 0)
return -EIO;
- if(RspFrm.resp != STABLE && RspFrm.resp != ACCEPTED) {
- printk(KERN_ERR "%s: AVCWrite returned code %d\n",
- __func__, RspFrm.resp);
+ if (RspFrm.resp != STABLE && RspFrm.resp != ACCEPTED) {
+ dev_err(&firesat->ud->device, "cannot read tuner status\n");
return -EINVAL;
}
length = RspFrm.operand[9];
- if(RspFrm.operand[1] == 0x10 && length == sizeof(ANTENNA_INPUT_INFO))
- {
- memcpy(antenna_input_info, &RspFrm.operand[10],
- sizeof(ANTENNA_INPUT_INFO));
- return 0;
+ if (RspFrm.operand[1] != 0x10 || length != sizeof(ANTENNA_INPUT_INFO)) {
+ dev_err(&firesat->ud->device, "got invalid tuner status\n");
+ return -EINVAL;
}
- printk(KERN_ERR "%s: invalid tuner status (op=%d,length=%d) returned "
- "from AVC\n", __func__, RspFrm.operand[1], length);
- return -EINVAL;
+
+ memcpy(antenna_input_info, &RspFrm.operand[10], length);
+ return 0;
}
-int AVCLNBControl(struct firesat *firesat, char voltage, char burst,
- char conttone, char nrdiseq,
- struct dvb_diseqc_master_cmd *diseqcmd)
+int avc_lnb_control(struct firesat *firesat, char voltage, char burst,
+ char conttone, char nrdiseq,
+ struct dvb_diseqc_master_cmd *diseqcmd)
{
AVCCmdFrm CmdFrm;
AVCRspFrm RspFrm;
- int i,j;
-
- printk(KERN_INFO "%s: voltage = %x, burst = %x, conttone = %x\n",
- __func__, voltage, burst, conttone);
+ int i, j, k;
memset(&CmdFrm, 0, sizeof(AVCCmdFrm));
@@ -804,85 +612,33 @@ int AVCLNBControl(struct firesat *firesat, char voltage, char burst,
i=6;
- for(j=0;j<nrdiseq;j++) {
- int k;
- printk(KERN_INFO "%s: diseq %d len %x\n",
- __func__, j, diseqcmd[j].msg_len);
- CmdFrm.operand[i++]=diseqcmd[j].msg_len;
+ for (j = 0; j < nrdiseq; j++) {
+ CmdFrm.operand[i++] = diseqcmd[j].msg_len;
- for(k=0;k<diseqcmd[j].msg_len;k++) {
- printk(KERN_INFO "%s: diseq %d msg[%d] = %x\n",
- __func__, j, k, diseqcmd[j].msg[k]);
- CmdFrm.operand[i++]=diseqcmd[j].msg[k];
- }
+ for (k = 0; k < diseqcmd[j].msg_len; k++)
+ CmdFrm.operand[i++] = diseqcmd[j].msg[k];
}
CmdFrm.operand[i++]=burst;
CmdFrm.operand[i++]=conttone;
- CmdFrm.length=i+3;
- if((i+3)%4)
- CmdFrm.length += 4 - ((i+3)%4);
+ CmdFrm.length = ALIGN(3 + i, 4);
-/* for(j=0;j<CmdFrm.length;j++)
- printk(KERN_INFO "%s: CmdFrm.operand[%d]=0x%x\n",__func__,j,CmdFrm.operand[j]);
-
- printk(KERN_INFO "%s: cmdfrm.length = %u\n",__func__,CmdFrm.length);
- */
- if(AVCWrite(firesat,&CmdFrm,&RspFrm) < 0)
+ if (avc_write(firesat, &CmdFrm, &RspFrm) < 0)
return -EIO;
- if(RspFrm.resp != ACCEPTED) {
- printk(KERN_ERR "%s: AVCWrite returned code %d\n",
- __func__, RspFrm.resp);
- return -EINVAL;
- }
-
- return 0;
-}
-
-int AVCSubUnitInfo(struct firesat *firesat, char *subunitcount)
-{
- AVCCmdFrm CmdFrm;
- AVCRspFrm RspFrm;
-
- memset(&CmdFrm, 0, sizeof(AVCCmdFrm));
-
- CmdFrm.cts = AVC;
- CmdFrm.ctype = STATUS;
- CmdFrm.sutyp = 0x1f;
- CmdFrm.suid = 0x7;
- CmdFrm.opcode = SUBUNIT_Info;
-
- CmdFrm.operand[0] = 0x07;
- CmdFrm.operand[1] = 0xff;
- CmdFrm.operand[2] = 0xff;
- CmdFrm.operand[3] = 0xff;
- CmdFrm.operand[4] = 0xff;
-
- CmdFrm.length = 8;
-
- if(AVCWrite(firesat,&CmdFrm,&RspFrm) < 0)
- return -EIO;
-
- if(RspFrm.resp != STABLE) {
- printk(KERN_ERR "%s: AVCWrite returned code %d\n",
- __func__, RspFrm.resp);
+ if (RspFrm.resp != ACCEPTED) {
+ dev_err(&firesat->ud->device, "LNB control failed\n");
return -EINVAL;
}
- if(subunitcount)
- *subunitcount = (RspFrm.operand[1] & 0x7) + 1;
-
return 0;
}
-int AVCRegisterRemoteControl(struct firesat *firesat)
+int avc_register_remote_control(struct firesat *firesat)
{
AVCCmdFrm CmdFrm;
-// printk(KERN_INFO "%s\n",__func__);
-
memset(&CmdFrm, 0, sizeof(AVCCmdFrm));
CmdFrm.cts = AVC;
@@ -898,7 +654,7 @@ int AVCRegisterRemoteControl(struct firesat *firesat)
CmdFrm.length = 8;
- return AVCWrite(firesat, &CmdFrm, NULL);
+ return avc_write(firesat, &CmdFrm, NULL);
}
void avc_remote_ctrl_work(struct work_struct *work)
@@ -907,12 +663,12 @@ void avc_remote_ctrl_work(struct work_struct *work)
container_of(work, struct firesat, remote_ctrl_work);
/* Should it be rescheduled in failure cases? */
- AVCRegisterRemoteControl(firesat);
+ avc_register_remote_control(firesat);
}
-int AVCTuner_Host2Ca(struct firesat *firesat)
+#if 0 /* FIXME: unused */
+int avc_tuner_host2ca(struct firesat *firesat)
{
-
AVCCmdFrm CmdFrm;
AVCRspFrm RspFrm;
@@ -933,37 +689,39 @@ int AVCTuner_Host2Ca(struct firesat *firesat)
CmdFrm.operand[7] = 0; // length
CmdFrm.length = 12;
- if(AVCWrite(firesat,&CmdFrm,&RspFrm) < 0)
+ if (avc_write(firesat, &CmdFrm, &RspFrm) < 0)
return -EIO;
return 0;
}
+#endif
static int get_ca_object_pos(AVCRspFrm *RspFrm)
{
int length = 1;
- // Check length of length field
+ /* Check length of length field */
if (RspFrm->operand[7] & 0x80)
- length = (RspFrm->operand[7] & 0x7F) + 1;
+ length = (RspFrm->operand[7] & 0x7f) + 1;
return length + 7;
}
static int get_ca_object_length(AVCRspFrm *RspFrm)
{
+#if 0 /* FIXME: unused */
int size = 0;
int i;
- if (RspFrm->operand[7] & 0x80) {
- for (i = 0; i < (RspFrm->operand[7] & 0x7F); i++) {
+ if (RspFrm->operand[7] & 0x80)
+ for (i = 0; i < (RspFrm->operand[7] & 0x7f); i++) {
size <<= 8;
size += RspFrm->operand[8 + i];
}
- }
+#endif
return RspFrm->operand[7];
}
-int avc_ca_app_info(struct firesat *firesat, char *app_info, int *length)
+int avc_ca_app_info(struct firesat *firesat, char *app_info, unsigned int *len)
{
AVCCmdFrm CmdFrm;
AVCRspFrm RspFrm;
@@ -984,9 +742,10 @@ int avc_ca_app_info(struct firesat *firesat, char *app_info, int *length)
CmdFrm.operand[5] = SFE_VENDOR_TAG_CA_APPLICATION_INFO; // ca tag
CmdFrm.length = 12;
- if(AVCWrite(firesat,&CmdFrm,&RspFrm) < 0)
+ if (avc_write(firesat, &CmdFrm, &RspFrm) < 0)
return -EIO;
+ /* FIXME: check response code and validate response data */
pos = get_ca_object_pos(&RspFrm);
app_info[0] = (TAG_APP_INFO >> 16) & 0xFF;
@@ -995,16 +754,16 @@ int avc_ca_app_info(struct firesat *firesat, char *app_info, int *length)
app_info[3] = 6 + RspFrm.operand[pos + 4];
app_info[4] = 0x01;
memcpy(&app_info[5], &RspFrm.operand[pos], 5 + RspFrm.operand[pos + 4]);
- *length = app_info[3] + 4;
+ *len = app_info[3] + 4;
return 0;
}
-int avc_ca_info(struct firesat *firesat, char *app_info, int *length)
+int avc_ca_info(struct firesat *firesat, char *app_info, unsigned int *len)
{
AVCCmdFrm CmdFrm;
AVCRspFrm RspFrm;
- int pos;
+ /* int pos; FIXME: unused */
memset(&CmdFrm, 0, sizeof(AVCCmdFrm));
CmdFrm.cts = AVC;
@@ -1021,17 +780,17 @@ int avc_ca_info(struct firesat *firesat, char *app_info, int *length)
CmdFrm.operand[5] = SFE_VENDOR_TAG_CA_APPLICATION_INFO; // ca tag
CmdFrm.length = 12;
- if(AVCWrite(firesat,&CmdFrm,&RspFrm) < 0)
+ if (avc_write(firesat, &CmdFrm, &RspFrm) < 0)
return -EIO;
- pos = get_ca_object_pos(&RspFrm);
+ /* pos = get_ca_object_pos(&RspFrm); FIXME: unused */
app_info[0] = (TAG_CA_INFO >> 16) & 0xFF;
app_info[1] = (TAG_CA_INFO >> 8) & 0xFF;
app_info[2] = (TAG_CA_INFO >> 0) & 0xFF;
app_info[3] = 2;
app_info[4] = app_info[5];
app_info[5] = app_info[6];
- *length = app_info[3] + 4;
+ *len = app_info[3] + 4;
return 0;
}
@@ -1059,7 +818,7 @@ int avc_ca_reset(struct firesat *firesat)
CmdFrm.operand[8] = 0; // force hardware reset
CmdFrm.length = 12;
- if(AVCWrite(firesat,&CmdFrm,&RspFrm) < 0)
+ if (avc_write(firesat, &CmdFrm, &RspFrm) < 0)
return -EIO;
return 0;
@@ -1085,9 +844,8 @@ int avc_ca_pmt(struct firesat *firesat, char *msg, int length)
CmdFrm.opcode = VENDOR;
if (msg[0] != LIST_MANAGEMENT_ONLY) {
- printk(KERN_INFO "%s: list_management %d not support. "
- "Forcing list_management to \"only\" (3). \n",
- __func__, msg[0]);
+ dev_info(&firesat->ud->device,
+ "forcing list_management to ONLY\n");
msg[0] = LIST_MANAGEMENT_ONLY;
}
// We take the cmd_id from the programme level only!
@@ -1134,20 +892,17 @@ int avc_ca_pmt(struct firesat *firesat, char *msg, int length)
read_pos = 6;
write_pos = 22;
if (program_info_length > 0) {
-/* printk(KERN_INFO "Copying descriptors at programme level.\n"); */
pmt_cmd_id = msg[read_pos++];
- if (pmt_cmd_id != 1 && pmt_cmd_id !=4) {
- printk(KERN_ERR "Invalid pmt_cmd_id=%d.\n",
- pmt_cmd_id);
- }
+ if (pmt_cmd_id != 1 && pmt_cmd_id != 4)
+ dev_err(&firesat->ud->device,
+ "invalid pmt_cmd_id %d\n", pmt_cmd_id);
+
memcpy(&CmdFrm.operand[write_pos], &msg[read_pos],
program_info_length);
read_pos += program_info_length;
write_pos += program_info_length;
}
while (read_pos < length) {
-/* printk(KERN_INFO "Copying descriptors at stream level for " */
-/* "stream type %d.\n", msg[read_pos]); */
CmdFrm.operand[write_pos++] = msg[read_pos++];
CmdFrm.operand[write_pos++] = msg[read_pos++];
CmdFrm.operand[write_pos++] = msg[read_pos++];
@@ -1160,10 +915,11 @@ int avc_ca_pmt(struct firesat *firesat, char *msg, int length)
CmdFrm.operand[write_pos++] = es_info_length & 0xFF;
if (es_info_length > 0) {
pmt_cmd_id = msg[read_pos++];
- if (pmt_cmd_id != 1 && pmt_cmd_id !=4) {
- printk(KERN_ERR "Invalid pmt_cmd_id=%d at "
- "stream level.\n", pmt_cmd_id);
- }
+ if (pmt_cmd_id != 1 && pmt_cmd_id != 4)
+ dev_err(&firesat->ud->device,
+ "invalid pmt_cmd_id %d "
+ "at stream level\n", pmt_cmd_id);
+
memcpy(&CmdFrm.operand[write_pos], &msg[read_pos],
es_info_length);
read_pos += es_info_length;
@@ -1187,20 +943,18 @@ int avc_ca_pmt(struct firesat *firesat, char *msg, int length)
CmdFrm.operand[write_pos - 2] = (crc32_csum >> 8) & 0xFF;
CmdFrm.operand[write_pos - 1] = (crc32_csum >> 0) & 0xFF;
- CmdFrm.length = write_pos + 3;
- if ((write_pos + 3) % 4)
- CmdFrm.length += 4 - ((write_pos + 3) % 4);
+ CmdFrm.length = ALIGN(3 + write_pos, 4);
- if(AVCWrite(firesat,&CmdFrm,&RspFrm) < 0)
+ if (avc_write(firesat, &CmdFrm, &RspFrm) < 0)
return -EIO;
if (RspFrm.resp != ACCEPTED) {
- printk(KERN_ERR "Answer to CA PMT was %d\n", RspFrm.resp);
+ dev_err(&firesat->ud->device,
+ "CA PMT failed with response 0x%x\n", RspFrm.resp);
return -EFAULT;
}
return 0;
-
}
int avc_ca_get_time_date(struct firesat *firesat, int *interval)
@@ -1225,9 +979,11 @@ int avc_ca_get_time_date(struct firesat *firesat, int *interval)
CmdFrm.operand[7] = 0; // length
CmdFrm.length = 12;
- if(AVCWrite(firesat,&CmdFrm,&RspFrm) < 0)
+ if (avc_write(firesat, &CmdFrm, &RspFrm) < 0)
return -EIO;
+ /* FIXME: check response code and validate response data */
+
*interval = RspFrm.operand[get_ca_object_pos(&RspFrm)];
return 0;
@@ -1255,13 +1011,13 @@ int avc_ca_enter_menu(struct firesat *firesat)
CmdFrm.operand[7] = 0; // length
CmdFrm.length = 12;
- if(AVCWrite(firesat,&CmdFrm,&RspFrm) < 0)
+ if (avc_write(firesat, &CmdFrm, &RspFrm) < 0)
return -EIO;
return 0;
}
-int avc_ca_get_mmi(struct firesat *firesat, char *mmi_object, int *length)
+int avc_ca_get_mmi(struct firesat *firesat, char *mmi_object, unsigned int *len)
{
AVCCmdFrm CmdFrm;
AVCRspFrm RspFrm;
@@ -1283,11 +1039,13 @@ int avc_ca_get_mmi(struct firesat *firesat, char *mmi_object, int *length)
CmdFrm.operand[7] = 0; // length
CmdFrm.length = 12;
- if(AVCWrite(firesat,&CmdFrm,&RspFrm) < 0)
+ if (avc_write(firesat, &CmdFrm, &RspFrm) < 0)
return -EIO;
- *length = get_ca_object_length(&RspFrm);
- memcpy(mmi_object, &RspFrm.operand[get_ca_object_pos(&RspFrm)], *length);
+ /* FIXME: check response code and validate response data */
+
+ *len = get_ca_object_length(&RspFrm);
+ memcpy(mmi_object, &RspFrm.operand[get_ca_object_pos(&RspFrm)], *len);
return 0;
}