aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/firewire/firedtv-ci.c
diff options
context:
space:
mode:
authorStefan Richter <stefanr@s5r6.in-berlin.de>2009-02-23 08:21:10 -0500
committerStefan Richter <stefanr@s5r6.in-berlin.de>2009-02-24 08:51:29 -0500
commit154907957f9391b1af997b57507b16c018cc4995 (patch)
treef9033e7dc29d5406e871b8102ba0b588d34b50ec /drivers/media/dvb/firewire/firedtv-ci.c
parenta70f81c1c0dac113ac4705e7701e2676e67905cd (diff)
firedtv: massive refactoring
Combination of the following changes: Mon, 23 Feb 2009 14:21:10 +0100 (CET) firedtv: reinstate debug logging option Henrik Kurelid tells me that FCP debug logging (which I removed during cleanups) is still useful when working on driver issues together with end users. So bring it back in an updated form with only 60% of the original code footprint. Logging can be enabled with # echo -1 > /sys/module/firedtv/parameters/debug 1 instead of -1 enables only FCP header logging, 2 instead of -1 enables only hexdumps of the entire FCP frames. 0 switches logging off again. Fri, 20 Feb 2009 20:54:27 +0100 (CET) firedtv: build fix for INPUT=m and DVB_FIREDTV=y Thu, 19 Feb 2009 20:40:39 +0100 firedtv: use msecs_to_jiffies Pointed out by Mauro Carvalho Chehab. Sun Feb 15 20:50:46 CET 2009 firedtv: some more housekeeping Fix an old checkpatch warning and a new compiler warning. Sun Feb 15 15:33:17 CET 2009 firedtv: rename a file once more At the moment, about a third of avc.c is specific to FireDTVs rather than generic AV/C code. Rename it to firedtv-avc.c. Sun Feb 15 15:33:17 CET 2009 firedtv: dvb demux: more compact channels backing store Replace struct firedtv_channel { bool active; int pid; } channel[16]; by unsigned long channel_active; u16 channel_pid[16];. Sun Feb 15 15:33:17 CET 2009 firedtv: dvb demux: some simplifications c->active was unnecessarily cleared twice. Also, by marking the channel inactive before the for loop, the loop becomes identical with fdtv_channel_collect(). Sun Feb 15 15:33:17 CET 2009 firedtv: dvb demux: remove a bogus loop This loop is unnecessary because - only active channel[].pid's will be sent to the device, - when a channel is activated, its pid is set to dvbdmxfeed->pid. Perhaps the original code was there because it was initially not fully covered by the fdtv->demux_mutex. Sun Feb 15 15:33:17 CET 2009 firedtv: dvb demux: fix mutex protection fdtv_start_feed() accessed the channel list unsafely. Fully serialize it with itself and fdtv_stop_feed(). Sun Feb 15 15:33:17 CET 2009 firedtv: dvb demux: fix missing braces Original code was: ... case DMX_TS_PES_OTHER: //Dirty fix to keep firesat->channel pid-list up to date for(k=0;k<16;k++){ if(firesat->channel[k].active == 0) firesat->channel[k].pid = dvbdmxfeed->pid; break; } channel = firesat_channel_allocate(firesat); break; default: ... Looks bogus in several respects. For now let's just add braces to the if because that seems to be what the author meant. Sun Feb 15 15:33:17 CET 2009 firedtv: allow build without input subsystem !CONFIG_INPUT is very unlikely on systems on which firedtv is of interest. But we can easily support it. Sun Feb 15 15:33:17 CET 2009 firedtv: replace EXTRA_CFLAGS by ccflags The former are deprecated. The latter can depend on Kconfig variables. Sun Feb 15 15:33:17 CET 2009 firedtv: concentrate ieee1394 dependencies Move the entire interface with drivers/ieee1394 to firedtv-1394.c. Move 1394-independent module initialization code to firedtv-dvb.c. This prepares interfacing with drivers/firewire. Sun Feb 15 15:33:17 CET 2009 firedtv: amend Kconfig menu prompt Sun Feb 15 15:33:17 CET 2009 firedtv: remove kernel version compatibility macro Sun Feb 15 15:33:17 CET 2009 firedtv: combine header files avc.h and firedtv-*.h are small and currently not shared with other drivers, hence concatenate them all into firedtv.h. Sun Feb 15 15:33:17 CET 2009 firedtv: misc style touch-ups Standardize on lower-case hexadecimal constants. Adjust whitespace. Omit unnecessary pointer type casts and an unnecessary list head initialization. Use dev_printk. Wed Feb 11 21:21:04 CET 2009 firedtv: avc, ci: remove unused constants Wed Feb 11 21:21:04 CET 2009 firedtv: avc: remove bitfields from read descriptor response operands Don't use bitfields in struct types of on-the-wire data. Wed Feb 11 21:21:04 CET 2009 firedtv: avc: remove bitfields from DSD command operands Don't use bitfields in struct types of on-the-wire data. Wed Feb 11 21:21:04 CET 2009 firedtv: avc: header file cleanup Remove unused constants and declarations. Move privately used constants into .c files. Wed Feb 11 21:21:04 CET 2009 firedtv: avc: remove bitfields from FCP frame types Don't use bitfields in struct types of on-the-wire data. Also move many privately used constants from avc.h to avc.c and remove some unused constants. Sun, 18 Jan 2009 16:30:00 +0100 (CET) firedtv: avc: fix offset in avc_tuner_get_ts The parentheses were wrong. It didn't matter though because this code only writes a 0 into an area which is already initialized to 0. Sun, 18 Jan 2009 16:30:00 +0100 (CET) firedtv: avc: reduce stack usage, remove two typedefs It is safe to share a memory buffer for command frame and response frame because the response data come in after the command frame was last used. Even less stack would be required if only the actual required frame size instead of the entire FCP register size was allocated. Also, rename the defined types AVCCmdFrm and AVCRspFrm to struct avc_command_frame and struct avc_response_frame. TODO: Remove the bitfields in these types. Sun, 18 Jan 2009 16:30:00 +0100 (CET) firedtv: cmp: move code to avc Sun, 18 Jan 2009 16:30:00 +0100 (CET) firedtv: iso: move code to firedtv-1394 Sun, 18 Jan 2009 16:30:00 +0100 (CET) firedtv: iso: remove unnecessary struct type definitions Sun, 18 Jan 2009 16:30:00 +0100 (CET) firedtv: iso: style changes and fixlets Add cleanup after failure in setup_iso_channel. Replace printk() by dv_err(). Decrease indentation level in rawiso_activity_cb(). Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'drivers/media/dvb/firewire/firedtv-ci.c')
-rw-r--r--drivers/media/dvb/firewire/firedtv-ci.c93
1 files changed, 46 insertions, 47 deletions
diff --git a/drivers/media/dvb/firewire/firedtv-ci.c b/drivers/media/dvb/firewire/firedtv-ci.c
index 6d87926b8bfe..eeb80d0ea3ff 100644
--- a/drivers/media/dvb/firewire/firedtv-ci.c
+++ b/drivers/media/dvb/firewire/firedtv-ci.c
@@ -10,33 +10,37 @@
10 * the License, or (at your option) any later version. 10 * the License, or (at your option) any later version.
11 */ 11 */
12 12
13#include <linux/device.h>
13#include <linux/dvb/ca.h> 14#include <linux/dvb/ca.h>
14#include <linux/fs.h> 15#include <linux/fs.h>
15#include <linux/module.h> 16#include <linux/module.h>
16 17
17#include <dvbdev.h> 18#include <dvbdev.h>
18 19
19#include "avc.h"
20#include "firedtv.h" 20#include "firedtv.h"
21#include "firedtv-ci.h"
22 21
23static int fdtv_ca_ready(ANTENNA_INPUT_INFO *info) 22#define EN50221_TAG_APP_INFO_ENQUIRY 0x9f8020
23#define EN50221_TAG_CA_INFO_ENQUIRY 0x9f8030
24#define EN50221_TAG_CA_PMT 0x9f8032
25#define EN50221_TAG_ENTER_MENU 0x9f8022
26
27static int fdtv_ca_ready(struct firedtv_tuner_status *stat)
24{ 28{
25 return info->CaInitializationStatus == 1 && 29 return stat->ca_initialization_status == 1 &&
26 info->CaErrorFlag == 0 && 30 stat->ca_error_flag == 0 &&
27 info->CaDvbFlag == 1 && 31 stat->ca_dvb_flag == 1 &&
28 info->CaModulePresentStatus == 1; 32 stat->ca_module_present_status == 1;
29} 33}
30 34
31static int fdtv_get_ca_flags(ANTENNA_INPUT_INFO *info) 35static int fdtv_get_ca_flags(struct firedtv_tuner_status *stat)
32{ 36{
33 int flags = 0; 37 int flags = 0;
34 38
35 if (info->CaModulePresentStatus == 1) 39 if (stat->ca_module_present_status == 1)
36 flags |= CA_CI_MODULE_PRESENT; 40 flags |= CA_CI_MODULE_PRESENT;
37 if (info->CaInitializationStatus == 1 && 41 if (stat->ca_initialization_status == 1 &&
38 info->CaErrorFlag == 0 && 42 stat->ca_error_flag == 0 &&
39 info->CaDvbFlag == 1) 43 stat->ca_dvb_flag == 1)
40 flags |= CA_CI_MODULE_READY; 44 flags |= CA_CI_MODULE_READY;
41 return flags; 45 return flags;
42} 46}
@@ -59,17 +63,17 @@ static int fdtv_ca_get_caps(void *arg)
59 63
60static int fdtv_ca_get_slot_info(struct firedtv *fdtv, void *arg) 64static int fdtv_ca_get_slot_info(struct firedtv *fdtv, void *arg)
61{ 65{
62 ANTENNA_INPUT_INFO info; 66 struct firedtv_tuner_status stat;
63 struct ca_slot_info *slot = arg; 67 struct ca_slot_info *slot = arg;
64 68
65 if (avc_tuner_status(fdtv, &info)) 69 if (avc_tuner_status(fdtv, &stat))
66 return -EFAULT; 70 return -EFAULT;
67 71
68 if (slot->num != 0) 72 if (slot->num != 0)
69 return -EFAULT; 73 return -EFAULT;
70 74
71 slot->type = CA_CI; 75 slot->type = CA_CI;
72 slot->flags = fdtv_get_ca_flags(&info); 76 slot->flags = fdtv_get_ca_flags(&stat);
73 return 0; 77 return 0;
74} 78}
75 79
@@ -77,8 +81,7 @@ static int fdtv_ca_app_info(struct firedtv *fdtv, void *arg)
77{ 81{
78 struct ca_msg *reply = arg; 82 struct ca_msg *reply = arg;
79 83
80 return 84 return avc_ca_app_info(fdtv, reply->msg, &reply->length) ? -EFAULT : 0;
81 avc_ca_app_info(fdtv, reply->msg, &reply->length) ? -EFAULT : 0;
82} 85}
83 86
84static int fdtv_ca_info(struct firedtv *fdtv, void *arg) 87static int fdtv_ca_info(struct firedtv *fdtv, void *arg)
@@ -92,30 +95,29 @@ static int fdtv_ca_get_mmi(struct firedtv *fdtv, void *arg)
92{ 95{
93 struct ca_msg *reply = arg; 96 struct ca_msg *reply = arg;
94 97
95 return 98 return avc_ca_get_mmi(fdtv, reply->msg, &reply->length) ? -EFAULT : 0;
96 avc_ca_get_mmi(fdtv, reply->msg, &reply->length) ? -EFAULT : 0;
97} 99}
98 100
99static int fdtv_ca_get_msg(struct firedtv *fdtv, void *arg) 101static int fdtv_ca_get_msg(struct firedtv *fdtv, void *arg)
100{ 102{
101 ANTENNA_INPUT_INFO info; 103 struct firedtv_tuner_status stat;
102 int err; 104 int err;
103 105
104 switch (fdtv->ca_last_command) { 106 switch (fdtv->ca_last_command) {
105 case TAG_APP_INFO_ENQUIRY: 107 case EN50221_TAG_APP_INFO_ENQUIRY:
106 err = fdtv_ca_app_info(fdtv, arg); 108 err = fdtv_ca_app_info(fdtv, arg);
107 break; 109 break;
108 case TAG_CA_INFO_ENQUIRY: 110 case EN50221_TAG_CA_INFO_ENQUIRY:
109 err = fdtv_ca_info(fdtv, arg); 111 err = fdtv_ca_info(fdtv, arg);
110 break; 112 break;
111 default: 113 default:
112 if (avc_tuner_status(fdtv, &info)) 114 if (avc_tuner_status(fdtv, &stat))
113 err = -EFAULT; 115 err = -EFAULT;
114 else if (info.CaMmi == 1) 116 else if (stat.ca_mmi == 1)
115 err = fdtv_ca_get_mmi(fdtv, arg); 117 err = fdtv_ca_get_mmi(fdtv, arg);
116 else { 118 else {
117 printk(KERN_INFO "%s: Unhandled message 0x%08X\n", 119 dev_info(fdtv->device, "unhandled CA message 0x%08x\n",
118 __func__, fdtv->ca_last_command); 120 fdtv->ca_last_command);
119 err = -EFAULT; 121 err = -EFAULT;
120 } 122 }
121 } 123 }
@@ -133,14 +135,13 @@ static int fdtv_ca_pmt(struct firedtv *fdtv, void *arg)
133 data_pos = 4; 135 data_pos = 4;
134 if (msg->msg[3] & 0x80) { 136 if (msg->msg[3] & 0x80) {
135 data_length = 0; 137 data_length = 0;
136 for (i = 0; i < (msg->msg[3] & 0x7F); i++) 138 for (i = 0; i < (msg->msg[3] & 0x7f); i++)
137 data_length = (data_length << 8) + msg->msg[data_pos++]; 139 data_length = (data_length << 8) + msg->msg[data_pos++];
138 } else { 140 } else {
139 data_length = msg->msg[3]; 141 data_length = msg->msg[3];
140 } 142 }
141 143
142 return avc_ca_pmt(fdtv, &msg->msg[data_pos], data_length) ? 144 return avc_ca_pmt(fdtv, &msg->msg[data_pos], data_length) ? -EFAULT : 0;
143 -EFAULT : 0;
144} 145}
145 146
146static int fdtv_ca_send_msg(struct firedtv *fdtv, void *arg) 147static int fdtv_ca_send_msg(struct firedtv *fdtv, void *arg)
@@ -152,23 +153,23 @@ static int fdtv_ca_send_msg(struct firedtv *fdtv, void *arg)
152 fdtv->ca_last_command = 153 fdtv->ca_last_command =
153 (msg->msg[0] << 16) + (msg->msg[1] << 8) + msg->msg[2]; 154 (msg->msg[0] << 16) + (msg->msg[1] << 8) + msg->msg[2];
154 switch (fdtv->ca_last_command) { 155 switch (fdtv->ca_last_command) {
155 case TAG_CA_PMT: 156 case EN50221_TAG_CA_PMT:
156 err = fdtv_ca_pmt(fdtv, arg); 157 err = fdtv_ca_pmt(fdtv, arg);
157 break; 158 break;
158 case TAG_APP_INFO_ENQUIRY: 159 case EN50221_TAG_APP_INFO_ENQUIRY:
159 /* handled in ca_get_msg */ 160 /* handled in ca_get_msg */
160 err = 0; 161 err = 0;
161 break; 162 break;
162 case TAG_CA_INFO_ENQUIRY: 163 case EN50221_TAG_CA_INFO_ENQUIRY:
163 /* handled in ca_get_msg */ 164 /* handled in ca_get_msg */
164 err = 0; 165 err = 0;
165 break; 166 break;
166 case TAG_ENTER_MENU: 167 case EN50221_TAG_ENTER_MENU:
167 err = avc_ca_enter_menu(fdtv); 168 err = avc_ca_enter_menu(fdtv);
168 break; 169 break;
169 default: 170 default:
170 printk(KERN_ERR "%s: Unhandled unknown message 0x%08X\n", 171 dev_err(fdtv->device, "unhandled CA message 0x%08x\n",
171 __func__, fdtv->ca_last_command); 172 fdtv->ca_last_command);
172 err = -EFAULT; 173 err = -EFAULT;
173 } 174 }
174 return err; 175 return err;
@@ -179,10 +180,10 @@ static int fdtv_ca_ioctl(struct inode *inode, struct file *file,
179{ 180{
180 struct dvb_device *dvbdev = file->private_data; 181 struct dvb_device *dvbdev = file->private_data;
181 struct firedtv *fdtv = dvbdev->priv; 182 struct firedtv *fdtv = dvbdev->priv;
182 ANTENNA_INPUT_INFO info; 183 struct firedtv_tuner_status stat;
183 int err; 184 int err;
184 185
185 switch(cmd) { 186 switch (cmd) {
186 case CA_RESET: 187 case CA_RESET:
187 err = fdtv_ca_reset(fdtv); 188 err = fdtv_ca_reset(fdtv);
188 break; 189 break;
@@ -199,13 +200,12 @@ static int fdtv_ca_ioctl(struct inode *inode, struct file *file,
199 err = fdtv_ca_send_msg(fdtv, arg); 200 err = fdtv_ca_send_msg(fdtv, arg);
200 break; 201 break;
201 default: 202 default:
202 printk(KERN_INFO "%s: Unhandled ioctl, command: %u\n",__func__, 203 dev_info(fdtv->device, "unhandled CA ioctl %u\n", cmd);
203 cmd);
204 err = -EOPNOTSUPP; 204 err = -EOPNOTSUPP;
205 } 205 }
206 206
207 /* FIXME Is this necessary? */ 207 /* FIXME Is this necessary? */
208 avc_tuner_status(fdtv, &info); 208 avc_tuner_status(fdtv, &stat);
209 209
210 return err; 210 return err;
211} 211}
@@ -233,22 +233,21 @@ static struct dvb_device fdtv_ca = {
233 233
234int fdtv_ca_register(struct firedtv *fdtv) 234int fdtv_ca_register(struct firedtv *fdtv)
235{ 235{
236 ANTENNA_INPUT_INFO info; 236 struct firedtv_tuner_status stat;
237 int err; 237 int err;
238 238
239 if (avc_tuner_status(fdtv, &info)) 239 if (avc_tuner_status(fdtv, &stat))
240 return -EINVAL; 240 return -EINVAL;
241 241
242 if (!fdtv_ca_ready(&info)) 242 if (!fdtv_ca_ready(&stat))
243 return -EFAULT; 243 return -EFAULT;
244 244
245 err = dvb_register_device(&fdtv->adapter, &fdtv->cadev, 245 err = dvb_register_device(&fdtv->adapter, &fdtv->cadev,
246 &fdtv_ca, fdtv, DVB_DEVICE_CA); 246 &fdtv_ca, fdtv, DVB_DEVICE_CA);
247 247
248 if (info.CaApplicationInfo == 0) 248 if (stat.ca_application_info == 0)
249 printk(KERN_ERR "%s: CaApplicationInfo is not set.\n", 249 dev_err(fdtv->device, "CaApplicationInfo is not set\n");
250 __func__); 250 if (stat.ca_date_time_request == 1)
251 if (info.CaDateTimeRequest == 1)
252 avc_ca_get_time_date(fdtv, &fdtv->ca_time_interval); 251 avc_ca_get_time_date(fdtv, &fdtv->ca_time_interval);
253 252
254 return err; 253 return err;