diff options
Diffstat (limited to 'drivers/media/dvb/dvb-usb/vp702x.c')
-rw-r--r-- | drivers/media/dvb/dvb-usb/vp702x.c | 59 |
1 files changed, 35 insertions, 24 deletions
diff --git a/drivers/media/dvb/dvb-usb/vp702x.c b/drivers/media/dvb/dvb-usb/vp702x.c index c82cb6b3a27d..6dd50bc8418e 100644 --- a/drivers/media/dvb/dvb-usb/vp702x.c +++ b/drivers/media/dvb/dvb-usb/vp702x.c | |||
@@ -140,38 +140,44 @@ static int vp702x_usb_inout_cmd(struct dvb_usb_device *d, u8 cmd, u8 *o, | |||
140 | static int vp702x_set_pld_mode(struct dvb_usb_adapter *adap, u8 bypass) | 140 | static int vp702x_set_pld_mode(struct dvb_usb_adapter *adap, u8 bypass) |
141 | { | 141 | { |
142 | int ret; | 142 | int ret; |
143 | u8 *buf = kzalloc(16, GFP_KERNEL); | 143 | struct vp702x_device_state *st = adap->dev->priv; |
144 | if (!buf) | 144 | u8 *buf; |
145 | return -ENOMEM; | 145 | |
146 | mutex_lock(&st->buf_mutex); | ||
147 | |||
148 | buf = st->buf; | ||
149 | memset(buf, 0, 16); | ||
146 | 150 | ||
147 | ret = vp702x_usb_in_op(adap->dev, 0xe0, (bypass << 8) | 0x0e, | 151 | ret = vp702x_usb_in_op(adap->dev, 0xe0, (bypass << 8) | 0x0e, |
148 | 0, buf, 16); | 152 | 0, buf, 16); |
149 | kfree(buf); | 153 | mutex_unlock(&st->buf_mutex); |
150 | return ret; | 154 | return ret; |
151 | } | 155 | } |
152 | 156 | ||
153 | static int vp702x_set_pld_state(struct dvb_usb_adapter *adap, u8 state) | 157 | static int vp702x_set_pld_state(struct dvb_usb_adapter *adap, u8 state) |
154 | { | 158 | { |
155 | int ret; | 159 | int ret; |
156 | u8 *buf = kzalloc(16, GFP_KERNEL); | 160 | struct vp702x_device_state *st = adap->dev->priv; |
157 | if (!buf) | 161 | u8 *buf; |
158 | return -ENOMEM; | 162 | |
163 | mutex_lock(&st->buf_mutex); | ||
159 | 164 | ||
165 | buf = st->buf; | ||
166 | memset(buf, 0, 16); | ||
160 | ret = vp702x_usb_in_op(adap->dev, 0xe0, (state << 8) | 0x0f, | 167 | ret = vp702x_usb_in_op(adap->dev, 0xe0, (state << 8) | 0x0f, |
161 | 0, buf, 16); | 168 | 0, buf, 16); |
162 | kfree(buf); | 169 | |
170 | mutex_unlock(&st->buf_mutex); | ||
171 | |||
163 | return ret; | 172 | return ret; |
164 | } | 173 | } |
165 | 174 | ||
166 | static int vp702x_set_pid(struct dvb_usb_adapter *adap, u16 pid, u8 id, int onoff) | 175 | static int vp702x_set_pid(struct dvb_usb_adapter *adap, u16 pid, u8 id, int onoff) |
167 | { | 176 | { |
168 | struct vp702x_adapter_state *st = adap->priv; | 177 | struct vp702x_adapter_state *st = adap->priv; |
178 | struct vp702x_device_state *dst = adap->dev->priv; | ||
169 | u8 *buf; | 179 | u8 *buf; |
170 | 180 | ||
171 | buf = kzalloc(16, GFP_KERNEL); | ||
172 | if (!buf) | ||
173 | return -ENOMEM; | ||
174 | |||
175 | if (onoff) | 181 | if (onoff) |
176 | st->pid_filter_state |= (1 << id); | 182 | st->pid_filter_state |= (1 << id); |
177 | else { | 183 | else { |
@@ -182,10 +188,16 @@ static int vp702x_set_pid(struct dvb_usb_adapter *adap, u16 pid, u8 id, int onof | |||
182 | id = 0x10 + id*2; | 188 | id = 0x10 + id*2; |
183 | 189 | ||
184 | vp702x_set_pld_state(adap, st->pid_filter_state); | 190 | vp702x_set_pld_state(adap, st->pid_filter_state); |
191 | |||
192 | mutex_lock(&dst->buf_mutex); | ||
193 | |||
194 | buf = dst->buf; | ||
195 | memset(buf, 0, 16); | ||
185 | vp702x_usb_in_op(adap->dev, 0xe0, (((pid >> 8) & 0xff) << 8) | (id), 0, buf, 16); | 196 | vp702x_usb_in_op(adap->dev, 0xe0, (((pid >> 8) & 0xff) << 8) | (id), 0, buf, 16); |
186 | vp702x_usb_in_op(adap->dev, 0xe0, (((pid ) & 0xff) << 8) | (id+1), 0, buf, 16); | 197 | vp702x_usb_in_op(adap->dev, 0xe0, (((pid ) & 0xff) << 8) | (id+1), 0, buf, 16); |
187 | 198 | ||
188 | kfree(buf); | 199 | mutex_unlock(&dst->buf_mutex); |
200 | |||
189 | return 0; | 201 | return 0; |
190 | } | 202 | } |
191 | 203 | ||
@@ -193,13 +205,10 @@ static int vp702x_set_pid(struct dvb_usb_adapter *adap, u16 pid, u8 id, int onof | |||
193 | static int vp702x_init_pid_filter(struct dvb_usb_adapter *adap) | 205 | static int vp702x_init_pid_filter(struct dvb_usb_adapter *adap) |
194 | { | 206 | { |
195 | struct vp702x_adapter_state *st = adap->priv; | 207 | struct vp702x_adapter_state *st = adap->priv; |
208 | struct vp702x_device_state *dst = adap->dev->priv; | ||
196 | int i; | 209 | int i; |
197 | u8 *b; | 210 | u8 *b; |
198 | 211 | ||
199 | b = kzalloc(10, GFP_KERNEL); | ||
200 | if (!b) | ||
201 | return -ENOMEM; | ||
202 | |||
203 | st->pid_filter_count = 8; | 212 | st->pid_filter_count = 8; |
204 | st->pid_filter_can_bypass = 1; | 213 | st->pid_filter_can_bypass = 1; |
205 | st->pid_filter_state = 0x00; | 214 | st->pid_filter_state = 0x00; |
@@ -209,12 +218,15 @@ static int vp702x_init_pid_filter(struct dvb_usb_adapter *adap) | |||
209 | for (i = 0; i < st->pid_filter_count; i++) | 218 | for (i = 0; i < st->pid_filter_count; i++) |
210 | vp702x_set_pid(adap, 0xffff, i, 1); | 219 | vp702x_set_pid(adap, 0xffff, i, 1); |
211 | 220 | ||
221 | mutex_lock(&dst->buf_mutex); | ||
222 | b = dst->buf; | ||
223 | memset(b, 0, 10); | ||
212 | vp702x_usb_in_op(adap->dev, 0xb5, 3, 0, b, 10); | 224 | vp702x_usb_in_op(adap->dev, 0xb5, 3, 0, b, 10); |
213 | vp702x_usb_in_op(adap->dev, 0xb5, 0, 0, b, 10); | 225 | vp702x_usb_in_op(adap->dev, 0xb5, 0, 0, b, 10); |
214 | vp702x_usb_in_op(adap->dev, 0xb5, 1, 0, b, 10); | 226 | vp702x_usb_in_op(adap->dev, 0xb5, 1, 0, b, 10); |
227 | mutex_unlock(&dst->buf_mutex); | ||
228 | /*vp702x_set_pld_mode(d, 0); // filter */ | ||
215 | 229 | ||
216 | //vp702x_set_pld_mode(d, 0); // filter | ||
217 | kfree(b); | ||
218 | return 0; | 230 | return 0; |
219 | } | 231 | } |
220 | 232 | ||
@@ -266,16 +278,15 @@ static int vp702x_rc_query(struct dvb_usb_device *d, u32 *event, int *state) | |||
266 | static int vp702x_read_mac_addr(struct dvb_usb_device *d,u8 mac[6]) | 278 | static int vp702x_read_mac_addr(struct dvb_usb_device *d,u8 mac[6]) |
267 | { | 279 | { |
268 | u8 i, *buf; | 280 | u8 i, *buf; |
281 | struct vp702x_device_state *st = d->priv; | ||
269 | 282 | ||
270 | buf = kmalloc(6, GFP_KERNEL); | 283 | mutex_lock(&st->buf_mutex); |
271 | if (!buf) | 284 | buf = st->buf; |
272 | return -ENOMEM; | ||
273 | |||
274 | for (i = 6; i < 12; i++) | 285 | for (i = 6; i < 12; i++) |
275 | vp702x_usb_in_op(d, READ_EEPROM_REQ, i, 1, &buf[i - 6], 1); | 286 | vp702x_usb_in_op(d, READ_EEPROM_REQ, i, 1, &buf[i - 6], 1); |
276 | 287 | ||
277 | memcpy(mac, buf, 6); | 288 | memcpy(mac, buf, 6); |
278 | kfree(buf); | 289 | mutex_unlock(&st->buf_mutex); |
279 | return 0; | 290 | return 0; |
280 | } | 291 | } |
281 | 292 | ||