diff options
Diffstat (limited to 'drivers/media/dvb/firewire/firedtv-ci.c')
-rw-r--r-- | drivers/media/dvb/firewire/firedtv-ci.c | 93 |
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 | ||
23 | static 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 | |||
27 | static 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 | ||
31 | static int fdtv_get_ca_flags(ANTENNA_INPUT_INFO *info) | 35 | static 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 | ||
60 | static int fdtv_ca_get_slot_info(struct firedtv *fdtv, void *arg) | 64 | static 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 | ||
84 | static int fdtv_ca_info(struct firedtv *fdtv, void *arg) | 87 | static 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 | ||
99 | static int fdtv_ca_get_msg(struct firedtv *fdtv, void *arg) | 101 | static 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 | ||
146 | static int fdtv_ca_send_msg(struct firedtv *fdtv, void *arg) | 147 | static 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 | ||
234 | int fdtv_ca_register(struct firedtv *fdtv) | 234 | int 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; |