diff options
Diffstat (limited to 'drivers/media/dvb')
-rw-r--r-- | drivers/media/dvb/dvb-usb/dvb-usb-common.h | 3 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/dvb-usb-urb.c | 178 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/dvb-usb.h | 24 |
3 files changed, 167 insertions, 38 deletions
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-common.h b/drivers/media/dvb/dvb-usb/dvb-usb-common.h index 67e0d73fbceb..abf7d2f562b8 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-common.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb-common.h | |||
@@ -15,11 +15,12 @@ extern int dvb_usb_debug; | |||
15 | 15 | ||
16 | #define deb_info(args...) dprintk(dvb_usb_debug,0x01,args) | 16 | #define deb_info(args...) dprintk(dvb_usb_debug,0x01,args) |
17 | #define deb_xfer(args...) dprintk(dvb_usb_debug,0x02,args) | 17 | #define deb_xfer(args...) dprintk(dvb_usb_debug,0x02,args) |
18 | #define deb_pll(args...) dprintk(dvb_usb_debug,0x04,args) | 18 | #define deb_pll(args...) dprintk(dvb_usb_debug,0x04,args) |
19 | #define deb_ts(args...) dprintk(dvb_usb_debug,0x08,args) | 19 | #define deb_ts(args...) dprintk(dvb_usb_debug,0x08,args) |
20 | #define deb_err(args...) dprintk(dvb_usb_debug,0x10,args) | 20 | #define deb_err(args...) dprintk(dvb_usb_debug,0x10,args) |
21 | #define deb_rc(args...) dprintk(dvb_usb_debug,0x20,args) | 21 | #define deb_rc(args...) dprintk(dvb_usb_debug,0x20,args) |
22 | #define deb_fw(args...) dprintk(dvb_usb_debug,0x40,args) | 22 | #define deb_fw(args...) dprintk(dvb_usb_debug,0x40,args) |
23 | #define deb_mem(args...) dprintk(dvb_usb_debug,0x80,args) | ||
23 | 24 | ||
24 | /* commonly used methods */ | 25 | /* commonly used methods */ |
25 | extern int usb_cypress_load_firmware(struct usb_device *, const char *, int); | 26 | extern int usb_cypress_load_firmware(struct usb_device *, const char *, int); |
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-urb.c b/drivers/media/dvb/dvb-usb/dvb-usb-urb.c index 83d476fb410a..dcd8c2f915f8 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-urb.c +++ b/drivers/media/dvb/dvb-usb/dvb-usb-urb.c | |||
@@ -24,6 +24,7 @@ int dvb_usb_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf, | |||
24 | if ((ret = down_interruptible(&d->usb_sem))) | 24 | if ((ret = down_interruptible(&d->usb_sem))) |
25 | return ret; | 25 | return ret; |
26 | 26 | ||
27 | deb_xfer(">>> "); | ||
27 | debug_dump(wbuf,wlen,deb_xfer); | 28 | debug_dump(wbuf,wlen,deb_xfer); |
28 | 29 | ||
29 | ret = usb_bulk_msg(d->udev,usb_sndbulkpipe(d->udev, | 30 | ret = usb_bulk_msg(d->udev,usb_sndbulkpipe(d->udev, |
@@ -46,8 +47,10 @@ int dvb_usb_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf, | |||
46 | 47 | ||
47 | if (ret) | 48 | if (ret) |
48 | err("recv bulk message failed: %d",ret); | 49 | err("recv bulk message failed: %d",ret); |
49 | else | 50 | else { |
51 | deb_xfer("<<< "); | ||
50 | debug_dump(rbuf,actlen,deb_xfer); | 52 | debug_dump(rbuf,actlen,deb_xfer); |
53 | } | ||
51 | } | 54 | } |
52 | 55 | ||
53 | up(&d->usb_sem); | 56 | up(&d->usb_sem); |
@@ -61,12 +64,19 @@ int dvb_usb_generic_write(struct dvb_usb_device *d, u8 *buf, u16 len) | |||
61 | } | 64 | } |
62 | EXPORT_SYMBOL(dvb_usb_generic_write); | 65 | EXPORT_SYMBOL(dvb_usb_generic_write); |
63 | 66 | ||
64 | static void dvb_usb_bulk_urb_complete(struct urb *urb, struct pt_regs *ptregs) | 67 | |
68 | /* URB stuff for streaming */ | ||
69 | static void dvb_usb_urb_complete(struct urb *urb, struct pt_regs *ptregs) | ||
65 | { | 70 | { |
66 | struct dvb_usb_device *d = urb->context; | 71 | struct dvb_usb_device *d = urb->context; |
72 | int ptype = usb_pipetype(urb->pipe); | ||
73 | int i; | ||
74 | u8 *b; | ||
67 | 75 | ||
68 | deb_ts("bulk urb completed. feedcount: %d, status: %d, length: %d\n",d->feedcount,urb->status, | 76 | deb_ts("'%s' urb completed. feedcount: %d, status: %d, length: %d/%d, pack_num: %d, errors: %d\n", |
69 | urb->actual_length); | 77 | ptype == PIPE_ISOCHRONOUS ? "isoc" : "bulk", d->feedcount, |
78 | urb->status,urb->actual_length,urb->transfer_buffer_length, | ||
79 | urb->number_of_packets,urb->error_count); | ||
70 | 80 | ||
71 | switch (urb->status) { | 81 | switch (urb->status) { |
72 | case 0: /* success */ | 82 | case 0: /* success */ |
@@ -81,11 +91,33 @@ static void dvb_usb_bulk_urb_complete(struct urb *urb, struct pt_regs *ptregs) | |||
81 | break; | 91 | break; |
82 | } | 92 | } |
83 | 93 | ||
84 | if (d->feedcount > 0 && urb->actual_length > 0) { | 94 | if (d->feedcount > 0) { |
85 | if (d->state & DVB_USB_STATE_DVB) | 95 | if (d->state & DVB_USB_STATE_DVB) { |
86 | dvb_dmx_swfilter(&d->demux, (u8*) urb->transfer_buffer,urb->actual_length); | 96 | switch (ptype) { |
87 | } else | 97 | case PIPE_ISOCHRONOUS: |
88 | deb_ts("URB dropped because of feedcount.\n"); | 98 | b = (u8 *) urb->transfer_buffer; |
99 | for (i = 0; i < urb->number_of_packets; i++) { | ||
100 | if (urb->iso_frame_desc[i].status != 0) | ||
101 | deb_ts("iso frame descriptor has an error: %d\n",urb->iso_frame_desc[i].status); | ||
102 | else if (urb->iso_frame_desc[i].actual_length > 0) { | ||
103 | dvb_dmx_swfilter(&d->demux,b + urb->iso_frame_desc[i].offset, | ||
104 | urb->iso_frame_desc[i].actual_length); | ||
105 | } | ||
106 | urb->iso_frame_desc[i].status = 0; | ||
107 | urb->iso_frame_desc[i].actual_length = 0; | ||
108 | } | ||
109 | debug_dump(b,20,deb_ts); | ||
110 | break; | ||
111 | case PIPE_BULK: | ||
112 | if (urb->actual_length > 0) | ||
113 | dvb_dmx_swfilter(&d->demux, (u8 *) urb->transfer_buffer,urb->actual_length); | ||
114 | break; | ||
115 | default: | ||
116 | err("unkown endpoint type in completition handler."); | ||
117 | return; | ||
118 | } | ||
119 | } | ||
120 | } | ||
89 | 121 | ||
90 | usb_submit_urb(urb,GFP_ATOMIC); | 122 | usb_submit_urb(urb,GFP_ATOMIC); |
91 | } | 123 | } |
@@ -94,7 +126,7 @@ int dvb_usb_urb_kill(struct dvb_usb_device *d) | |||
94 | { | 126 | { |
95 | int i; | 127 | int i; |
96 | for (i = 0; i < d->urbs_submitted; i++) { | 128 | for (i = 0; i < d->urbs_submitted; i++) { |
97 | deb_info("killing URB no. %d.\n",i); | 129 | deb_ts("killing URB no. %d.\n",i); |
98 | 130 | ||
99 | /* stop the URB */ | 131 | /* stop the URB */ |
100 | usb_kill_urb(d->urb_list[i]); | 132 | usb_kill_urb(d->urb_list[i]); |
@@ -107,9 +139,9 @@ int dvb_usb_urb_submit(struct dvb_usb_device *d) | |||
107 | { | 139 | { |
108 | int i,ret; | 140 | int i,ret; |
109 | for (i = 0; i < d->urbs_initialized; i++) { | 141 | for (i = 0; i < d->urbs_initialized; i++) { |
110 | deb_info("submitting URB no. %d\n",i); | 142 | deb_ts("submitting URB no. %d\n",i); |
111 | if ((ret = usb_submit_urb(d->urb_list[i],GFP_ATOMIC))) { | 143 | if ((ret = usb_submit_urb(d->urb_list[i],GFP_ATOMIC))) { |
112 | err("could not submit URB no. %d - get them all back\n",i); | 144 | err("could not submit URB no. %d - get them all back",i); |
113 | dvb_usb_urb_kill(d); | 145 | dvb_usb_urb_kill(d); |
114 | return ret; | 146 | return ret; |
115 | } | 147 | } |
@@ -118,32 +150,78 @@ int dvb_usb_urb_submit(struct dvb_usb_device *d) | |||
118 | return 0; | 150 | return 0; |
119 | } | 151 | } |
120 | 152 | ||
121 | static int dvb_usb_bulk_urb_init(struct dvb_usb_device *d) | 153 | static int dvb_usb_free_stream_buffers(struct dvb_usb_device *d) |
122 | { | 154 | { |
123 | int i,bufsize = d->props.urb.count * d->props.urb.u.bulk.buffersize; | 155 | if (d->state & DVB_USB_STATE_URB_BUF) { |
156 | while (d->buf_num) { | ||
157 | d->buf_num--; | ||
158 | deb_mem("freeing buffer %d\n",d->buf_num); | ||
159 | usb_buffer_free(d->udev, d->buf_size, | ||
160 | d->buf_list[d->buf_num], d->dma_addr[d->buf_num]); | ||
161 | } | ||
162 | kfree(d->buf_list); | ||
163 | kfree(d->dma_addr); | ||
164 | } | ||
165 | |||
166 | d->state &= ~DVB_USB_STATE_URB_BUF; | ||
124 | 167 | ||
125 | deb_info("allocate %d bytes as buffersize for all URBs\n",bufsize); | 168 | return 0; |
126 | /* allocate the actual buffer for the URBs */ | 169 | } |
127 | if ((d->buffer = usb_buffer_alloc(d->udev, bufsize, SLAB_ATOMIC, &d->dma_handle)) == NULL) { | 170 | |
128 | deb_info("not enough memory for urb-buffer allocation.\n"); | 171 | static int dvb_usb_allocate_stream_buffers(struct dvb_usb_device *d, int num, unsigned long size) |
172 | { | ||
173 | d->buf_num = 0; | ||
174 | d->buf_size = size; | ||
175 | |||
176 | deb_mem("all in all I will use %lu bytes for streaming\n",num*size); | ||
177 | |||
178 | if ((d->buf_list = kmalloc(num*sizeof(u8 *), GFP_ATOMIC)) == NULL) | ||
179 | return -ENOMEM; | ||
180 | |||
181 | if ((d->dma_addr = kmalloc(num*sizeof(dma_addr_t), GFP_ATOMIC)) == NULL) { | ||
182 | kfree(d->buf_list); | ||
129 | return -ENOMEM; | 183 | return -ENOMEM; |
130 | } | 184 | } |
131 | deb_info("allocation successful\n"); | 185 | memset(d->buf_list,0,num*sizeof(u8 *)); |
132 | memset(d->buffer,0,bufsize); | 186 | memset(d->dma_addr,0,num*sizeof(dma_addr_t)); |
133 | 187 | ||
134 | d->state |= DVB_USB_STATE_URB_BUF; | 188 | d->state |= DVB_USB_STATE_URB_BUF; |
135 | 189 | ||
190 | for (d->buf_num = 0; d->buf_num < num; d->buf_num++) { | ||
191 | deb_mem("allocating buffer %d\n",d->buf_num); | ||
192 | if (( d->buf_list[d->buf_num] = | ||
193 | usb_buffer_alloc(d->udev, size, SLAB_ATOMIC, | ||
194 | &d->dma_addr[d->buf_num]) ) == NULL) { | ||
195 | deb_mem("not enough memory for urb-buffer allocation.\n"); | ||
196 | dvb_usb_free_stream_buffers(d); | ||
197 | return -ENOMEM; | ||
198 | } | ||
199 | deb_mem("buffer %d: %p (dma: %d)\n",d->buf_num,d->buf_list[d->buf_num],d->dma_addr[d->buf_num]); | ||
200 | memset(d->buf_list[d->buf_num],0,size); | ||
201 | } | ||
202 | deb_mem("allocation successful\n"); | ||
203 | |||
204 | return 0; | ||
205 | } | ||
206 | |||
207 | static int dvb_usb_bulk_urb_init(struct dvb_usb_device *d) | ||
208 | { | ||
209 | int i; | ||
210 | |||
211 | if ((i = dvb_usb_allocate_stream_buffers(d,d->props.urb.count, | ||
212 | d->props.urb.u.bulk.buffersize)) < 0) | ||
213 | return i; | ||
214 | |||
136 | /* allocate the URBs */ | 215 | /* allocate the URBs */ |
137 | for (i = 0; i < d->props.urb.count; i++) { | 216 | for (i = 0; i < d->props.urb.count; i++) { |
138 | if (!(d->urb_list[i] = usb_alloc_urb(0,GFP_ATOMIC))) { | 217 | if ((d->urb_list[i] = usb_alloc_urb(0,GFP_ATOMIC)) == NULL) |
139 | return -ENOMEM; | 218 | return -ENOMEM; |
140 | } | ||
141 | 219 | ||
142 | usb_fill_bulk_urb( d->urb_list[i], d->udev, | 220 | usb_fill_bulk_urb( d->urb_list[i], d->udev, |
143 | usb_rcvbulkpipe(d->udev,d->props.urb.endpoint), | 221 | usb_rcvbulkpipe(d->udev,d->props.urb.endpoint), |
144 | &d->buffer[i*d->props.urb.u.bulk.buffersize], | 222 | d->buf_list[i], |
145 | d->props.urb.u.bulk.buffersize, | 223 | d->props.urb.u.bulk.buffersize, |
146 | dvb_usb_bulk_urb_complete, d); | 224 | dvb_usb_urb_complete, d); |
147 | 225 | ||
148 | d->urb_list[i]->transfer_flags = 0; | 226 | d->urb_list[i]->transfer_flags = 0; |
149 | d->urbs_initialized++; | 227 | d->urbs_initialized++; |
@@ -151,6 +229,47 @@ static int dvb_usb_bulk_urb_init(struct dvb_usb_device *d) | |||
151 | return 0; | 229 | return 0; |
152 | } | 230 | } |
153 | 231 | ||
232 | static int dvb_usb_isoc_urb_init(struct dvb_usb_device *d) | ||
233 | { | ||
234 | int i,j; | ||
235 | |||
236 | if ((i = dvb_usb_allocate_stream_buffers(d,d->props.urb.count, | ||
237 | d->props.urb.u.isoc.framesize*d->props.urb.u.isoc.framesperurb)) < 0) | ||
238 | return i; | ||
239 | |||
240 | /* allocate the URBs */ | ||
241 | for (i = 0; i < d->props.urb.count; i++) { | ||
242 | struct urb *urb; | ||
243 | int frame_offset = 0; | ||
244 | if ((d->urb_list[i] = | ||
245 | usb_alloc_urb(d->props.urb.u.isoc.framesperurb,GFP_ATOMIC)) == NULL) | ||
246 | return -ENOMEM; | ||
247 | |||
248 | urb = d->urb_list[i]; | ||
249 | |||
250 | urb->dev = d->udev; | ||
251 | urb->context = d; | ||
252 | urb->complete = dvb_usb_urb_complete; | ||
253 | urb->pipe = usb_rcvisocpipe(d->udev,d->props.urb.endpoint); | ||
254 | urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP; | ||
255 | urb->interval = d->props.urb.u.isoc.interval; | ||
256 | urb->number_of_packets = d->props.urb.u.isoc.framesperurb; | ||
257 | urb->transfer_buffer_length = d->buf_size; | ||
258 | urb->transfer_buffer = d->buf_list[i]; | ||
259 | urb->transfer_dma = d->dma_addr[i]; | ||
260 | |||
261 | for (j = 0; j < d->props.urb.u.isoc.framesperurb; j++) { | ||
262 | urb->iso_frame_desc[j].offset = frame_offset; | ||
263 | urb->iso_frame_desc[j].length = d->props.urb.u.isoc.framesize; | ||
264 | frame_offset += d->props.urb.u.isoc.framesize; | ||
265 | } | ||
266 | |||
267 | d->urbs_initialized++; | ||
268 | } | ||
269 | return 0; | ||
270 | |||
271 | } | ||
272 | |||
154 | int dvb_usb_urb_init(struct dvb_usb_device *d) | 273 | int dvb_usb_urb_init(struct dvb_usb_device *d) |
155 | { | 274 | { |
156 | /* | 275 | /* |
@@ -174,8 +293,7 @@ int dvb_usb_urb_init(struct dvb_usb_device *d) | |||
174 | case DVB_USB_BULK: | 293 | case DVB_USB_BULK: |
175 | return dvb_usb_bulk_urb_init(d); | 294 | return dvb_usb_bulk_urb_init(d); |
176 | case DVB_USB_ISOC: | 295 | case DVB_USB_ISOC: |
177 | err("isochronous transfer not yet implemented in dvb-usb."); | 296 | return dvb_usb_isoc_urb_init(d); |
178 | return -EINVAL; | ||
179 | default: | 297 | default: |
180 | err("unkown URB-type for data transfer."); | 298 | err("unkown URB-type for data transfer."); |
181 | return -EINVAL; | 299 | return -EINVAL; |
@@ -191,7 +309,7 @@ int dvb_usb_urb_exit(struct dvb_usb_device *d) | |||
191 | if (d->state & DVB_USB_STATE_URB_LIST) { | 309 | if (d->state & DVB_USB_STATE_URB_LIST) { |
192 | for (i = 0; i < d->urbs_initialized; i++) { | 310 | for (i = 0; i < d->urbs_initialized; i++) { |
193 | if (d->urb_list[i] != NULL) { | 311 | if (d->urb_list[i] != NULL) { |
194 | deb_info("freeing URB no. %d.\n",i); | 312 | deb_mem("freeing URB no. %d.\n",i); |
195 | /* free the URBs */ | 313 | /* free the URBs */ |
196 | usb_free_urb(d->urb_list[i]); | 314 | usb_free_urb(d->urb_list[i]); |
197 | } | 315 | } |
@@ -202,10 +320,6 @@ int dvb_usb_urb_exit(struct dvb_usb_device *d) | |||
202 | d->state &= ~DVB_USB_STATE_URB_LIST; | 320 | d->state &= ~DVB_USB_STATE_URB_LIST; |
203 | } | 321 | } |
204 | 322 | ||
205 | if (d->state & DVB_USB_STATE_URB_BUF) | 323 | dvb_usb_free_stream_buffers(d); |
206 | usb_buffer_free(d->udev, d->props.urb.u.bulk.buffersize * d->props.urb.count, | ||
207 | d->buffer, d->dma_handle); | ||
208 | |||
209 | d->state &= ~DVB_USB_STATE_URB_BUF; | ||
210 | return 0; | 324 | return 0; |
211 | } | 325 | } |
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb.h b/drivers/media/dvb/dvb-usb/dvb-usb.h index abcee1943f64..6c627e9ea648 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb.h | |||
@@ -189,6 +189,7 @@ struct dvb_usb_properties { | |||
189 | struct { | 189 | struct { |
190 | int framesperurb; | 190 | int framesperurb; |
191 | int framesize; | 191 | int framesize; |
192 | int interval; | ||
192 | } isoc; | 193 | } isoc; |
193 | } u; | 194 | } u; |
194 | } urb; | 195 | } urb; |
@@ -207,19 +208,28 @@ struct dvb_usb_properties { | |||
207 | * @udev: pointer to the device's struct usb_device. | 208 | * @udev: pointer to the device's struct usb_device. |
208 | * @urb_list: array of dynamically allocated struct urb for the MPEG2-TS- | 209 | * @urb_list: array of dynamically allocated struct urb for the MPEG2-TS- |
209 | * streaming. | 210 | * streaming. |
210 | * @buffer: buffer used to streaming. | 211 | * |
211 | * @dma_handle: dma_addr_t for buffer. | 212 | * @buf_num: number of buffer allocated. |
213 | * @buf_size: size of each buffer in buf_list. | ||
214 | * @buf_list: array containing all allocate buffers for streaming. | ||
215 | * @dma_addr: list of dma_addr_t for each buffer in buf_list. | ||
216 | * | ||
212 | * @urbs_initialized: number of URBs initialized. | 217 | * @urbs_initialized: number of URBs initialized. |
213 | * @urbs_submitted: number of URBs submitted. | 218 | * @urbs_submitted: number of URBs submitted. |
219 | * | ||
214 | * @feedcount: number of reqested feeds (used for streaming-activation) | 220 | * @feedcount: number of reqested feeds (used for streaming-activation) |
215 | * @pid_filtering: is hardware pid_filtering used or not. | 221 | * @pid_filtering: is hardware pid_filtering used or not. |
222 | * | ||
216 | * @usb_sem: semaphore of USB control messages (reading needs two messages) | 223 | * @usb_sem: semaphore of USB control messages (reading needs two messages) |
217 | * @i2c_sem: semaphore for i2c-transfers | 224 | * @i2c_sem: semaphore for i2c-transfers |
225 | * | ||
218 | * @i2c_adap: device's i2c_adapter if it uses I2CoverUSB | 226 | * @i2c_adap: device's i2c_adapter if it uses I2CoverUSB |
219 | * @pll_addr: I2C address of the tuner for programming | 227 | * @pll_addr: I2C address of the tuner for programming |
220 | * @pll_init: array containing the initialization buffer | 228 | * @pll_init: array containing the initialization buffer |
221 | * @pll_desc: pointer to the appropriate struct dvb_pll_desc | 229 | * @pll_desc: pointer to the appropriate struct dvb_pll_desc |
222 | * @tuner_pass_ctrl: called to (de)activate tuner passthru of the demod | 230 | * |
231 | * @tuner_pass_ctrl: called to (de)activate tuner passthru of the demod or the board | ||
232 | * | ||
223 | * @dvb_adap: device's dvb_adapter. | 233 | * @dvb_adap: device's dvb_adapter. |
224 | * @dmxdev: device's dmxdev. | 234 | * @dmxdev: device's dmxdev. |
225 | * @demux: device's software demuxer. | 235 | * @demux: device's software demuxer. |
@@ -253,8 +263,12 @@ struct dvb_usb_device { | |||
253 | /* usb */ | 263 | /* usb */ |
254 | struct usb_device *udev; | 264 | struct usb_device *udev; |
255 | struct urb **urb_list; | 265 | struct urb **urb_list; |
256 | u8 *buffer; | 266 | |
257 | dma_addr_t dma_handle; | 267 | int buf_num; |
268 | unsigned long buf_size; | ||
269 | u8 **buf_list; | ||
270 | dma_addr_t *dma_addr; | ||
271 | |||
258 | int urbs_initialized; | 272 | int urbs_initialized; |
259 | int urbs_submitted; | 273 | int urbs_submitted; |
260 | 274 | ||