diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-09-13 10:25:45 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-09-18 22:47:37 -0400 |
commit | bb4c9a74b88aac4c30566cc8616a01c47028761f (patch) | |
tree | cc093b6cd829397895dbc2b414ffa82734841ae2 | |
parent | 466a1c15b5dff85810cb86d6b37b96b07846cd82 (diff) |
V4L/DVB (12732): cx25821: fix bad whitespacing
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
29 files changed, 3914 insertions, 3915 deletions
diff --git a/drivers/staging/cx25821/Kconfig b/drivers/staging/cx25821/Kconfig index 88871156c0d..df7756a95fa 100644 --- a/drivers/staging/cx25821/Kconfig +++ b/drivers/staging/cx25821/Kconfig | |||
@@ -15,7 +15,7 @@ config VIDEO_CX25821 | |||
15 | 15 | ||
16 | To compile this driver as a module, choose M here: the | 16 | To compile this driver as a module, choose M here: the |
17 | module will be called cx25821 | 17 | module will be called cx25821 |
18 | 18 | ||
19 | config VIDEO_CX25821_ALSA | 19 | config VIDEO_CX25821_ALSA |
20 | tristate "Conexant 25821 DMA audio support" | 20 | tristate "Conexant 25821 DMA audio support" |
21 | depends on VIDEO_CX25821 && SND && EXPERIMENTAL | 21 | depends on VIDEO_CX25821 && SND && EXPERIMENTAL |
@@ -30,5 +30,5 @@ config VIDEO_CX25821_ALSA | |||
30 | PCI device. | 30 | PCI device. |
31 | 31 | ||
32 | To compile this driver as a module, choose M here: the | 32 | To compile this driver as a module, choose M here: the |
33 | module will be called cx25821-alsa. | 33 | module will be called cx25821-alsa. |
34 | 34 | ||
diff --git a/drivers/staging/cx25821/cx25821-alsa.c b/drivers/staging/cx25821/cx25821-alsa.c index 6b2e86acc12..3ab5641d298 100644 --- a/drivers/staging/cx25821/cx25821-alsa.c +++ b/drivers/staging/cx25821/cx25821-alsa.c | |||
@@ -72,7 +72,7 @@ struct cx25821_audio_dev { | |||
72 | 72 | ||
73 | unsigned long iobase; | 73 | unsigned long iobase; |
74 | spinlock_t reg_lock; | 74 | spinlock_t reg_lock; |
75 | atomic_t count; | 75 | atomic_t count; |
76 | 76 | ||
77 | unsigned int dma_size; | 77 | unsigned int dma_size; |
78 | unsigned int period_size; | 78 | unsigned int period_size; |
diff --git a/drivers/staging/cx25821/cx25821-audio-upstream.c b/drivers/staging/cx25821/cx25821-audio-upstream.c index 9138767e4d7..376c953a878 100644 --- a/drivers/staging/cx25821/cx25821-audio-upstream.c +++ b/drivers/staging/cx25821/cx25821-audio-upstream.c | |||
@@ -45,8 +45,8 @@ static int _intr_msk = FLD_AUD_SRC_RISCI1 | FLD_AUD_SRC_OF | FLD_AUD_SRC_SYNC | | |||
45 | 45 | ||
46 | 46 | ||
47 | int cx25821_sram_channel_setup_upstream_audio(struct cx25821_dev *dev, | 47 | int cx25821_sram_channel_setup_upstream_audio(struct cx25821_dev *dev, |
48 | struct sram_channel *ch, | 48 | struct sram_channel *ch, |
49 | unsigned int bpl, u32 risc) | 49 | unsigned int bpl, u32 risc) |
50 | { | 50 | { |
51 | unsigned int i, lines; | 51 | unsigned int i, lines; |
52 | u32 cdt; | 52 | u32 cdt; |
@@ -66,7 +66,7 @@ int cx25821_sram_channel_setup_upstream_audio(struct cx25821_dev *dev, | |||
66 | 66 | ||
67 | if (lines > 3) | 67 | if (lines > 3) |
68 | { | 68 | { |
69 | lines = 3; | 69 | lines = 3; |
70 | } | 70 | } |
71 | 71 | ||
72 | BUG_ON(lines < 2); | 72 | BUG_ON(lines < 2); |
@@ -87,7 +87,7 @@ int cx25821_sram_channel_setup_upstream_audio(struct cx25821_dev *dev, | |||
87 | cx_write(ch->cmds_start + 8, cdt); | 87 | cx_write(ch->cmds_start + 8, cdt); |
88 | cx_write(ch->cmds_start + 12, AUDIO_CDT_SIZE_QW); | 88 | cx_write(ch->cmds_start + 12, AUDIO_CDT_SIZE_QW); |
89 | cx_write(ch->cmds_start + 16, ch->ctrl_start); | 89 | cx_write(ch->cmds_start + 16, ch->ctrl_start); |
90 | 90 | ||
91 | //IQ size | 91 | //IQ size |
92 | cx_write(ch->cmds_start + 20, AUDIO_IQ_SIZE_DW); | 92 | cx_write(ch->cmds_start + 20, AUDIO_IQ_SIZE_DW); |
93 | 93 | ||
@@ -105,40 +105,40 @@ int cx25821_sram_channel_setup_upstream_audio(struct cx25821_dev *dev, | |||
105 | 105 | ||
106 | 106 | ||
107 | static __le32 *cx25821_risc_field_upstream_audio( struct cx25821_dev *dev, __le32 *rp, | 107 | static __le32 *cx25821_risc_field_upstream_audio( struct cx25821_dev *dev, __le32 *rp, |
108 | dma_addr_t databuf_phys_addr, | 108 | dma_addr_t databuf_phys_addr, |
109 | unsigned int bpl, int fifo_enable) | 109 | unsigned int bpl, int fifo_enable) |
110 | { | 110 | { |
111 | unsigned int line; | 111 | unsigned int line; |
112 | struct sram_channel *sram_ch = &dev->sram_channels[dev->_audio_upstream_channel_select]; | 112 | struct sram_channel *sram_ch = &dev->sram_channels[dev->_audio_upstream_channel_select]; |
113 | int offset = 0; | 113 | int offset = 0; |
114 | 114 | ||
115 | 115 | ||
116 | /* scan lines */ | 116 | /* scan lines */ |
117 | for (line = 0; line < LINES_PER_AUDIO_BUFFER; line++) | 117 | for (line = 0; line < LINES_PER_AUDIO_BUFFER; line++) |
118 | { | 118 | { |
119 | *(rp++) = cpu_to_le32(RISC_READ|RISC_SOL|RISC_EOL|bpl); | 119 | *(rp++) = cpu_to_le32(RISC_READ|RISC_SOL|RISC_EOL|bpl); |
120 | *(rp++) = cpu_to_le32(databuf_phys_addr + offset); | 120 | *(rp++) = cpu_to_le32(databuf_phys_addr + offset); |
121 | *(rp++) = cpu_to_le32(0); /* bits 63-32 */ | 121 | *(rp++) = cpu_to_le32(0); /* bits 63-32 */ |
122 | 122 | ||
123 | // Check if we need to enable the FIFO after the first 3 lines | 123 | // Check if we need to enable the FIFO after the first 3 lines |
124 | // For the upstream audio channel, the risc engine will enable the FIFO. | 124 | // For the upstream audio channel, the risc engine will enable the FIFO. |
125 | if ( fifo_enable && line == 2 ) | 125 | if ( fifo_enable && line == 2 ) |
126 | { | 126 | { |
127 | *(rp++) = RISC_WRITECR; | 127 | *(rp++) = RISC_WRITECR; |
128 | *(rp++) = sram_ch->dma_ctl; | 128 | *(rp++) = sram_ch->dma_ctl; |
129 | *(rp++) = sram_ch->fld_aud_fifo_en; | 129 | *(rp++) = sram_ch->fld_aud_fifo_en; |
130 | *(rp++) = 0x00000020; | 130 | *(rp++) = 0x00000020; |
131 | } | 131 | } |
132 | 132 | ||
133 | offset += AUDIO_LINE_SIZE; | 133 | offset += AUDIO_LINE_SIZE; |
134 | } | 134 | } |
135 | 135 | ||
136 | return rp; | 136 | return rp; |
137 | } | 137 | } |
138 | 138 | ||
139 | int cx25821_risc_buffer_upstream_audio( struct cx25821_dev *dev, | 139 | int cx25821_risc_buffer_upstream_audio( struct cx25821_dev *dev, |
140 | struct pci_dev *pci, | 140 | struct pci_dev *pci, |
141 | unsigned int bpl, unsigned int lines) | 141 | unsigned int bpl, unsigned int lines) |
142 | { | 142 | { |
143 | __le32 *rp; | 143 | __le32 *rp; |
144 | int fifo_enable = 0; | 144 | int fifo_enable = 0; |
@@ -148,7 +148,7 @@ int cx25821_risc_buffer_upstream_audio( struct cx25821_dev *dev, | |||
148 | int risc_flag = RISC_CNT_INC; | 148 | int risc_flag = RISC_CNT_INC; |
149 | dma_addr_t risc_phys_jump_addr; | 149 | dma_addr_t risc_phys_jump_addr; |
150 | 150 | ||
151 | 151 | ||
152 | /* Virtual address of Risc buffer program */ | 152 | /* Virtual address of Risc buffer program */ |
153 | rp = dev->_risc_virt_addr; | 153 | rp = dev->_risc_virt_addr; |
154 | 154 | ||
@@ -158,48 +158,48 @@ int cx25821_risc_buffer_upstream_audio( struct cx25821_dev *dev, | |||
158 | 158 | ||
159 | for( frame = 0; frame < NUM_AUDIO_FRAMES; frame++ ) | 159 | for( frame = 0; frame < NUM_AUDIO_FRAMES; frame++ ) |
160 | { | 160 | { |
161 | databuf_offset = frame_size * frame; | 161 | databuf_offset = frame_size * frame; |
162 | 162 | ||
163 | if( frame == 0 ) | 163 | if( frame == 0 ) |
164 | { | 164 | { |
165 | fifo_enable = 1; | 165 | fifo_enable = 1; |
166 | risc_flag = RISC_CNT_RESET; | 166 | risc_flag = RISC_CNT_RESET; |
167 | } | 167 | } |
168 | else | 168 | else |
169 | { | 169 | { |
170 | fifo_enable = 0; | 170 | fifo_enable = 0; |
171 | risc_flag = RISC_CNT_INC; | 171 | risc_flag = RISC_CNT_INC; |
172 | } | 172 | } |
173 | 173 | ||
174 | //Calculate physical jump address | 174 | //Calculate physical jump address |
175 | if( (frame+1) == NUM_AUDIO_FRAMES ) | 175 | if( (frame+1) == NUM_AUDIO_FRAMES ) |
176 | { | 176 | { |
177 | risc_phys_jump_addr = dev->_risc_phys_start_addr + RISC_SYNC_INSTRUCTION_SIZE; | 177 | risc_phys_jump_addr = dev->_risc_phys_start_addr + RISC_SYNC_INSTRUCTION_SIZE; |
178 | } | 178 | } |
179 | else | 179 | else |
180 | { | 180 | { |
181 | risc_phys_jump_addr = dev->_risc_phys_start_addr + RISC_SYNC_INSTRUCTION_SIZE + AUDIO_RISC_DMA_BUF_SIZE*(frame+1); | 181 | risc_phys_jump_addr = dev->_risc_phys_start_addr + RISC_SYNC_INSTRUCTION_SIZE + AUDIO_RISC_DMA_BUF_SIZE*(frame+1); |
182 | } | 182 | } |
183 | 183 | ||
184 | rp = cx25821_risc_field_upstream_audio(dev, rp, dev->_audiodata_buf_phys_addr+databuf_offset, bpl, fifo_enable); | 184 | rp = cx25821_risc_field_upstream_audio(dev, rp, dev->_audiodata_buf_phys_addr+databuf_offset, bpl, fifo_enable); |
185 | 185 | ||
186 | 186 | ||
187 | if( USE_RISC_NOOP_AUDIO ) | 187 | if( USE_RISC_NOOP_AUDIO ) |
188 | { | 188 | { |
189 | for( i = 0; i < NUM_NO_OPS; i++ ) | 189 | for( i = 0; i < NUM_NO_OPS; i++ ) |
190 | { | 190 | { |
191 | *(rp++) = cpu_to_le32(RISC_NOOP); | 191 | *(rp++) = cpu_to_le32(RISC_NOOP); |
192 | } | 192 | } |
193 | } | 193 | } |
194 | 194 | ||
195 | 195 | ||
196 | // Loop to (Nth)FrameRISC or to Start of Risc program & generate IRQ | 196 | // Loop to (Nth)FrameRISC or to Start of Risc program & generate IRQ |
197 | *(rp++) = cpu_to_le32(RISC_JUMP|RISC_IRQ1|risc_flag); | 197 | *(rp++) = cpu_to_le32(RISC_JUMP|RISC_IRQ1|risc_flag); |
198 | *(rp++) = cpu_to_le32(risc_phys_jump_addr); | 198 | *(rp++) = cpu_to_le32(risc_phys_jump_addr); |
199 | *(rp++) = cpu_to_le32(0); | 199 | *(rp++) = cpu_to_le32(0); |
200 | 200 | ||
201 | //Recalculate virtual address based on frame index | 201 | //Recalculate virtual address based on frame index |
202 | rp = dev->_risc_virt_addr + RISC_SYNC_INSTRUCTION_SIZE/4 + (AUDIO_RISC_DMA_BUF_SIZE*(frame+1)/4 ) ; | 202 | rp = dev->_risc_virt_addr + RISC_SYNC_INSTRUCTION_SIZE/4 + (AUDIO_RISC_DMA_BUF_SIZE*(frame+1)/4 ) ; |
203 | } | 203 | } |
204 | 204 | ||
205 | return 0; | 205 | return 0; |
@@ -228,10 +228,10 @@ void cx25821_stop_upstream_audio(struct cx25821_dev *dev) | |||
228 | 228 | ||
229 | if( !dev->_audio_is_running ) | 229 | if( !dev->_audio_is_running ) |
230 | { | 230 | { |
231 | printk("cx25821: No audio file is currently running so return!\n"); | 231 | printk("cx25821: No audio file is currently running so return!\n"); |
232 | return; | 232 | return; |
233 | } | 233 | } |
234 | 234 | ||
235 | //Disable RISC interrupts | 235 | //Disable RISC interrupts |
236 | cx_write( sram_ch->int_msk, 0 ); | 236 | cx_write( sram_ch->int_msk, 0 ); |
237 | 237 | ||
@@ -241,8 +241,8 @@ void cx25821_stop_upstream_audio(struct cx25821_dev *dev) | |||
241 | 241 | ||
242 | //Clear data buffer memory | 242 | //Clear data buffer memory |
243 | if( dev->_audiodata_buf_virt_addr ) | 243 | if( dev->_audiodata_buf_virt_addr ) |
244 | memset( dev->_audiodata_buf_virt_addr, 0, dev->_audiodata_buf_size ); | 244 | memset( dev->_audiodata_buf_virt_addr, 0, dev->_audiodata_buf_size ); |
245 | 245 | ||
246 | dev->_audio_is_running = 0; | 246 | dev->_audio_is_running = 0; |
247 | dev->_is_first_audio_frame = 0; | 247 | dev->_is_first_audio_frame = 0; |
248 | dev->_audioframe_count = 0; | 248 | dev->_audioframe_count = 0; |
@@ -250,12 +250,12 @@ void cx25821_stop_upstream_audio(struct cx25821_dev *dev) | |||
250 | 250 | ||
251 | if( dev->_irq_audio_queues ) | 251 | if( dev->_irq_audio_queues ) |
252 | { | 252 | { |
253 | kfree(dev->_irq_audio_queues); | 253 | kfree(dev->_irq_audio_queues); |
254 | dev->_irq_audio_queues = NULL; | 254 | dev->_irq_audio_queues = NULL; |
255 | } | 255 | } |
256 | 256 | ||
257 | if( dev->_audiofilename != NULL ) | 257 | if( dev->_audiofilename != NULL ) |
258 | kfree(dev->_audiofilename); | 258 | kfree(dev->_audiofilename); |
259 | } | 259 | } |
260 | 260 | ||
261 | 261 | ||
@@ -263,7 +263,7 @@ void cx25821_free_mem_upstream_audio(struct cx25821_dev *dev) | |||
263 | { | 263 | { |
264 | if( dev->_audio_is_running ) | 264 | if( dev->_audio_is_running ) |
265 | { | 265 | { |
266 | cx25821_stop_upstream_audio(dev); | 266 | cx25821_stop_upstream_audio(dev); |
267 | } | 267 | } |
268 | 268 | ||
269 | cx25821_free_memory_audio(dev); | 269 | cx25821_free_memory_audio(dev); |
@@ -286,69 +286,69 @@ int cx25821_get_audio_data(struct cx25821_dev *dev, struct sram_channel *sram_ch | |||
286 | 286 | ||
287 | 287 | ||
288 | if( dev->_audiofile_status == END_OF_FILE ) | 288 | if( dev->_audiofile_status == END_OF_FILE ) |
289 | return 0; | 289 | return 0; |
290 | 290 | ||
291 | myfile = filp_open( dev->_audiofilename, O_RDONLY | O_LARGEFILE, 0 ); | 291 | myfile = filp_open( dev->_audiofilename, O_RDONLY | O_LARGEFILE, 0 ); |
292 | 292 | ||
293 | 293 | ||
294 | if (IS_ERR(myfile)) | 294 | if (IS_ERR(myfile)) |
295 | { | 295 | { |
296 | const int open_errno = -PTR_ERR(myfile); | 296 | const int open_errno = -PTR_ERR(myfile); |
297 | printk("%s(): ERROR opening file(%s) with errno = %d! \n", __func__, dev->_audiofilename, open_errno); | 297 | printk("%s(): ERROR opening file(%s) with errno = %d! \n", __func__, dev->_audiofilename, open_errno); |
298 | return PTR_ERR(myfile); | 298 | return PTR_ERR(myfile); |
299 | } | 299 | } |
300 | else | 300 | else |
301 | { | 301 | { |
302 | if( !(myfile->f_op) ) | 302 | if( !(myfile->f_op) ) |
303 | { | 303 | { |
304 | printk("%s: File has no file operations registered!\n", __func__); | 304 | printk("%s: File has no file operations registered!\n", __func__); |
305 | filp_close(myfile, NULL); | 305 | filp_close(myfile, NULL); |
306 | return -EIO; | 306 | return -EIO; |
307 | } | 307 | } |
308 | 308 | ||
309 | 309 | ||
310 | if( !myfile->f_op->read ) | 310 | if( !myfile->f_op->read ) |
311 | { | 311 | { |
312 | printk("%s: File has no READ operations registered! \n", __func__); | 312 | printk("%s: File has no READ operations registered! \n", __func__); |
313 | filp_close(myfile, NULL); | 313 | filp_close(myfile, NULL); |
314 | return -EIO; | 314 | return -EIO; |
315 | } | 315 | } |
316 | 316 | ||
317 | pos = myfile->f_pos; | 317 | pos = myfile->f_pos; |
318 | old_fs = get_fs(); | 318 | old_fs = get_fs(); |
319 | set_fs(KERNEL_DS); | 319 | set_fs(KERNEL_DS); |
320 | 320 | ||
321 | 321 | ||
322 | for( i = 0; i < dev->_audio_lines_count; i++ ) | 322 | for( i = 0; i < dev->_audio_lines_count; i++ ) |
323 | { | 323 | { |
324 | pos = file_offset; | 324 | pos = file_offset; |
325 | 325 | ||
326 | vfs_read_retval = vfs_read(myfile, mybuf, line_size, &pos); | 326 | vfs_read_retval = vfs_read(myfile, mybuf, line_size, &pos); |
327 | 327 | ||
328 | 328 | ||
329 | if( vfs_read_retval > 0 && vfs_read_retval == line_size && dev->_audiodata_buf_virt_addr != NULL ) | 329 | if( vfs_read_retval > 0 && vfs_read_retval == line_size && dev->_audiodata_buf_virt_addr != NULL ) |
330 | { | 330 | { |
331 | memcpy( (void*)(dev->_audiodata_buf_virt_addr+frame_offset/4), mybuf, vfs_read_retval); | 331 | memcpy( (void*)(dev->_audiodata_buf_virt_addr+frame_offset/4), mybuf, vfs_read_retval); |
332 | } | 332 | } |
333 | 333 | ||
334 | file_offset += vfs_read_retval; | 334 | file_offset += vfs_read_retval; |
335 | frame_offset += vfs_read_retval; | 335 | frame_offset += vfs_read_retval; |
336 | 336 | ||
337 | if( vfs_read_retval < line_size ) | 337 | if( vfs_read_retval < line_size ) |
338 | { | 338 | { |
339 | printk(KERN_INFO "Done: exit %s() since no more bytes to read from Audio file.\n", __func__ ); | 339 | printk(KERN_INFO "Done: exit %s() since no more bytes to read from Audio file.\n", __func__ ); |
340 | break; | 340 | break; |
341 | } | 341 | } |
342 | } | 342 | } |
343 | 343 | ||
344 | if( i > 0 ) | 344 | if( i > 0 ) |
345 | dev->_audioframe_count++; | 345 | dev->_audioframe_count++; |
346 | 346 | ||
347 | dev->_audiofile_status = (vfs_read_retval == line_size) ? IN_PROGRESS : END_OF_FILE; | 347 | dev->_audiofile_status = (vfs_read_retval == line_size) ? IN_PROGRESS : END_OF_FILE; |
348 | 348 | ||
349 | 349 | ||
350 | set_fs(old_fs); | 350 | set_fs(old_fs); |
351 | filp_close(myfile, NULL); | 351 | filp_close(myfile, NULL); |
352 | } | 352 | } |
353 | 353 | ||
354 | return 0; | 354 | return 0; |
@@ -360,8 +360,8 @@ static void cx25821_audioups_handler(struct work_struct *work) | |||
360 | 360 | ||
361 | if( !dev ) | 361 | if( !dev ) |
362 | { | 362 | { |
363 | printk("ERROR %s(): since container_of(work_struct) FAILED! \n", __func__ ); | 363 | printk("ERROR %s(): since container_of(work_struct) FAILED! \n", __func__ ); |
364 | return; | 364 | return; |
365 | } | 365 | } |
366 | 366 | ||
367 | cx25821_get_audio_data( dev, &dev->sram_channels[dev->_audio_upstream_channel_select] ); | 367 | cx25821_get_audio_data( dev, &dev->sram_channels[dev->_audio_upstream_channel_select] ); |
@@ -377,91 +377,91 @@ int cx25821_openfile_audio(struct cx25821_dev *dev, struct sram_channel *sram_ch | |||
377 | loff_t pos; | 377 | loff_t pos; |
378 | loff_t offset = (unsigned long)0; | 378 | loff_t offset = (unsigned long)0; |
379 | mm_segment_t old_fs; | 379 | mm_segment_t old_fs; |
380 | 380 | ||
381 | 381 | ||
382 | myfile = filp_open( dev->_audiofilename, O_RDONLY | O_LARGEFILE, 0 ); | 382 | myfile = filp_open( dev->_audiofilename, O_RDONLY | O_LARGEFILE, 0 ); |
383 | 383 | ||
384 | 384 | ||
385 | if (IS_ERR(myfile)) | 385 | if (IS_ERR(myfile)) |
386 | { | 386 | { |
387 | const int open_errno = -PTR_ERR(myfile); | 387 | const int open_errno = -PTR_ERR(myfile); |
388 | printk("%s(): ERROR opening file(%s) with errno = %d! \n", __func__, dev->_audiofilename, open_errno); | 388 | printk("%s(): ERROR opening file(%s) with errno = %d! \n", __func__, dev->_audiofilename, open_errno); |
389 | return PTR_ERR(myfile); | 389 | return PTR_ERR(myfile); |
390 | } | 390 | } |
391 | else | 391 | else |
392 | { | 392 | { |
393 | if( !(myfile->f_op) ) | 393 | if( !(myfile->f_op) ) |
394 | { | 394 | { |
395 | printk("%s: File has no file operations registered! \n", __func__); | 395 | printk("%s: File has no file operations registered! \n", __func__); |
396 | filp_close(myfile, NULL); | 396 | filp_close(myfile, NULL); |
397 | return -EIO; | 397 | return -EIO; |
398 | } | 398 | } |
399 | 399 | ||
400 | 400 | ||
401 | if( !myfile->f_op->read ) | 401 | if( !myfile->f_op->read ) |
402 | { | 402 | { |
403 | printk("%s: File has no READ operations registered! \n", __func__); | 403 | printk("%s: File has no READ operations registered! \n", __func__); |
404 | filp_close(myfile, NULL); | 404 | filp_close(myfile, NULL); |
405 | return -EIO; | 405 | return -EIO; |
406 | } | 406 | } |
407 | 407 | ||
408 | pos = myfile->f_pos; | 408 | pos = myfile->f_pos; |
409 | old_fs = get_fs(); | 409 | old_fs = get_fs(); |
410 | set_fs(KERNEL_DS); | 410 | set_fs(KERNEL_DS); |
411 | 411 | ||
412 | 412 | ||
413 | for( j = 0; j < NUM_AUDIO_FRAMES; j++ ) | 413 | for( j = 0; j < NUM_AUDIO_FRAMES; j++ ) |
414 | { | 414 | { |
415 | for( i = 0; i < dev->_audio_lines_count; i++ ) | 415 | for( i = 0; i < dev->_audio_lines_count; i++ ) |
416 | { | 416 | { |
417 | pos = offset; | 417 | pos = offset; |
418 | 418 | ||
419 | vfs_read_retval = vfs_read(myfile, mybuf, line_size, &pos); | 419 | vfs_read_retval = vfs_read(myfile, mybuf, line_size, &pos); |
420 | 420 | ||
421 | 421 | ||
422 | if( vfs_read_retval > 0 && vfs_read_retval == line_size && dev->_audiodata_buf_virt_addr != NULL ) | 422 | if( vfs_read_retval > 0 && vfs_read_retval == line_size && dev->_audiodata_buf_virt_addr != NULL ) |
423 | { | 423 | { |
424 | memcpy( (void*)(dev->_audiodata_buf_virt_addr+offset/4), mybuf, vfs_read_retval); | 424 | memcpy( (void*)(dev->_audiodata_buf_virt_addr+offset/4), mybuf, vfs_read_retval); |
425 | } | 425 | } |
426 | 426 | ||
427 | offset += vfs_read_retval; | 427 | offset += vfs_read_retval; |
428 | 428 | ||
429 | if( vfs_read_retval < line_size ) | 429 | if( vfs_read_retval < line_size ) |
430 | { | 430 | { |
431 | printk(KERN_INFO "Done: exit %s() since no more bytes to read from Audio file.\n", __func__ ); | 431 | printk(KERN_INFO "Done: exit %s() since no more bytes to read from Audio file.\n", __func__ ); |
432 | break; | 432 | break; |
433 | } | 433 | } |
434 | } | 434 | } |
435 | 435 | ||
436 | if( i > 0 ) | 436 | if( i > 0 ) |
437 | { | 437 | { |
438 | dev->_audioframe_count++; | 438 | dev->_audioframe_count++; |
439 | } | 439 | } |
440 | 440 | ||
441 | if( vfs_read_retval < line_size ) | 441 | if( vfs_read_retval < line_size ) |
442 | { | 442 | { |
443 | break; | 443 | break; |
444 | } | 444 | } |
445 | } | 445 | } |
446 | 446 | ||
447 | dev->_audiofile_status = (vfs_read_retval == line_size) ? IN_PROGRESS : END_OF_FILE; | 447 | dev->_audiofile_status = (vfs_read_retval == line_size) ? IN_PROGRESS : END_OF_FILE; |
448 | 448 | ||
449 | set_fs(old_fs); | 449 | set_fs(old_fs); |
450 | myfile->f_pos = 0; | 450 | myfile->f_pos = 0; |
451 | filp_close(myfile, NULL); | 451 | filp_close(myfile, NULL); |
452 | } | 452 | } |
453 | 453 | ||
454 | return 0; | 454 | return 0; |
455 | } | 455 | } |
456 | 456 | ||
457 | static int cx25821_audio_upstream_buffer_prepare(struct cx25821_dev *dev, | 457 | static int cx25821_audio_upstream_buffer_prepare(struct cx25821_dev *dev, |
458 | struct sram_channel *sram_ch, | 458 | struct sram_channel *sram_ch, |
459 | int bpl) | 459 | int bpl) |
460 | { | 460 | { |
461 | int ret = 0; | 461 | int ret = 0; |
462 | dma_addr_t dma_addr; | 462 | dma_addr_t dma_addr; |
463 | dma_addr_t data_dma_addr; | 463 | dma_addr_t data_dma_addr; |
464 | 464 | ||
465 | 465 | ||
466 | cx25821_free_memory_audio(dev); | 466 | cx25821_free_memory_audio(dev); |
467 | 467 | ||
@@ -474,7 +474,7 @@ static int cx25821_audio_upstream_buffer_prepare(struct cx25821_dev *dev, | |||
474 | 474 | ||
475 | if (!dev->_risc_virt_addr) | 475 | if (!dev->_risc_virt_addr) |
476 | { | 476 | { |
477 | printk("cx25821 ERROR: pci_alloc_consistent() FAILED to allocate memory for RISC program! Returning.\n"); | 477 | printk("cx25821 ERROR: pci_alloc_consistent() FAILED to allocate memory for RISC program! Returning.\n"); |
478 | return -ENOMEM; | 478 | return -ENOMEM; |
479 | } | 479 | } |
480 | 480 | ||
@@ -489,7 +489,7 @@ static int cx25821_audio_upstream_buffer_prepare(struct cx25821_dev *dev, | |||
489 | 489 | ||
490 | if (!dev->_audiodata_buf_virt_addr) | 490 | if (!dev->_audiodata_buf_virt_addr) |
491 | { | 491 | { |
492 | printk("cx25821 ERROR: pci_alloc_consistent() FAILED to allocate memory for data buffer! Returning. \n"); | 492 | printk("cx25821 ERROR: pci_alloc_consistent() FAILED to allocate memory for data buffer! Returning. \n"); |
493 | return -ENOMEM; | 493 | return -ENOMEM; |
494 | } | 494 | } |
495 | 495 | ||
@@ -499,8 +499,8 @@ static int cx25821_audio_upstream_buffer_prepare(struct cx25821_dev *dev, | |||
499 | 499 | ||
500 | ret = cx25821_openfile_audio(dev, sram_ch); | 500 | ret = cx25821_openfile_audio(dev, sram_ch); |
501 | if( ret < 0 ) | 501 | if( ret < 0 ) |
502 | return ret; | 502 | return ret; |
503 | 503 | ||
504 | 504 | ||
505 | //Creating RISC programs | 505 | //Creating RISC programs |
506 | ret = cx25821_risc_buffer_upstream_audio(dev, dev->pci, bpl, dev->_audio_lines_count ); | 506 | ret = cx25821_risc_buffer_upstream_audio(dev, dev->pci, bpl, dev->_audio_lines_count ); |
@@ -528,86 +528,86 @@ int cx25821_audio_upstream_irq(struct cx25821_dev *dev, int chan_num, u32 status | |||
528 | if (status & FLD_AUD_SRC_RISCI1) | 528 | if (status & FLD_AUD_SRC_RISCI1) |
529 | { | 529 | { |
530 | //Get interrupt_index of the program that interrupted | 530 | //Get interrupt_index of the program that interrupted |
531 | u32 prog_cnt = cx_read( channel->gpcnt ); | 531 | u32 prog_cnt = cx_read( channel->gpcnt ); |
532 | 532 | ||
533 | //Since we've identified our IRQ, clear our bits from the interrupt mask and interrupt status registers | 533 | //Since we've identified our IRQ, clear our bits from the interrupt mask and interrupt status registers |
534 | cx_write(channel->int_msk, 0); | 534 | cx_write(channel->int_msk, 0); |
535 | cx_write(channel->int_stat, cx_read(channel->int_stat) ); | 535 | cx_write(channel->int_stat, cx_read(channel->int_stat) ); |
536 | 536 | ||
537 | spin_lock(&dev->slock); | 537 | spin_lock(&dev->slock); |
538 | 538 | ||
539 | 539 | ||
540 | while(prog_cnt != dev->_last_index_irq) | 540 | while(prog_cnt != dev->_last_index_irq) |
541 | { | 541 | { |
542 | //Update _last_index_irq | 542 | //Update _last_index_irq |
543 | if(dev->_last_index_irq < (NUMBER_OF_PROGRAMS-1)) | 543 | if(dev->_last_index_irq < (NUMBER_OF_PROGRAMS-1)) |
544 | { | 544 | { |
545 | dev->_last_index_irq++; | 545 | dev->_last_index_irq++; |
546 | } | 546 | } |
547 | else | 547 | else |
548 | { | 548 | { |
549 | dev->_last_index_irq = 0; | 549 | dev->_last_index_irq = 0; |
550 | } | 550 | } |
551 | 551 | ||
552 | dev->_audioframe_index = dev->_last_index_irq; | 552 | dev->_audioframe_index = dev->_last_index_irq; |
553 | 553 | ||
554 | queue_work(dev->_irq_audio_queues, &dev->_audio_work_entry); | 554 | queue_work(dev->_irq_audio_queues, &dev->_audio_work_entry); |
555 | } | 555 | } |
556 | 556 | ||
557 | 557 | ||
558 | if ( dev->_is_first_audio_frame ) | 558 | if ( dev->_is_first_audio_frame ) |
559 | { | 559 | { |
560 | dev->_is_first_audio_frame = 0; | 560 | dev->_is_first_audio_frame = 0; |
561 | 561 | ||
562 | if( dev->_risc_virt_start_addr != NULL ) | 562 | if( dev->_risc_virt_start_addr != NULL ) |
563 | { | 563 | { |
564 | risc_phys_jump_addr = dev->_risc_phys_start_addr + RISC_SYNC_INSTRUCTION_SIZE + AUDIO_RISC_DMA_BUF_SIZE; | 564 | risc_phys_jump_addr = dev->_risc_phys_start_addr + RISC_SYNC_INSTRUCTION_SIZE + AUDIO_RISC_DMA_BUF_SIZE; |
565 | 565 | ||
566 | rp = cx25821_risc_field_upstream_audio(dev, dev->_risc_virt_start_addr+1, dev->_audiodata_buf_phys_addr, AUDIO_LINE_SIZE, FIFO_DISABLE); | 566 | rp = cx25821_risc_field_upstream_audio(dev, dev->_risc_virt_start_addr+1, dev->_audiodata_buf_phys_addr, AUDIO_LINE_SIZE, FIFO_DISABLE); |
567 | 567 | ||
568 | if( USE_RISC_NOOP_AUDIO ) | 568 | if( USE_RISC_NOOP_AUDIO ) |
569 | { | 569 | { |
570 | for( i = 0; i < NUM_NO_OPS; i++ ) | 570 | for( i = 0; i < NUM_NO_OPS; i++ ) |
571 | { | 571 | { |
572 | *(rp++) = cpu_to_le32(RISC_NOOP); | 572 | *(rp++) = cpu_to_le32(RISC_NOOP); |
573 | } | 573 | } |
574 | } | 574 | } |
575 | 575 | ||
576 | // Jump to 2nd Audio Frame | 576 | // Jump to 2nd Audio Frame |
577 | *(rp++) = cpu_to_le32(RISC_JUMP | RISC_IRQ1 | RISC_CNT_RESET); | 577 | *(rp++) = cpu_to_le32(RISC_JUMP | RISC_IRQ1 | RISC_CNT_RESET); |
578 | *(rp++) = cpu_to_le32(risc_phys_jump_addr); | 578 | *(rp++) = cpu_to_le32(risc_phys_jump_addr); |
579 | *(rp++) = cpu_to_le32(0); | 579 | *(rp++) = cpu_to_le32(0); |
580 | } | 580 | } |
581 | } | 581 | } |
582 | 582 | ||
583 | spin_unlock(&dev->slock); | 583 | spin_unlock(&dev->slock); |
584 | } | 584 | } |
585 | else | 585 | else |
586 | { | 586 | { |
587 | if(status & FLD_AUD_SRC_OF) | 587 | if(status & FLD_AUD_SRC_OF) |
588 | printk("%s: Audio Received Overflow Error Interrupt!\n", __func__); | 588 | printk("%s: Audio Received Overflow Error Interrupt!\n", __func__); |
589 | 589 | ||
590 | if(status & FLD_AUD_SRC_SYNC) | 590 | if(status & FLD_AUD_SRC_SYNC) |
591 | printk("%s: Audio Received Sync Error Interrupt!\n", __func__); | 591 | printk("%s: Audio Received Sync Error Interrupt!\n", __func__); |
592 | 592 | ||
593 | if(status & FLD_AUD_SRC_OPC_ERR) | 593 | if(status & FLD_AUD_SRC_OPC_ERR) |
594 | printk("%s: Audio Received OpCode Error Interrupt!\n", __func__); | 594 | printk("%s: Audio Received OpCode Error Interrupt!\n", __func__); |
595 | 595 | ||
596 | // Read and write back the interrupt status register to clear our bits | 596 | // Read and write back the interrupt status register to clear our bits |
597 | cx_write(channel->int_stat, cx_read(channel->int_stat) ); | 597 | cx_write(channel->int_stat, cx_read(channel->int_stat) ); |
598 | } | 598 | } |
599 | 599 | ||
600 | 600 | ||
601 | if( dev->_audiofile_status == END_OF_FILE ) | 601 | if( dev->_audiofile_status == END_OF_FILE ) |
602 | { | 602 | { |
603 | printk("cx25821: EOF Channel Audio Framecount = %d\n", dev->_audioframe_count ); | 603 | printk("cx25821: EOF Channel Audio Framecount = %d\n", dev->_audioframe_count ); |
604 | return -1; | 604 | return -1; |
605 | } | 605 | } |
606 | 606 | ||
607 | //ElSE, set the interrupt mask register, re-enable irq. | 607 | //ElSE, set the interrupt mask register, re-enable irq. |
608 | int_msk_tmp = cx_read( channel->int_msk ); | 608 | int_msk_tmp = cx_read( channel->int_msk ); |
609 | cx_write( channel->int_msk, int_msk_tmp |= _intr_msk ); | 609 | cx_write( channel->int_msk, int_msk_tmp |= _intr_msk ); |
610 | 610 | ||
611 | return 0; | 611 | return 0; |
612 | } | 612 | } |
613 | 613 | ||
@@ -620,8 +620,8 @@ static irqreturn_t cx25821_upstream_irq_audio(int irq, void *dev_id) | |||
620 | 620 | ||
621 | 621 | ||
622 | if( !dev ) | 622 | if( !dev ) |
623 | return -1; | 623 | return -1; |
624 | 624 | ||
625 | 625 | ||
626 | sram_ch = &dev->sram_channels[dev->_audio_upstream_channel_select]; | 626 | sram_ch = &dev->sram_channels[dev->_audio_upstream_channel_select]; |
627 | 627 | ||
@@ -631,17 +631,17 @@ static irqreturn_t cx25821_upstream_irq_audio(int irq, void *dev_id) | |||
631 | // Only deal with our interrupt | 631 | // Only deal with our interrupt |
632 | if(audio_status) | 632 | if(audio_status) |
633 | { | 633 | { |
634 | handled = cx25821_audio_upstream_irq(dev, dev->_audio_upstream_channel_select, audio_status); | 634 | handled = cx25821_audio_upstream_irq(dev, dev->_audio_upstream_channel_select, audio_status); |
635 | } | 635 | } |
636 | 636 | ||
637 | 637 | ||
638 | if( handled < 0 ) | 638 | if( handled < 0 ) |
639 | { | 639 | { |
640 | cx25821_stop_upstream_audio(dev); | 640 | cx25821_stop_upstream_audio(dev); |
641 | } | 641 | } |
642 | else | 642 | else |
643 | { | 643 | { |
644 | handled += handled; | 644 | handled += handled; |
645 | } | 645 | } |
646 | 646 | ||
647 | return IRQ_RETVAL(handled); | 647 | return IRQ_RETVAL(handled); |
@@ -655,24 +655,24 @@ static void cx25821_wait_fifo_enable(struct cx25821_dev *dev, struct sram_channe | |||
655 | 655 | ||
656 | do | 656 | do |
657 | { | 657 | { |
658 | //Wait 10 microsecond before checking to see if the FIFO is turned ON. | 658 | //Wait 10 microsecond before checking to see if the FIFO is turned ON. |
659 | udelay(10); | 659 | udelay(10); |
660 | 660 | ||
661 | tmp = cx_read( sram_ch->dma_ctl ); | 661 | tmp = cx_read( sram_ch->dma_ctl ); |
662 | 662 | ||
663 | if(count++ > 1000) //10 millisecond timeout | 663 | if(count++ > 1000) //10 millisecond timeout |
664 | { | 664 | { |
665 | printk("cx25821 ERROR: %s() fifo is NOT turned on. Timeout!\n", __func__); | 665 | printk("cx25821 ERROR: %s() fifo is NOT turned on. Timeout!\n", __func__); |
666 | return; | 666 | return; |
667 | } | 667 | } |
668 | 668 | ||
669 | } while( !(tmp & sram_ch->fld_aud_fifo_en) ); | 669 | } while( !(tmp & sram_ch->fld_aud_fifo_en) ); |
670 | 670 | ||
671 | } | 671 | } |
672 | 672 | ||
673 | 673 | ||
674 | int cx25821_start_audio_dma_upstream(struct cx25821_dev *dev, | 674 | int cx25821_start_audio_dma_upstream(struct cx25821_dev *dev, |
675 | struct sram_channel *sram_ch) | 675 | struct sram_channel *sram_ch) |
676 | { | 676 | { |
677 | u32 tmp = 0; | 677 | u32 tmp = 0; |
678 | int err = 0; | 678 | int err = 0; |
@@ -744,10 +744,10 @@ int cx25821_audio_upstream_init(struct cx25821_dev *dev, int channel_select) | |||
744 | 744 | ||
745 | if( dev->_audio_is_running ) | 745 | if( dev->_audio_is_running ) |
746 | { | 746 | { |
747 | printk("Audio Channel is still running so return!\n"); | 747 | printk("Audio Channel is still running so return!\n"); |
748 | return 0; | 748 | return 0; |
749 | } | 749 | } |
750 | 750 | ||
751 | dev->_audio_upstream_channel_select = channel_select; | 751 | dev->_audio_upstream_channel_select = channel_select; |
752 | sram_ch = &dev->sram_channels[channel_select]; | 752 | sram_ch = &dev->sram_channels[channel_select]; |
753 | 753 | ||
@@ -757,10 +757,10 @@ int cx25821_audio_upstream_init(struct cx25821_dev *dev, int channel_select) | |||
757 | 757 | ||
758 | if(!dev->_irq_audio_queues) | 758 | if(!dev->_irq_audio_queues) |
759 | { | 759 | { |
760 | printk("cx25821 ERROR: create_singlethread_workqueue() for Audio FAILED!\n"); | 760 | printk("cx25821 ERROR: create_singlethread_workqueue() for Audio FAILED!\n"); |
761 | return -ENOMEM; | 761 | return -ENOMEM; |
762 | } | 762 | } |
763 | 763 | ||
764 | 764 | ||
765 | dev->_last_index_irq = 0; | 765 | dev->_last_index_irq = 0; |
766 | dev->_audio_is_running = 0; | 766 | dev->_audio_is_running = 0; |
@@ -769,32 +769,32 @@ int cx25821_audio_upstream_init(struct cx25821_dev *dev, int channel_select) | |||
769 | dev->_audio_lines_count = LINES_PER_AUDIO_BUFFER; | 769 | dev->_audio_lines_count = LINES_PER_AUDIO_BUFFER; |
770 | _line_size = AUDIO_LINE_SIZE; | 770 | _line_size = AUDIO_LINE_SIZE; |
771 | 771 | ||
772 | 772 | ||
773 | if( dev->input_audiofilename ) | 773 | if( dev->input_audiofilename ) |
774 | { | 774 | { |
775 | str_length = strlen(dev->input_audiofilename); | 775 | str_length = strlen(dev->input_audiofilename); |
776 | dev->_audiofilename = (char *) kmalloc(str_length + 1, GFP_KERNEL); | 776 | dev->_audiofilename = (char *) kmalloc(str_length + 1, GFP_KERNEL); |
777 | 777 | ||
778 | if( !dev->_audiofilename ) | 778 | if( !dev->_audiofilename ) |
779 | goto error; | 779 | goto error; |
780 | 780 | ||
781 | memcpy(dev->_audiofilename, dev->input_audiofilename, str_length + 1); | 781 | memcpy(dev->_audiofilename, dev->input_audiofilename, str_length + 1); |
782 | 782 | ||
783 | //Default if filename is empty string | 783 | //Default if filename is empty string |
784 | if( strcmp(dev->input_audiofilename,"") == 0) | 784 | if( strcmp(dev->input_audiofilename,"") == 0) |
785 | { | 785 | { |
786 | dev->_audiofilename = "/root/audioGOOD.wav"; | 786 | dev->_audiofilename = "/root/audioGOOD.wav"; |
787 | } | 787 | } |
788 | } | 788 | } |
789 | else | 789 | else |
790 | { | 790 | { |
791 | str_length = strlen(_defaultAudioName); | 791 | str_length = strlen(_defaultAudioName); |
792 | dev->_audiofilename = (char *) kmalloc(str_length + 1, GFP_KERNEL); | 792 | dev->_audiofilename = (char *) kmalloc(str_length + 1, GFP_KERNEL); |
793 | 793 | ||
794 | if( !dev->_audiofilename ) | 794 | if( !dev->_audiofilename ) |
795 | goto error; | 795 | goto error; |
796 | 796 | ||
797 | memcpy(dev->_audiofilename, _defaultAudioName, str_length + 1); | 797 | memcpy(dev->_audiofilename, _defaultAudioName, str_length + 1); |
798 | } | 798 | } |
799 | 799 | ||
800 | 800 | ||
@@ -822,4 +822,3 @@ error: | |||
822 | 822 | ||
823 | return err; | 823 | return err; |
824 | } | 824 | } |
825 | |||
diff --git a/drivers/staging/cx25821/cx25821-audups11.c b/drivers/staging/cx25821/cx25821-audups11.c index a8e4dce88b9..4a60be2f688 100644 --- a/drivers/staging/cx25821/cx25821-audups11.c +++ b/drivers/staging/cx25821/cx25821-audups11.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the Conexant CX25821 PCIe bridge | 2 | * Driver for the Conexant CX25821 PCIe bridge |
3 | * | 3 | * |
4 | * Copyright (C) 2009 Conexant Systems Inc. | 4 | * Copyright (C) 2009 Conexant Systems Inc. |
5 | * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com> | 5 | * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com> |
6 | * Based on Steven Toth <stoth@linuxtv.org> cx23885 driver | 6 | * Based on Steven Toth <stoth@linuxtv.org> cx23885 driver |
7 | * | 7 | * |
@@ -40,37 +40,37 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) | |||
40 | dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]); | 40 | dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]); |
41 | 41 | ||
42 | if (!list_empty(&q->queued)) { | 42 | if (!list_empty(&q->queued)) { |
43 | list_add_tail(&buf->vb.queue, &q->queued); | 43 | list_add_tail(&buf->vb.queue, &q->queued); |
44 | buf->vb.state = VIDEOBUF_QUEUED; | 44 | buf->vb.state = VIDEOBUF_QUEUED; |
45 | dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i); | 45 | dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i); |
46 | 46 | ||
47 | } else if (list_empty(&q->active)) { | 47 | } else if (list_empty(&q->active)) { |
48 | list_add_tail(&buf->vb.queue, &q->active); | 48 | list_add_tail(&buf->vb.queue, &q->active); |
49 | cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH11]); | 49 | cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH11]); |
50 | buf->vb.state = VIDEOBUF_ACTIVE; | 50 | buf->vb.state = VIDEOBUF_ACTIVE; |
51 | buf->count = q->count++; | 51 | buf->count = q->count++; |
52 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); | 52 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); |
53 | dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n", | 53 | dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n", |
54 | buf, buf->vb. i, buf->count, q->count); | 54 | buf, buf->vb. i, buf->count, q->count); |
55 | } else { | 55 | } else { |
56 | prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue); | 56 | prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue); |
57 | if (prev->vb.width == buf->vb.width && | 57 | if (prev->vb.width == buf->vb.width && |
58 | prev->vb.height == buf->vb.height && | 58 | prev->vb.height == buf->vb.height && |
59 | prev->fmt == buf->fmt) { | 59 | prev->fmt == buf->fmt) { |
60 | list_add_tail(&buf->vb.queue, &q->active); | 60 | list_add_tail(&buf->vb.queue, &q->active); |
61 | buf->vb.state = VIDEOBUF_ACTIVE; | 61 | buf->vb.state = VIDEOBUF_ACTIVE; |
62 | buf->count = q->count++; | 62 | buf->count = q->count++; |
63 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); | 63 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); |
64 | 64 | ||
65 | /* 64 bit bits 63-32 */ | 65 | /* 64 bit bits 63-32 */ |
66 | prev->risc.jmp[2] = cpu_to_le32(0); | 66 | prev->risc.jmp[2] = cpu_to_le32(0); |
67 | dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count); | 67 | dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count); |
68 | 68 | ||
69 | } else { | 69 | } else { |
70 | list_add_tail(&buf->vb.queue, &q->queued); | 70 | list_add_tail(&buf->vb.queue, &q->queued); |
71 | buf->vb.state = VIDEOBUF_QUEUED; | 71 | buf->vb.state = VIDEOBUF_QUEUED; |
72 | dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i); | 72 | dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i); |
73 | } | 73 | } |
74 | } | 74 | } |
75 | 75 | ||
76 | if (list_empty(&q->active)) | 76 | if (list_empty(&q->active)) |
@@ -99,18 +99,18 @@ static int video_open(struct file *file) | |||
99 | lock_kernel(); | 99 | lock_kernel(); |
100 | list_for_each(list, &cx25821_devlist) | 100 | list_for_each(list, &cx25821_devlist) |
101 | { | 101 | { |
102 | h = list_entry(list, struct cx25821_dev, devlist); | 102 | h = list_entry(list, struct cx25821_dev, devlist); |
103 | 103 | ||
104 | if (h->video_dev[SRAM_CH11] && h->video_dev[SRAM_CH11]->minor == minor) | 104 | if (h->video_dev[SRAM_CH11] && h->video_dev[SRAM_CH11]->minor == minor) |
105 | { | 105 | { |
106 | dev = h; | 106 | dev = h; |
107 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 107 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
108 | } | 108 | } |
109 | } | 109 | } |
110 | 110 | ||
111 | if (NULL == dev) { | 111 | if (NULL == dev) { |
112 | unlock_kernel(); | 112 | unlock_kernel(); |
113 | return -ENODEV; | 113 | return -ENODEV; |
114 | } | 114 | } |
115 | 115 | ||
116 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); | 116 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); |
@@ -118,8 +118,8 @@ static int video_open(struct file *file) | |||
118 | /* allocate + initialize per filehandle data */ | 118 | /* allocate + initialize per filehandle data */ |
119 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); | 119 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); |
120 | if (NULL == fh) { | 120 | if (NULL == fh) { |
121 | unlock_kernel(); | 121 | unlock_kernel(); |
122 | return -ENOMEM; | 122 | return -ENOMEM; |
123 | } | 123 | } |
124 | 124 | ||
125 | file->private_data = fh; | 125 | file->private_data = fh; |
@@ -128,21 +128,21 @@ static int video_open(struct file *file) | |||
128 | fh->width = 720; | 128 | fh->width = 720; |
129 | 129 | ||
130 | if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) | 130 | if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) |
131 | fh->height = 576; | 131 | fh->height = 576; |
132 | else | 132 | else |
133 | fh->height = 480; | 133 | fh->height = 480; |
134 | 134 | ||
135 | dev->channel_opened = 10; | 135 | dev->channel_opened = 10; |
136 | fh->fmt = format_by_fourcc(V4L2_PIX_FMT_YUYV); | 136 | fh->fmt = format_by_fourcc(V4L2_PIX_FMT_YUYV); |
137 | 137 | ||
138 | v4l2_prio_open(&dev->prio,&fh->prio); | 138 | v4l2_prio_open(&dev->prio,&fh->prio); |
139 | 139 | ||
140 | videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops, | 140 | videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops, |
141 | &dev->pci->dev, &dev->slock, | 141 | &dev->pci->dev, &dev->slock, |
142 | V4L2_BUF_TYPE_VIDEO_CAPTURE, | 142 | V4L2_BUF_TYPE_VIDEO_CAPTURE, |
143 | V4L2_FIELD_INTERLACED, | 143 | V4L2_FIELD_INTERLACED, |
144 | sizeof(struct cx25821_buffer), | 144 | sizeof(struct cx25821_buffer), |
145 | fh); | 145 | fh); |
146 | 146 | ||
147 | dprintk(1, "post videobuf_queue_init()\n"); | 147 | dprintk(1, "post videobuf_queue_init()\n"); |
148 | unlock_kernel(); | 148 | unlock_kernel(); |
@@ -156,15 +156,15 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo | |||
156 | 156 | ||
157 | switch (fh->type) | 157 | switch (fh->type) |
158 | { | 158 | { |
159 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 159 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
160 | if (res_locked(fh->dev, RESOURCE_VIDEO11)) | 160 | if (res_locked(fh->dev, RESOURCE_VIDEO11)) |
161 | return -EBUSY; | 161 | return -EBUSY; |
162 | 162 | ||
163 | return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK); | 163 | return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK); |
164 | 164 | ||
165 | default: | 165 | default: |
166 | BUG(); | 166 | BUG(); |
167 | return 0; | 167 | return 0; |
168 | } | 168 | } |
169 | } | 169 | } |
170 | 170 | ||
@@ -174,21 +174,21 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait | |||
174 | struct cx25821_buffer *buf; | 174 | struct cx25821_buffer *buf; |
175 | 175 | ||
176 | if (res_check(fh, RESOURCE_VIDEO11)) { | 176 | if (res_check(fh, RESOURCE_VIDEO11)) { |
177 | /* streaming capture */ | 177 | /* streaming capture */ |
178 | if (list_empty(&fh->vidq.stream)) | 178 | if (list_empty(&fh->vidq.stream)) |
179 | return POLLERR; | 179 | return POLLERR; |
180 | buf = list_entry(fh->vidq.stream.next, | 180 | buf = list_entry(fh->vidq.stream.next, |
181 | struct cx25821_buffer, vb.stream); | 181 | struct cx25821_buffer, vb.stream); |
182 | } else { | 182 | } else { |
183 | /* read() capture */ | 183 | /* read() capture */ |
184 | buf = (struct cx25821_buffer *)fh->vidq.read_buf; | 184 | buf = (struct cx25821_buffer *)fh->vidq.read_buf; |
185 | if (NULL == buf) | 185 | if (NULL == buf) |
186 | return POLLERR; | 186 | return POLLERR; |
187 | } | 187 | } |
188 | 188 | ||
189 | poll_wait(file, &buf->vb.done, wait); | 189 | poll_wait(file, &buf->vb.done, wait); |
190 | if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR) | 190 | if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR) |
191 | return POLLIN|POLLRDNORM; | 191 | return POLLIN|POLLRDNORM; |
192 | return 0; | 192 | return 0; |
193 | } | 193 | } |
194 | 194 | ||
@@ -199,17 +199,17 @@ static int video_release(struct file *file) | |||
199 | struct cx25821_dev *dev = fh->dev; | 199 | struct cx25821_dev *dev = fh->dev; |
200 | 200 | ||
201 | //stop the risc engine and fifo | 201 | //stop the risc engine and fifo |
202 | //cx_write(channel11->dma_ctl, 0); | 202 | //cx_write(channel11->dma_ctl, 0); |
203 | 203 | ||
204 | /* stop video capture */ | 204 | /* stop video capture */ |
205 | if (res_check(fh, RESOURCE_VIDEO11)) { | 205 | if (res_check(fh, RESOURCE_VIDEO11)) { |
206 | videobuf_queue_cancel(&fh->vidq); | 206 | videobuf_queue_cancel(&fh->vidq); |
207 | res_free(dev, fh, RESOURCE_VIDEO11); | 207 | res_free(dev, fh, RESOURCE_VIDEO11); |
208 | } | 208 | } |
209 | 209 | ||
210 | if (fh->vidq.read_buf) { | 210 | if (fh->vidq.read_buf) { |
211 | buffer_release(&fh->vidq, fh->vidq.read_buf); | 211 | buffer_release(&fh->vidq, fh->vidq.read_buf); |
212 | kfree(fh->vidq.read_buf); | 212 | kfree(fh->vidq.read_buf); |
213 | } | 213 | } |
214 | 214 | ||
215 | videobuf_mmap_free(&fh->vidq); | 215 | videobuf_mmap_free(&fh->vidq); |
@@ -230,17 +230,17 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) | |||
230 | 230 | ||
231 | if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) | 231 | if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) |
232 | { | 232 | { |
233 | return -EINVAL; | 233 | return -EINVAL; |
234 | } | 234 | } |
235 | 235 | ||
236 | if (unlikely(i != fh->type)) | 236 | if (unlikely(i != fh->type)) |
237 | { | 237 | { |
238 | return -EINVAL; | 238 | return -EINVAL; |
239 | } | 239 | } |
240 | 240 | ||
241 | if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO11)))) | 241 | if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO11)))) |
242 | { | 242 | { |
243 | return -EBUSY; | 243 | return -EBUSY; |
244 | } | 244 | } |
245 | 245 | ||
246 | return videobuf_streamon(get_queue(fh)); | 246 | return videobuf_streamon(get_queue(fh)); |
@@ -253,14 +253,14 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) | |||
253 | int err, res; | 253 | int err, res; |
254 | 254 | ||
255 | if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 255 | if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
256 | return -EINVAL; | 256 | return -EINVAL; |
257 | if (i != fh->type) | 257 | if (i != fh->type) |
258 | return -EINVAL; | 258 | return -EINVAL; |
259 | 259 | ||
260 | res = get_resource(fh, RESOURCE_VIDEO11); | 260 | res = get_resource(fh, RESOURCE_VIDEO11); |
261 | err = videobuf_streamoff(get_queue(fh)); | 261 | err = videobuf_streamoff(get_queue(fh)); |
262 | if (err < 0) | 262 | if (err < 0) |
263 | return err; | 263 | return err; |
264 | res_free(dev, fh, res); | 264 | res_free(dev, fh, res); |
265 | return 0; | 265 | return 0; |
266 | } | 266 | } |
@@ -272,18 +272,18 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma | |||
272 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 272 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
273 | int err; | 273 | int err; |
274 | 274 | ||
275 | if (fh) | 275 | if (fh) |
276 | { | 276 | { |
277 | err = v4l2_prio_check(&dev->prio, &fh->prio); | 277 | err = v4l2_prio_check(&dev->prio, &fh->prio); |
278 | if (0 != err) | 278 | if (0 != err) |
279 | return err; | 279 | return err; |
280 | } | 280 | } |
281 | 281 | ||
282 | dprintk(2, "%s()\n", __func__); | 282 | dprintk(2, "%s()\n", __func__); |
283 | err = vidioc_try_fmt_vid_cap(file, priv, f); | 283 | err = vidioc_try_fmt_vid_cap(file, priv, f); |
284 | 284 | ||
285 | if (0 != err) | 285 | if (0 != err) |
286 | return err; | 286 | return err; |
287 | fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); | 287 | fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); |
288 | fh->width = f->fmt.pix.width; | 288 | fh->width = f->fmt.pix.width; |
289 | fh->height = f->fmt.pix.height; | 289 | fh->height = f->fmt.pix.height; |
@@ -293,30 +293,30 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma | |||
293 | return 0; | 293 | return 0; |
294 | } | 294 | } |
295 | 295 | ||
296 | static long video_ioctl_upstream11(struct file *file, unsigned int cmd, unsigned long arg) | 296 | static long video_ioctl_upstream11(struct file *file, unsigned int cmd, unsigned long arg) |
297 | { | 297 | { |
298 | struct cx25821_fh *fh = file->private_data; | 298 | struct cx25821_fh *fh = file->private_data; |
299 | struct cx25821_dev *dev = fh->dev; | 299 | struct cx25821_dev *dev = fh->dev; |
300 | int command = 0; | 300 | int command = 0; |
301 | struct upstream_user_struct *data_from_user; | 301 | struct upstream_user_struct *data_from_user; |
302 | 302 | ||
303 | 303 | ||
304 | data_from_user = (struct upstream_user_struct *)arg; | 304 | data_from_user = (struct upstream_user_struct *)arg; |
305 | 305 | ||
306 | if( !data_from_user ) | 306 | if( !data_from_user ) |
307 | { | 307 | { |
308 | printk("cx25821 in %s(): Upstream data is INVALID. Returning.\n", __func__); | 308 | printk("cx25821 in %s(): Upstream data is INVALID. Returning.\n", __func__); |
309 | return 0; | 309 | return 0; |
310 | } | 310 | } |
311 | 311 | ||
312 | command = data_from_user->command; | 312 | command = data_from_user->command; |
313 | 313 | ||
314 | if( command != UPSTREAM_START_AUDIO && command != UPSTREAM_STOP_AUDIO ) | 314 | if( command != UPSTREAM_START_AUDIO && command != UPSTREAM_STOP_AUDIO ) |
315 | { | 315 | { |
316 | return 0; | 316 | return 0; |
317 | } | 317 | } |
318 | 318 | ||
319 | 319 | ||
320 | dev->input_filename = data_from_user->input_filename; | 320 | dev->input_filename = data_from_user->input_filename; |
321 | dev->input_audiofilename = data_from_user->input_filename; | 321 | dev->input_audiofilename = data_from_user->input_filename; |
322 | dev->vid_stdname = data_from_user->vid_stdname; | 322 | dev->vid_stdname = data_from_user->vid_stdname; |
@@ -324,18 +324,18 @@ static long video_ioctl_upstream11(struct file *file, unsigned int cmd, unsigned | |||
324 | dev->channel_select = data_from_user->channel_select; | 324 | dev->channel_select = data_from_user->channel_select; |
325 | dev->command = data_from_user->command; | 325 | dev->command = data_from_user->command; |
326 | 326 | ||
327 | 327 | ||
328 | switch(command) | 328 | switch(command) |
329 | { | 329 | { |
330 | case UPSTREAM_START_AUDIO: | 330 | case UPSTREAM_START_AUDIO: |
331 | cx25821_start_upstream_audio(dev, data_from_user); | 331 | cx25821_start_upstream_audio(dev, data_from_user); |
332 | break; | 332 | break; |
333 | 333 | ||
334 | case UPSTREAM_STOP_AUDIO: | 334 | case UPSTREAM_STOP_AUDIO: |
335 | cx25821_stop_upstream_audio(dev); | 335 | cx25821_stop_upstream_audio(dev); |
336 | break; | 336 | break; |
337 | } | 337 | } |
338 | 338 | ||
339 | return 0; | 339 | return 0; |
340 | } | 340 | } |
341 | 341 | ||
@@ -366,11 +366,11 @@ static int vidioc_s_ctrl(struct file *file, void *priv, | |||
366 | struct cx25821_dev *dev = fh->dev; | 366 | struct cx25821_dev *dev = fh->dev; |
367 | int err; | 367 | int err; |
368 | 368 | ||
369 | if (fh) | 369 | if (fh) |
370 | { | 370 | { |
371 | err = v4l2_prio_check(&dev->prio, &fh->prio); | 371 | err = v4l2_prio_check(&dev->prio, &fh->prio); |
372 | if (0 != err) | 372 | if (0 != err) |
373 | return err; | 373 | return err; |
374 | } | 374 | } |
375 | return 0; | 375 | return 0; |
376 | } | 376 | } |
@@ -382,7 +382,7 @@ static const struct v4l2_file_operations video_fops = { | |||
382 | .read = video_read, | 382 | .read = video_read, |
383 | .poll = video_poll, | 383 | .poll = video_poll, |
384 | .mmap = video_mmap, | 384 | .mmap = video_mmap, |
385 | .ioctl = video_ioctl_upstream11, | 385 | .ioctl = video_ioctl_upstream11, |
386 | }; | 386 | }; |
387 | 387 | ||
388 | static const struct v4l2_ioctl_ops video_ioctl_ops = { | 388 | static const struct v4l2_ioctl_ops video_ioctl_ops = { |
diff --git a/drivers/staging/cx25821/cx25821-cards.c b/drivers/staging/cx25821/cx25821-cards.c index eaaa56707c1..f8f3c327916 100644 --- a/drivers/staging/cx25821/cx25821-cards.c +++ b/drivers/staging/cx25821/cx25821-cards.c | |||
@@ -30,12 +30,12 @@ | |||
30 | #include "cx25821.h" | 30 | #include "cx25821.h" |
31 | #include "tuner-xc2028.h" | 31 | #include "tuner-xc2028.h" |
32 | 32 | ||
33 | // board config info | 33 | // board config info |
34 | 34 | ||
35 | struct cx25821_board cx25821_boards[] = { | 35 | struct cx25821_board cx25821_boards[] = { |
36 | [UNKNOWN_BOARD] = { | 36 | [UNKNOWN_BOARD] = { |
37 | .name = "UNKNOWN/GENERIC", | 37 | .name = "UNKNOWN/GENERIC", |
38 | // Ensure safe default for unknown boards | 38 | // Ensure safe default for unknown boards |
39 | .clk_freq = 0, | 39 | .clk_freq = 0, |
40 | }, | 40 | }, |
41 | 41 | ||
@@ -43,8 +43,8 @@ struct cx25821_board cx25821_boards[] = { | |||
43 | .name = "CX25821", | 43 | .name = "CX25821", |
44 | .portb = CX25821_RAW, | 44 | .portb = CX25821_RAW, |
45 | .portc = CX25821_264, | 45 | .portc = CX25821_264, |
46 | .input[0].type = CX25821_VMUX_COMPOSITE, | 46 | .input[0].type = CX25821_VMUX_COMPOSITE, |
47 | }, | 47 | }, |
48 | 48 | ||
49 | }; | 49 | }; |
50 | 50 | ||
@@ -63,7 +63,7 @@ void cx25821_card_setup(struct cx25821_dev *dev) | |||
63 | { | 63 | { |
64 | static u8 eeprom[256]; | 64 | static u8 eeprom[256]; |
65 | 65 | ||
66 | if (dev->i2c_bus[0].i2c_rc == 0) | 66 | if (dev->i2c_bus[0].i2c_rc == 0) |
67 | { | 67 | { |
68 | dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1; | 68 | dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1; |
69 | tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom, sizeof(eeprom)); | 69 | tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom, sizeof(eeprom)); |
diff --git a/drivers/staging/cx25821/cx25821-core.c b/drivers/staging/cx25821/cx25821-core.c index adca7af1e50..6f2970c1d25 100644 --- a/drivers/staging/cx25821/cx25821-core.c +++ b/drivers/staging/cx25821/cx25821-core.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the Conexant CX25821 PCIe bridge | 2 | * Driver for the Conexant CX25821 PCIe bridge |
3 | * | 3 | * |
4 | * Copyright (C) 2009 Conexant Systems Inc. | 4 | * Copyright (C) 2009 Conexant Systems Inc. |
5 | * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com> | 5 | * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com> |
6 | * Based on Steven Toth <stoth@linuxtv.org> cx23885 driver | 6 | * Based on Steven Toth <stoth@linuxtv.org> cx23885 driver |
7 | * | 7 | * |
@@ -49,271 +49,271 @@ LIST_HEAD(cx25821_devlist); | |||
49 | 49 | ||
50 | struct sram_channel cx25821_sram_channels[] = { | 50 | struct sram_channel cx25821_sram_channels[] = { |
51 | [SRAM_CH00] = { | 51 | [SRAM_CH00] = { |
52 | .i = SRAM_CH00, | 52 | .i = SRAM_CH00, |
53 | .name = "VID A", | 53 | .name = "VID A", |
54 | .cmds_start = VID_A_DOWN_CMDS, | 54 | .cmds_start = VID_A_DOWN_CMDS, |
55 | .ctrl_start = VID_A_IQ, | 55 | .ctrl_start = VID_A_IQ, |
56 | .cdt = VID_A_CDT, | 56 | .cdt = VID_A_CDT, |
57 | .fifo_start = VID_A_DOWN_CLUSTER_1, | 57 | .fifo_start = VID_A_DOWN_CLUSTER_1, |
58 | .fifo_size = (VID_CLUSTER_SIZE<<2), | 58 | .fifo_size = (VID_CLUSTER_SIZE<<2), |
59 | .ptr1_reg = DMA1_PTR1, | 59 | .ptr1_reg = DMA1_PTR1, |
60 | .ptr2_reg = DMA1_PTR2, | 60 | .ptr2_reg = DMA1_PTR2, |
61 | .cnt1_reg = DMA1_CNT1, | 61 | .cnt1_reg = DMA1_CNT1, |
62 | .cnt2_reg = DMA1_CNT2, | 62 | .cnt2_reg = DMA1_CNT2, |
63 | .int_msk = VID_A_INT_MSK, | 63 | .int_msk = VID_A_INT_MSK, |
64 | .int_stat = VID_A_INT_STAT, | 64 | .int_stat = VID_A_INT_STAT, |
65 | .int_mstat = VID_A_INT_MSTAT, | 65 | .int_mstat = VID_A_INT_MSTAT, |
66 | .dma_ctl = VID_DST_A_DMA_CTL, | 66 | .dma_ctl = VID_DST_A_DMA_CTL, |
67 | .gpcnt_ctl = VID_DST_A_GPCNT_CTL, | 67 | .gpcnt_ctl = VID_DST_A_GPCNT_CTL, |
68 | .gpcnt = VID_DST_A_GPCNT, | 68 | .gpcnt = VID_DST_A_GPCNT, |
69 | .vip_ctl = VID_DST_A_VIP_CTL, | 69 | .vip_ctl = VID_DST_A_VIP_CTL, |
70 | .pix_frmt = VID_DST_A_PIX_FRMT, | 70 | .pix_frmt = VID_DST_A_PIX_FRMT, |
71 | }, | 71 | }, |
72 | 72 | ||
73 | [SRAM_CH01] = { | 73 | [SRAM_CH01] = { |
74 | .i = SRAM_CH01, | 74 | .i = SRAM_CH01, |
75 | .name = "VID B", | 75 | .name = "VID B", |
76 | .cmds_start = VID_B_DOWN_CMDS, | 76 | .cmds_start = VID_B_DOWN_CMDS, |
77 | .ctrl_start = VID_B_IQ, | 77 | .ctrl_start = VID_B_IQ, |
78 | .cdt = VID_B_CDT, | 78 | .cdt = VID_B_CDT, |
79 | .fifo_start = VID_B_DOWN_CLUSTER_1, | 79 | .fifo_start = VID_B_DOWN_CLUSTER_1, |
80 | .fifo_size = (VID_CLUSTER_SIZE<<2), | 80 | .fifo_size = (VID_CLUSTER_SIZE<<2), |
81 | .ptr1_reg = DMA2_PTR1, | 81 | .ptr1_reg = DMA2_PTR1, |
82 | .ptr2_reg = DMA2_PTR2, | 82 | .ptr2_reg = DMA2_PTR2, |
83 | .cnt1_reg = DMA2_CNT1, | 83 | .cnt1_reg = DMA2_CNT1, |
84 | .cnt2_reg = DMA2_CNT2, | 84 | .cnt2_reg = DMA2_CNT2, |
85 | .int_msk = VID_B_INT_MSK, | 85 | .int_msk = VID_B_INT_MSK, |
86 | .int_stat = VID_B_INT_STAT, | 86 | .int_stat = VID_B_INT_STAT, |
87 | .int_mstat = VID_B_INT_MSTAT, | 87 | .int_mstat = VID_B_INT_MSTAT, |
88 | .dma_ctl = VID_DST_B_DMA_CTL, | 88 | .dma_ctl = VID_DST_B_DMA_CTL, |
89 | .gpcnt_ctl = VID_DST_B_GPCNT_CTL, | 89 | .gpcnt_ctl = VID_DST_B_GPCNT_CTL, |
90 | .gpcnt = VID_DST_B_GPCNT, | 90 | .gpcnt = VID_DST_B_GPCNT, |
91 | .vip_ctl = VID_DST_B_VIP_CTL, | 91 | .vip_ctl = VID_DST_B_VIP_CTL, |
92 | .pix_frmt = VID_DST_B_PIX_FRMT, | 92 | .pix_frmt = VID_DST_B_PIX_FRMT, |
93 | }, | 93 | }, |
94 | 94 | ||
95 | [SRAM_CH02] = { | 95 | [SRAM_CH02] = { |
96 | .i = SRAM_CH02, | 96 | .i = SRAM_CH02, |
97 | .name = "VID C", | 97 | .name = "VID C", |
98 | .cmds_start = VID_C_DOWN_CMDS, | 98 | .cmds_start = VID_C_DOWN_CMDS, |
99 | .ctrl_start = VID_C_IQ, | 99 | .ctrl_start = VID_C_IQ, |
100 | .cdt = VID_C_CDT, | 100 | .cdt = VID_C_CDT, |
101 | .fifo_start = VID_C_DOWN_CLUSTER_1, | 101 | .fifo_start = VID_C_DOWN_CLUSTER_1, |
102 | .fifo_size = (VID_CLUSTER_SIZE<<2), | 102 | .fifo_size = (VID_CLUSTER_SIZE<<2), |
103 | .ptr1_reg = DMA3_PTR1, | 103 | .ptr1_reg = DMA3_PTR1, |
104 | .ptr2_reg = DMA3_PTR2, | 104 | .ptr2_reg = DMA3_PTR2, |
105 | .cnt1_reg = DMA3_CNT1, | 105 | .cnt1_reg = DMA3_CNT1, |
106 | .cnt2_reg = DMA3_CNT2, | 106 | .cnt2_reg = DMA3_CNT2, |
107 | .int_msk = VID_C_INT_MSK, | 107 | .int_msk = VID_C_INT_MSK, |
108 | .int_stat = VID_C_INT_STAT, | 108 | .int_stat = VID_C_INT_STAT, |
109 | .int_mstat = VID_C_INT_MSTAT, | 109 | .int_mstat = VID_C_INT_MSTAT, |
110 | .dma_ctl = VID_DST_C_DMA_CTL, | 110 | .dma_ctl = VID_DST_C_DMA_CTL, |
111 | .gpcnt_ctl = VID_DST_C_GPCNT_CTL, | 111 | .gpcnt_ctl = VID_DST_C_GPCNT_CTL, |
112 | .gpcnt = VID_DST_C_GPCNT, | 112 | .gpcnt = VID_DST_C_GPCNT, |
113 | .vip_ctl = VID_DST_C_VIP_CTL, | 113 | .vip_ctl = VID_DST_C_VIP_CTL, |
114 | .pix_frmt = VID_DST_C_PIX_FRMT, | 114 | .pix_frmt = VID_DST_C_PIX_FRMT, |
115 | }, | 115 | }, |
116 | 116 | ||
117 | [SRAM_CH03] = { | 117 | [SRAM_CH03] = { |
118 | .i = SRAM_CH03, | 118 | .i = SRAM_CH03, |
119 | .name = "VID D", | 119 | .name = "VID D", |
120 | .cmds_start = VID_D_DOWN_CMDS, | 120 | .cmds_start = VID_D_DOWN_CMDS, |
121 | .ctrl_start = VID_D_IQ, | 121 | .ctrl_start = VID_D_IQ, |
122 | .cdt = VID_D_CDT, | 122 | .cdt = VID_D_CDT, |
123 | .fifo_start = VID_D_DOWN_CLUSTER_1, | 123 | .fifo_start = VID_D_DOWN_CLUSTER_1, |
124 | .fifo_size = (VID_CLUSTER_SIZE<<2), | 124 | .fifo_size = (VID_CLUSTER_SIZE<<2), |
125 | .ptr1_reg = DMA4_PTR1, | 125 | .ptr1_reg = DMA4_PTR1, |
126 | .ptr2_reg = DMA4_PTR2, | 126 | .ptr2_reg = DMA4_PTR2, |
127 | .cnt1_reg = DMA4_CNT1, | 127 | .cnt1_reg = DMA4_CNT1, |
128 | .cnt2_reg = DMA4_CNT2, | 128 | .cnt2_reg = DMA4_CNT2, |
129 | .int_msk = VID_D_INT_MSK, | 129 | .int_msk = VID_D_INT_MSK, |
130 | .int_stat = VID_D_INT_STAT, | 130 | .int_stat = VID_D_INT_STAT, |
131 | .int_mstat = VID_D_INT_MSTAT, | 131 | .int_mstat = VID_D_INT_MSTAT, |
132 | .dma_ctl = VID_DST_D_DMA_CTL, | 132 | .dma_ctl = VID_DST_D_DMA_CTL, |
133 | .gpcnt_ctl = VID_DST_D_GPCNT_CTL, | 133 | .gpcnt_ctl = VID_DST_D_GPCNT_CTL, |
134 | .gpcnt = VID_DST_D_GPCNT, | 134 | .gpcnt = VID_DST_D_GPCNT, |
135 | .vip_ctl = VID_DST_D_VIP_CTL, | 135 | .vip_ctl = VID_DST_D_VIP_CTL, |
136 | .pix_frmt = VID_DST_D_PIX_FRMT, | 136 | .pix_frmt = VID_DST_D_PIX_FRMT, |
137 | }, | 137 | }, |
138 | 138 | ||
139 | [SRAM_CH04] = { | 139 | [SRAM_CH04] = { |
140 | .i = SRAM_CH04, | 140 | .i = SRAM_CH04, |
141 | .name = "VID E", | 141 | .name = "VID E", |
142 | .cmds_start = VID_E_DOWN_CMDS, | 142 | .cmds_start = VID_E_DOWN_CMDS, |
143 | .ctrl_start = VID_E_IQ, | 143 | .ctrl_start = VID_E_IQ, |
144 | .cdt = VID_E_CDT, | 144 | .cdt = VID_E_CDT, |
145 | .fifo_start = VID_E_DOWN_CLUSTER_1, | 145 | .fifo_start = VID_E_DOWN_CLUSTER_1, |
146 | .fifo_size = (VID_CLUSTER_SIZE<<2), | 146 | .fifo_size = (VID_CLUSTER_SIZE<<2), |
147 | .ptr1_reg = DMA5_PTR1, | 147 | .ptr1_reg = DMA5_PTR1, |
148 | .ptr2_reg = DMA5_PTR2, | 148 | .ptr2_reg = DMA5_PTR2, |
149 | .cnt1_reg = DMA5_CNT1, | 149 | .cnt1_reg = DMA5_CNT1, |
150 | .cnt2_reg = DMA5_CNT2, | 150 | .cnt2_reg = DMA5_CNT2, |
151 | .int_msk = VID_E_INT_MSK, | 151 | .int_msk = VID_E_INT_MSK, |
152 | .int_stat = VID_E_INT_STAT, | 152 | .int_stat = VID_E_INT_STAT, |
153 | .int_mstat = VID_E_INT_MSTAT, | 153 | .int_mstat = VID_E_INT_MSTAT, |
154 | .dma_ctl = VID_DST_E_DMA_CTL, | 154 | .dma_ctl = VID_DST_E_DMA_CTL, |
155 | .gpcnt_ctl = VID_DST_E_GPCNT_CTL, | 155 | .gpcnt_ctl = VID_DST_E_GPCNT_CTL, |
156 | .gpcnt = VID_DST_E_GPCNT, | 156 | .gpcnt = VID_DST_E_GPCNT, |
157 | .vip_ctl = VID_DST_E_VIP_CTL, | 157 | .vip_ctl = VID_DST_E_VIP_CTL, |
158 | .pix_frmt = VID_DST_E_PIX_FRMT, | 158 | .pix_frmt = VID_DST_E_PIX_FRMT, |
159 | }, | 159 | }, |
160 | 160 | ||
161 | [SRAM_CH05] = { | 161 | [SRAM_CH05] = { |
162 | .i = SRAM_CH05, | 162 | .i = SRAM_CH05, |
163 | .name = "VID F", | 163 | .name = "VID F", |
164 | .cmds_start = VID_F_DOWN_CMDS, | 164 | .cmds_start = VID_F_DOWN_CMDS, |
165 | .ctrl_start = VID_F_IQ, | 165 | .ctrl_start = VID_F_IQ, |
166 | .cdt = VID_F_CDT, | 166 | .cdt = VID_F_CDT, |
167 | .fifo_start = VID_F_DOWN_CLUSTER_1, | 167 | .fifo_start = VID_F_DOWN_CLUSTER_1, |
168 | .fifo_size = (VID_CLUSTER_SIZE<<2), | 168 | .fifo_size = (VID_CLUSTER_SIZE<<2), |
169 | .ptr1_reg = DMA6_PTR1, | 169 | .ptr1_reg = DMA6_PTR1, |
170 | .ptr2_reg = DMA6_PTR2, | 170 | .ptr2_reg = DMA6_PTR2, |
171 | .cnt1_reg = DMA6_CNT1, | 171 | .cnt1_reg = DMA6_CNT1, |
172 | .cnt2_reg = DMA6_CNT2, | 172 | .cnt2_reg = DMA6_CNT2, |
173 | .int_msk = VID_F_INT_MSK, | 173 | .int_msk = VID_F_INT_MSK, |
174 | .int_stat = VID_F_INT_STAT, | 174 | .int_stat = VID_F_INT_STAT, |
175 | .int_mstat = VID_F_INT_MSTAT, | 175 | .int_mstat = VID_F_INT_MSTAT, |
176 | .dma_ctl = VID_DST_F_DMA_CTL, | 176 | .dma_ctl = VID_DST_F_DMA_CTL, |
177 | .gpcnt_ctl = VID_DST_F_GPCNT_CTL, | 177 | .gpcnt_ctl = VID_DST_F_GPCNT_CTL, |
178 | .gpcnt = VID_DST_F_GPCNT, | 178 | .gpcnt = VID_DST_F_GPCNT, |
179 | .vip_ctl = VID_DST_F_VIP_CTL, | 179 | .vip_ctl = VID_DST_F_VIP_CTL, |
180 | .pix_frmt = VID_DST_F_PIX_FRMT, | 180 | .pix_frmt = VID_DST_F_PIX_FRMT, |
181 | }, | 181 | }, |
182 | 182 | ||
183 | [SRAM_CH06] = { | 183 | [SRAM_CH06] = { |
184 | .i = SRAM_CH06, | 184 | .i = SRAM_CH06, |
185 | .name = "VID G", | 185 | .name = "VID G", |
186 | .cmds_start = VID_G_DOWN_CMDS, | 186 | .cmds_start = VID_G_DOWN_CMDS, |
187 | .ctrl_start = VID_G_IQ, | 187 | .ctrl_start = VID_G_IQ, |
188 | .cdt = VID_G_CDT, | 188 | .cdt = VID_G_CDT, |
189 | .fifo_start = VID_G_DOWN_CLUSTER_1, | 189 | .fifo_start = VID_G_DOWN_CLUSTER_1, |
190 | .fifo_size = (VID_CLUSTER_SIZE<<2), | 190 | .fifo_size = (VID_CLUSTER_SIZE<<2), |
191 | .ptr1_reg = DMA7_PTR1, | 191 | .ptr1_reg = DMA7_PTR1, |
192 | .ptr2_reg = DMA7_PTR2, | 192 | .ptr2_reg = DMA7_PTR2, |
193 | .cnt1_reg = DMA7_CNT1, | 193 | .cnt1_reg = DMA7_CNT1, |
194 | .cnt2_reg = DMA7_CNT2, | 194 | .cnt2_reg = DMA7_CNT2, |
195 | .int_msk = VID_G_INT_MSK, | 195 | .int_msk = VID_G_INT_MSK, |
196 | .int_stat = VID_G_INT_STAT, | 196 | .int_stat = VID_G_INT_STAT, |
197 | .int_mstat = VID_G_INT_MSTAT, | 197 | .int_mstat = VID_G_INT_MSTAT, |
198 | .dma_ctl = VID_DST_G_DMA_CTL, | 198 | .dma_ctl = VID_DST_G_DMA_CTL, |
199 | .gpcnt_ctl = VID_DST_G_GPCNT_CTL, | 199 | .gpcnt_ctl = VID_DST_G_GPCNT_CTL, |
200 | .gpcnt = VID_DST_G_GPCNT, | 200 | .gpcnt = VID_DST_G_GPCNT, |
201 | .vip_ctl = VID_DST_G_VIP_CTL, | 201 | .vip_ctl = VID_DST_G_VIP_CTL, |
202 | .pix_frmt = VID_DST_G_PIX_FRMT, | 202 | .pix_frmt = VID_DST_G_PIX_FRMT, |
203 | }, | 203 | }, |
204 | 204 | ||
205 | [SRAM_CH07] = { | 205 | [SRAM_CH07] = { |
206 | .i = SRAM_CH07, | 206 | .i = SRAM_CH07, |
207 | .name = "VID H", | 207 | .name = "VID H", |
208 | .cmds_start = VID_H_DOWN_CMDS, | 208 | .cmds_start = VID_H_DOWN_CMDS, |
209 | .ctrl_start = VID_H_IQ, | 209 | .ctrl_start = VID_H_IQ, |
210 | .cdt = VID_H_CDT, | 210 | .cdt = VID_H_CDT, |
211 | .fifo_start = VID_H_DOWN_CLUSTER_1, | 211 | .fifo_start = VID_H_DOWN_CLUSTER_1, |
212 | .fifo_size = (VID_CLUSTER_SIZE<<2), | 212 | .fifo_size = (VID_CLUSTER_SIZE<<2), |
213 | .ptr1_reg = DMA8_PTR1, | 213 | .ptr1_reg = DMA8_PTR1, |
214 | .ptr2_reg = DMA8_PTR2, | 214 | .ptr2_reg = DMA8_PTR2, |
215 | .cnt1_reg = DMA8_CNT1, | 215 | .cnt1_reg = DMA8_CNT1, |
216 | .cnt2_reg = DMA8_CNT2, | 216 | .cnt2_reg = DMA8_CNT2, |
217 | .int_msk = VID_H_INT_MSK, | 217 | .int_msk = VID_H_INT_MSK, |
218 | .int_stat = VID_H_INT_STAT, | 218 | .int_stat = VID_H_INT_STAT, |
219 | .int_mstat = VID_H_INT_MSTAT, | 219 | .int_mstat = VID_H_INT_MSTAT, |
220 | .dma_ctl = VID_DST_H_DMA_CTL, | 220 | .dma_ctl = VID_DST_H_DMA_CTL, |
221 | .gpcnt_ctl = VID_DST_H_GPCNT_CTL, | 221 | .gpcnt_ctl = VID_DST_H_GPCNT_CTL, |
222 | .gpcnt = VID_DST_H_GPCNT, | 222 | .gpcnt = VID_DST_H_GPCNT, |
223 | .vip_ctl = VID_DST_H_VIP_CTL, | 223 | .vip_ctl = VID_DST_H_VIP_CTL, |
224 | .pix_frmt = VID_DST_H_PIX_FRMT, | 224 | .pix_frmt = VID_DST_H_PIX_FRMT, |
225 | }, | 225 | }, |
226 | 226 | ||
227 | [SRAM_CH08] = { | 227 | [SRAM_CH08] = { |
228 | .name = "audio from", | 228 | .name = "audio from", |
229 | .cmds_start = AUD_A_DOWN_CMDS, | 229 | .cmds_start = AUD_A_DOWN_CMDS, |
230 | .ctrl_start = AUD_A_IQ, | 230 | .ctrl_start = AUD_A_IQ, |
231 | .cdt = AUD_A_CDT, | 231 | .cdt = AUD_A_CDT, |
232 | .fifo_start = AUD_A_DOWN_CLUSTER_1, | 232 | .fifo_start = AUD_A_DOWN_CLUSTER_1, |
233 | .fifo_size = AUDIO_CLUSTER_SIZE * 3, | 233 | .fifo_size = AUDIO_CLUSTER_SIZE * 3, |
234 | .ptr1_reg = DMA17_PTR1, | 234 | .ptr1_reg = DMA17_PTR1, |
235 | .ptr2_reg = DMA17_PTR2, | 235 | .ptr2_reg = DMA17_PTR2, |
236 | .cnt1_reg = DMA17_CNT1, | 236 | .cnt1_reg = DMA17_CNT1, |
237 | .cnt2_reg = DMA17_CNT2, | 237 | .cnt2_reg = DMA17_CNT2, |
238 | }, | 238 | }, |
239 | 239 | ||
240 | [SRAM_CH09] = { | 240 | [SRAM_CH09] = { |
241 | .i = SRAM_CH09, | 241 | .i = SRAM_CH09, |
242 | .name = "VID Upstream I", | 242 | .name = "VID Upstream I", |
243 | .cmds_start = VID_I_UP_CMDS, | 243 | .cmds_start = VID_I_UP_CMDS, |
244 | .ctrl_start = VID_I_IQ, | 244 | .ctrl_start = VID_I_IQ, |
245 | .cdt = VID_I_CDT, | 245 | .cdt = VID_I_CDT, |
246 | .fifo_start = VID_I_UP_CLUSTER_1, | 246 | .fifo_start = VID_I_UP_CLUSTER_1, |
247 | .fifo_size = (VID_CLUSTER_SIZE<<2), | 247 | .fifo_size = (VID_CLUSTER_SIZE<<2), |
248 | .ptr1_reg = DMA15_PTR1, | 248 | .ptr1_reg = DMA15_PTR1, |
249 | .ptr2_reg = DMA15_PTR2, | 249 | .ptr2_reg = DMA15_PTR2, |
250 | .cnt1_reg = DMA15_CNT1, | 250 | .cnt1_reg = DMA15_CNT1, |
251 | .cnt2_reg = DMA15_CNT2, | 251 | .cnt2_reg = DMA15_CNT2, |
252 | .int_msk = VID_I_INT_MSK, | 252 | .int_msk = VID_I_INT_MSK, |
253 | .int_stat = VID_I_INT_STAT, | 253 | .int_stat = VID_I_INT_STAT, |
254 | .int_mstat = VID_I_INT_MSTAT, | 254 | .int_mstat = VID_I_INT_MSTAT, |
255 | .dma_ctl = VID_SRC_I_DMA_CTL, | 255 | .dma_ctl = VID_SRC_I_DMA_CTL, |
256 | .gpcnt_ctl = VID_SRC_I_GPCNT_CTL, | 256 | .gpcnt_ctl = VID_SRC_I_GPCNT_CTL, |
257 | .gpcnt = VID_SRC_I_GPCNT, | 257 | .gpcnt = VID_SRC_I_GPCNT, |
258 | 258 | ||
259 | .vid_fmt_ctl = VID_SRC_I_FMT_CTL, | 259 | .vid_fmt_ctl = VID_SRC_I_FMT_CTL, |
260 | .vid_active_ctl1= VID_SRC_I_ACTIVE_CTL1, | 260 | .vid_active_ctl1= VID_SRC_I_ACTIVE_CTL1, |
261 | .vid_active_ctl2= VID_SRC_I_ACTIVE_CTL2, | 261 | .vid_active_ctl2= VID_SRC_I_ACTIVE_CTL2, |
262 | .vid_cdt_size = VID_SRC_I_CDT_SZ, | 262 | .vid_cdt_size = VID_SRC_I_CDT_SZ, |
263 | .irq_bit = 8, | 263 | .irq_bit = 8, |
264 | }, | 264 | }, |
265 | 265 | ||
266 | [SRAM_CH10] = { | 266 | [SRAM_CH10] = { |
267 | .i = SRAM_CH10, | 267 | .i = SRAM_CH10, |
268 | .name = "VID Upstream J", | 268 | .name = "VID Upstream J", |
269 | .cmds_start = VID_J_UP_CMDS, | 269 | .cmds_start = VID_J_UP_CMDS, |
270 | .ctrl_start = VID_J_IQ, | 270 | .ctrl_start = VID_J_IQ, |
271 | .cdt = VID_J_CDT, | 271 | .cdt = VID_J_CDT, |
272 | .fifo_start = VID_J_UP_CLUSTER_1, | 272 | .fifo_start = VID_J_UP_CLUSTER_1, |
273 | .fifo_size = (VID_CLUSTER_SIZE<<2), | 273 | .fifo_size = (VID_CLUSTER_SIZE<<2), |
274 | .ptr1_reg = DMA16_PTR1, | 274 | .ptr1_reg = DMA16_PTR1, |
275 | .ptr2_reg = DMA16_PTR2, | 275 | .ptr2_reg = DMA16_PTR2, |
276 | .cnt1_reg = DMA16_CNT1, | 276 | .cnt1_reg = DMA16_CNT1, |
277 | .cnt2_reg = DMA16_CNT2, | 277 | .cnt2_reg = DMA16_CNT2, |
278 | .int_msk = VID_J_INT_MSK, | 278 | .int_msk = VID_J_INT_MSK, |
279 | .int_stat = VID_J_INT_STAT, | 279 | .int_stat = VID_J_INT_STAT, |
280 | .int_mstat = VID_J_INT_MSTAT, | 280 | .int_mstat = VID_J_INT_MSTAT, |
281 | .dma_ctl = VID_SRC_J_DMA_CTL, | 281 | .dma_ctl = VID_SRC_J_DMA_CTL, |
282 | .gpcnt_ctl = VID_SRC_J_GPCNT_CTL, | 282 | .gpcnt_ctl = VID_SRC_J_GPCNT_CTL, |
283 | .gpcnt = VID_SRC_J_GPCNT, | 283 | .gpcnt = VID_SRC_J_GPCNT, |
284 | 284 | ||
285 | .vid_fmt_ctl = VID_SRC_J_FMT_CTL, | 285 | .vid_fmt_ctl = VID_SRC_J_FMT_CTL, |
286 | .vid_active_ctl1= VID_SRC_J_ACTIVE_CTL1, | 286 | .vid_active_ctl1= VID_SRC_J_ACTIVE_CTL1, |
287 | .vid_active_ctl2= VID_SRC_J_ACTIVE_CTL2, | 287 | .vid_active_ctl2= VID_SRC_J_ACTIVE_CTL2, |
288 | .vid_cdt_size = VID_SRC_J_CDT_SZ, | 288 | .vid_cdt_size = VID_SRC_J_CDT_SZ, |
289 | .irq_bit = 9, | 289 | .irq_bit = 9, |
290 | }, | 290 | }, |
291 | 291 | ||
292 | 292 | ||
293 | [SRAM_CH11] = { | 293 | [SRAM_CH11] = { |
294 | .i = SRAM_CH11, | 294 | .i = SRAM_CH11, |
295 | .name = "Audio Upstream Channel B", | 295 | .name = "Audio Upstream Channel B", |
296 | .cmds_start = AUD_B_UP_CMDS, | 296 | .cmds_start = AUD_B_UP_CMDS, |
297 | .ctrl_start = AUD_B_IQ, | 297 | .ctrl_start = AUD_B_IQ, |
298 | .cdt = AUD_B_CDT, | 298 | .cdt = AUD_B_CDT, |
299 | .fifo_start = AUD_B_UP_CLUSTER_1, | 299 | .fifo_start = AUD_B_UP_CLUSTER_1, |
300 | .fifo_size = (AUDIO_CLUSTER_SIZE*3), | 300 | .fifo_size = (AUDIO_CLUSTER_SIZE*3), |
301 | .ptr1_reg = DMA22_PTR1, | 301 | .ptr1_reg = DMA22_PTR1, |
302 | .ptr2_reg = DMA22_PTR2, | 302 | .ptr2_reg = DMA22_PTR2, |
303 | .cnt1_reg = DMA22_CNT1, | 303 | .cnt1_reg = DMA22_CNT1, |
304 | .cnt2_reg = DMA22_CNT2, | 304 | .cnt2_reg = DMA22_CNT2, |
305 | .int_msk = AUD_B_INT_MSK, | 305 | .int_msk = AUD_B_INT_MSK, |
306 | .int_stat = AUD_B_INT_STAT, | 306 | .int_stat = AUD_B_INT_STAT, |
307 | .int_mstat = AUD_B_INT_MSTAT, | 307 | .int_mstat = AUD_B_INT_MSTAT, |
308 | .dma_ctl = AUD_INT_DMA_CTL, | 308 | .dma_ctl = AUD_INT_DMA_CTL, |
309 | .gpcnt_ctl = AUD_B_GPCNT_CTL, | 309 | .gpcnt_ctl = AUD_B_GPCNT_CTL, |
310 | .gpcnt = AUD_B_GPCNT, | 310 | .gpcnt = AUD_B_GPCNT, |
311 | .aud_length = AUD_B_LNGTH, | 311 | .aud_length = AUD_B_LNGTH, |
312 | .aud_cfg = AUD_B_CFG, | 312 | .aud_cfg = AUD_B_CFG, |
313 | .fld_aud_fifo_en = FLD_AUD_SRC_B_FIFO_EN, | 313 | .fld_aud_fifo_en = FLD_AUD_SRC_B_FIFO_EN, |
314 | .fld_aud_risc_en = FLD_AUD_SRC_B_RISC_EN, | 314 | .fld_aud_risc_en = FLD_AUD_SRC_B_RISC_EN, |
315 | .irq_bit = 11, | 315 | .irq_bit = 11, |
316 | }, | 316 | }, |
317 | }; | 317 | }; |
318 | 318 | ||
319 | 319 | ||
@@ -325,7 +325,7 @@ struct sram_channel *channel4 = &cx25821_sram_channels[SRAM_CH04]; | |||
325 | struct sram_channel *channel5 = &cx25821_sram_channels[SRAM_CH05]; | 325 | struct sram_channel *channel5 = &cx25821_sram_channels[SRAM_CH05]; |
326 | struct sram_channel *channel6 = &cx25821_sram_channels[SRAM_CH06]; | 326 | struct sram_channel *channel6 = &cx25821_sram_channels[SRAM_CH06]; |
327 | struct sram_channel *channel7 = &cx25821_sram_channels[SRAM_CH07]; | 327 | struct sram_channel *channel7 = &cx25821_sram_channels[SRAM_CH07]; |
328 | struct sram_channel *channel9 = &cx25821_sram_channels[SRAM_CH09]; | 328 | struct sram_channel *channel9 = &cx25821_sram_channels[SRAM_CH09]; |
329 | struct sram_channel *channel10 = &cx25821_sram_channels[SRAM_CH10]; | 329 | struct sram_channel *channel10 = &cx25821_sram_channels[SRAM_CH10]; |
330 | struct sram_channel *channel11 = &cx25821_sram_channels[SRAM_CH11]; | 330 | struct sram_channel *channel11 = &cx25821_sram_channels[SRAM_CH11]; |
331 | 331 | ||
@@ -334,40 +334,40 @@ struct cx25821_dmaqueue mpegq; | |||
334 | static int cx25821_risc_decode(u32 risc) | 334 | static int cx25821_risc_decode(u32 risc) |
335 | { | 335 | { |
336 | static char *instr[16] = { | 336 | static char *instr[16] = { |
337 | [RISC_SYNC >> 28] = "sync", | 337 | [RISC_SYNC >> 28] = "sync", |
338 | [RISC_WRITE >> 28] = "write", | 338 | [RISC_WRITE >> 28] = "write", |
339 | [RISC_WRITEC >> 28] = "writec", | 339 | [RISC_WRITEC >> 28] = "writec", |
340 | [RISC_READ >> 28] = "read", | 340 | [RISC_READ >> 28] = "read", |
341 | [RISC_READC >> 28] = "readc", | 341 | [RISC_READC >> 28] = "readc", |
342 | [RISC_JUMP >> 28] = "jump", | 342 | [RISC_JUMP >> 28] = "jump", |
343 | [RISC_SKIP >> 28] = "skip", | 343 | [RISC_SKIP >> 28] = "skip", |
344 | [RISC_WRITERM >> 28] = "writerm", | 344 | [RISC_WRITERM >> 28] = "writerm", |
345 | [RISC_WRITECM >> 28] = "writecm", | 345 | [RISC_WRITECM >> 28] = "writecm", |
346 | [RISC_WRITECR >> 28] = "writecr", | 346 | [RISC_WRITECR >> 28] = "writecr", |
347 | }; | 347 | }; |
348 | static int incr[16] = { | 348 | static int incr[16] = { |
349 | [RISC_WRITE >> 28] = 3, | 349 | [RISC_WRITE >> 28] = 3, |
350 | [RISC_JUMP >> 28] = 3, | 350 | [RISC_JUMP >> 28] = 3, |
351 | [RISC_SKIP >> 28] = 1, | 351 | [RISC_SKIP >> 28] = 1, |
352 | [RISC_SYNC >> 28] = 1, | 352 | [RISC_SYNC >> 28] = 1, |
353 | [RISC_WRITERM >> 28] = 3, | 353 | [RISC_WRITERM >> 28] = 3, |
354 | [RISC_WRITECM >> 28] = 3, | 354 | [RISC_WRITECM >> 28] = 3, |
355 | [RISC_WRITECR >> 28] = 4, | 355 | [RISC_WRITECR >> 28] = 4, |
356 | }; | 356 | }; |
357 | static char *bits[] = { | 357 | static char *bits[] = { |
358 | "12", "13", "14", "resync", | 358 | "12", "13", "14", "resync", |
359 | "cnt0", "cnt1", "18", "19", | 359 | "cnt0", "cnt1", "18", "19", |
360 | "20", "21", "22", "23", | 360 | "20", "21", "22", "23", |
361 | "irq1", "irq2", "eol", "sol", | 361 | "irq1", "irq2", "eol", "sol", |
362 | }; | 362 | }; |
363 | int i; | 363 | int i; |
364 | 364 | ||
365 | printk("0x%08x [ %s", risc, instr[risc >> 28] ? instr[risc >> 28] : "INVALID"); | 365 | printk("0x%08x [ %s", risc, instr[risc >> 28] ? instr[risc >> 28] : "INVALID"); |
366 | for (i = ARRAY_SIZE(bits) - 1; i >= 0; i--) | 366 | for (i = ARRAY_SIZE(bits) - 1; i >= 0; i--) |
367 | { | 367 | { |
368 | if (risc & (1 << (i + 12))) | 368 | if (risc & (1 << (i + 12))) |
369 | printk(" %s", bits[i]); | 369 | printk(" %s", bits[i]); |
370 | } | 370 | } |
371 | printk(" count=%d ]\n", risc & 0xfff); | 371 | printk(" count=%d ]\n", risc & 0xfff); |
372 | return incr[risc >> 28] ? incr[risc >> 28] : 1; | 372 | return incr[risc >> 28] ? incr[risc >> 28] : 1; |
373 | } | 373 | } |
@@ -384,17 +384,17 @@ void cx_i2c_read_print(struct cx25821_dev *dev, u32 reg, const char* reg_string) | |||
384 | { | 384 | { |
385 | int tmp = 0; | 385 | int tmp = 0; |
386 | u32 value = 0; | 386 | u32 value = 0; |
387 | 387 | ||
388 | value = cx25821_i2c_read(&dev->i2c_bus[0], reg, &tmp); | 388 | value = cx25821_i2c_read(&dev->i2c_bus[0], reg, &tmp); |
389 | } | 389 | } |
390 | 390 | ||
391 | static void cx25821_registers_init(struct cx25821_dev *dev) | 391 | static void cx25821_registers_init(struct cx25821_dev *dev) |
392 | { | 392 | { |
393 | u32 tmp; | 393 | u32 tmp; |
394 | 394 | ||
395 | // enable RUN_RISC in Pecos | 395 | // enable RUN_RISC in Pecos |
396 | cx_write( DEV_CNTRL2, 0x20 ); | 396 | cx_write( DEV_CNTRL2, 0x20 ); |
397 | 397 | ||
398 | // Set the master PCI interrupt masks to enable video, audio, MBIF, and GPIO interrupts | 398 | // Set the master PCI interrupt masks to enable video, audio, MBIF, and GPIO interrupts |
399 | // I2C interrupt masking is handled by the I2C objects themselves. | 399 | // I2C interrupt masking is handled by the I2C objects themselves. |
400 | cx_write( PCI_INT_MSK, 0x2001FFFF ); | 400 | cx_write( PCI_INT_MSK, 0x2001FFFF ); |
@@ -408,7 +408,7 @@ static void cx25821_registers_init(struct cx25821_dev *dev) | |||
408 | 408 | ||
409 | // PLL_A_POST = 0x1C, PLL_A_OUT_TO_PIN = 0x1 | 409 | // PLL_A_POST = 0x1C, PLL_A_OUT_TO_PIN = 0x1 |
410 | cx_write( PLL_A_POST_STAT_BIST, 0x8000019C); | 410 | cx_write( PLL_A_POST_STAT_BIST, 0x8000019C); |
411 | 411 | ||
412 | // clear reset bit [31] | 412 | // clear reset bit [31] |
413 | tmp = cx_read( PLL_A_INT_FRAC ); | 413 | tmp = cx_read( PLL_A_INT_FRAC ); |
414 | cx_write( PLL_A_INT_FRAC, tmp & 0x7FFFFFFF); | 414 | cx_write( PLL_A_INT_FRAC, tmp & 0x7FFFFFFF); |
@@ -443,52 +443,52 @@ static void cx25821_registers_init(struct cx25821_dev *dev) | |||
443 | tmp = cx_read( PLL_D_INT_FRAC ); | 443 | tmp = cx_read( PLL_D_INT_FRAC ); |
444 | cx_write( PLL_D_INT_FRAC, tmp & 0x7FFFFFFF); | 444 | cx_write( PLL_D_INT_FRAC, tmp & 0x7FFFFFFF); |
445 | 445 | ||
446 | 446 | ||
447 | // This selects the PLL C clock source for the video upstream channel I and J | 447 | // This selects the PLL C clock source for the video upstream channel I and J |
448 | tmp = cx_read( VID_CH_CLK_SEL ); | 448 | tmp = cx_read( VID_CH_CLK_SEL ); |
449 | cx_write( VID_CH_CLK_SEL, (tmp & 0x00FFFFFF) | 0x24000000); | 449 | cx_write( VID_CH_CLK_SEL, (tmp & 0x00FFFFFF) | 0x24000000); |
450 | 450 | ||
451 | 451 | ||
452 | // 656/VIP SRC Upstream Channel I & J and 7 - Host Bus Interface for channel A-C | 452 | // 656/VIP SRC Upstream Channel I & J and 7 - Host Bus Interface for channel A-C |
453 | //select 656/VIP DST for downstream Channel A - C | 453 | //select 656/VIP DST for downstream Channel A - C |
454 | tmp = cx_read( VID_CH_MODE_SEL ); | 454 | tmp = cx_read( VID_CH_MODE_SEL ); |
455 | //cx_write( VID_CH_MODE_SEL, tmp | 0x1B0001FF); | 455 | //cx_write( VID_CH_MODE_SEL, tmp | 0x1B0001FF); |
456 | cx_write( VID_CH_MODE_SEL, tmp & 0xFFFFFE00); | 456 | cx_write( VID_CH_MODE_SEL, tmp & 0xFFFFFE00); |
457 | 457 | ||
458 | 458 | ||
459 | // enables 656 port I and J as output | 459 | // enables 656 port I and J as output |
460 | tmp = cx_read( CLK_RST ); | 460 | tmp = cx_read( CLK_RST ); |
461 | tmp |= FLD_USE_ALT_PLL_REF; // use external ALT_PLL_REF pin as its reference clock instead | 461 | tmp |= FLD_USE_ALT_PLL_REF; // use external ALT_PLL_REF pin as its reference clock instead |
462 | cx_write( CLK_RST, tmp & ~(FLD_VID_I_CLK_NOE | FLD_VID_J_CLK_NOE) ); | 462 | cx_write( CLK_RST, tmp & ~(FLD_VID_I_CLK_NOE | FLD_VID_J_CLK_NOE) ); |
463 | 463 | ||
464 | mdelay(100); | 464 | mdelay(100); |
465 | } | 465 | } |
466 | 466 | ||
467 | 467 | ||
468 | int cx25821_sram_channel_setup(struct cx25821_dev *dev, | 468 | int cx25821_sram_channel_setup(struct cx25821_dev *dev, |
469 | struct sram_channel *ch, | 469 | struct sram_channel *ch, |
470 | unsigned int bpl, u32 risc) | 470 | unsigned int bpl, u32 risc) |
471 | { | 471 | { |
472 | unsigned int i, lines; | 472 | unsigned int i, lines; |
473 | u32 cdt; | 473 | u32 cdt; |
474 | 474 | ||
475 | if (ch->cmds_start == 0) { | 475 | if (ch->cmds_start == 0) { |
476 | cx_write(ch->ptr1_reg, 0); | 476 | cx_write(ch->ptr1_reg, 0); |
477 | cx_write(ch->ptr2_reg, 0); | 477 | cx_write(ch->ptr2_reg, 0); |
478 | cx_write(ch->cnt2_reg, 0); | 478 | cx_write(ch->cnt2_reg, 0); |
479 | cx_write(ch->cnt1_reg, 0); | 479 | cx_write(ch->cnt1_reg, 0); |
480 | return 0; | 480 | return 0; |
481 | } | 481 | } |
482 | 482 | ||
483 | bpl = (bpl + 7) & ~7; /* alignment */ | 483 | bpl = (bpl + 7) & ~7; /* alignment */ |
484 | cdt = ch->cdt; | 484 | cdt = ch->cdt; |
485 | lines = ch->fifo_size / bpl; | 485 | lines = ch->fifo_size / bpl; |
486 | 486 | ||
487 | if (lines > 4) | 487 | if (lines > 4) |
488 | { | 488 | { |
489 | lines = 4; | 489 | lines = 4; |
490 | } | 490 | } |
491 | 491 | ||
492 | BUG_ON(lines < 2); | 492 | BUG_ON(lines < 2); |
493 | 493 | ||
494 | cx_write(8 + 0, RISC_JUMP | RISC_IRQ1 | RISC_CNT_INC); | 494 | cx_write(8 + 0, RISC_JUMP | RISC_IRQ1 | RISC_CNT_INC); |
@@ -497,75 +497,75 @@ int cx25821_sram_channel_setup(struct cx25821_dev *dev, | |||
497 | 497 | ||
498 | /* write CDT */ | 498 | /* write CDT */ |
499 | for (i = 0; i < lines; i++) { | 499 | for (i = 0; i < lines; i++) { |
500 | cx_write(cdt + 16*i, ch->fifo_start + bpl*i); | 500 | cx_write(cdt + 16*i, ch->fifo_start + bpl*i); |
501 | cx_write(cdt + 16*i + 4, 0); | 501 | cx_write(cdt + 16*i + 4, 0); |
502 | cx_write(cdt + 16*i + 8, 0); | 502 | cx_write(cdt + 16*i + 8, 0); |
503 | cx_write(cdt + 16*i + 12, 0); | 503 | cx_write(cdt + 16*i + 12, 0); |
504 | } | 504 | } |
505 | 505 | ||
506 | //init the first cdt buffer | 506 | //init the first cdt buffer |
507 | for(i=0; i<128; i++) | 507 | for(i=0; i<128; i++) |
508 | cx_write(ch->fifo_start+4*i, i); | 508 | cx_write(ch->fifo_start+4*i, i); |
509 | 509 | ||
510 | /* write CMDS */ | 510 | /* write CMDS */ |
511 | if (ch->jumponly) | 511 | if (ch->jumponly) |
512 | { | 512 | { |
513 | cx_write(ch->cmds_start + 0, 8); | 513 | cx_write(ch->cmds_start + 0, 8); |
514 | } | 514 | } |
515 | else | 515 | else |
516 | { | 516 | { |
517 | cx_write(ch->cmds_start + 0, risc); | 517 | cx_write(ch->cmds_start + 0, risc); |
518 | } | 518 | } |
519 | 519 | ||
520 | cx_write(ch->cmds_start + 4, 0); /* 64 bits 63-32 */ | 520 | cx_write(ch->cmds_start + 4, 0); /* 64 bits 63-32 */ |
521 | cx_write(ch->cmds_start + 8, cdt); | 521 | cx_write(ch->cmds_start + 8, cdt); |
522 | cx_write(ch->cmds_start + 12, (lines*16) >> 3); | 522 | cx_write(ch->cmds_start + 12, (lines*16) >> 3); |
523 | cx_write(ch->cmds_start + 16, ch->ctrl_start); | 523 | cx_write(ch->cmds_start + 16, ch->ctrl_start); |
524 | 524 | ||
525 | if (ch->jumponly) | 525 | if (ch->jumponly) |
526 | cx_write(ch->cmds_start + 20, 0x80000000 | (64 >> 2)); | 526 | cx_write(ch->cmds_start + 20, 0x80000000 | (64 >> 2)); |
527 | else | 527 | else |
528 | cx_write(ch->cmds_start + 20, 64 >> 2); | 528 | cx_write(ch->cmds_start + 20, 64 >> 2); |
529 | 529 | ||
530 | for (i = 24; i < 80; i += 4) | 530 | for (i = 24; i < 80; i += 4) |
531 | cx_write(ch->cmds_start + i, 0); | 531 | cx_write(ch->cmds_start + i, 0); |
532 | 532 | ||
533 | /* fill registers */ | 533 | /* fill registers */ |
534 | cx_write(ch->ptr1_reg, ch->fifo_start); | 534 | cx_write(ch->ptr1_reg, ch->fifo_start); |
535 | cx_write(ch->ptr2_reg, cdt); | 535 | cx_write(ch->ptr2_reg, cdt); |
536 | cx_write(ch->cnt2_reg, (lines*16) >> 3); | 536 | cx_write(ch->cnt2_reg, (lines*16) >> 3); |
537 | cx_write(ch->cnt1_reg, (bpl >> 3) - 1); | 537 | cx_write(ch->cnt1_reg, (bpl >> 3) - 1); |
538 | 538 | ||
539 | return 0; | 539 | return 0; |
540 | } | 540 | } |
541 | 541 | ||
542 | int cx25821_sram_channel_setup_audio(struct cx25821_dev *dev, | 542 | int cx25821_sram_channel_setup_audio(struct cx25821_dev *dev, |
543 | struct sram_channel *ch, | 543 | struct sram_channel *ch, |
544 | unsigned int bpl, u32 risc) | 544 | unsigned int bpl, u32 risc) |
545 | { | 545 | { |
546 | unsigned int i, lines; | 546 | unsigned int i, lines; |
547 | u32 cdt; | 547 | u32 cdt; |
548 | 548 | ||
549 | 549 | ||
550 | if (ch->cmds_start == 0) { | 550 | if (ch->cmds_start == 0) { |
551 | cx_write(ch->ptr1_reg, 0); | 551 | cx_write(ch->ptr1_reg, 0); |
552 | cx_write(ch->ptr2_reg, 0); | 552 | cx_write(ch->ptr2_reg, 0); |
553 | cx_write(ch->cnt2_reg, 0); | 553 | cx_write(ch->cnt2_reg, 0); |
554 | cx_write(ch->cnt1_reg, 0); | 554 | cx_write(ch->cnt1_reg, 0); |
555 | return 0; | 555 | return 0; |
556 | } | 556 | } |
557 | 557 | ||
558 | bpl = (bpl + 7) & ~7; /* alignment */ | 558 | bpl = (bpl + 7) & ~7; /* alignment */ |
559 | cdt = ch->cdt; | 559 | cdt = ch->cdt; |
560 | lines = ch->fifo_size / bpl; | 560 | lines = ch->fifo_size / bpl; |
561 | 561 | ||
562 | if (lines > 3) | 562 | if (lines > 3) |
563 | { | 563 | { |
564 | lines = 3; //for AUDIO | 564 | lines = 3; //for AUDIO |
565 | } | 565 | } |
566 | 566 | ||
567 | BUG_ON(lines < 2); | 567 | BUG_ON(lines < 2); |
568 | 568 | ||
569 | 569 | ||
570 | cx_write(8 + 0, RISC_JUMP | RISC_IRQ1 | RISC_CNT_INC); | 570 | cx_write(8 + 0, RISC_JUMP | RISC_IRQ1 | RISC_CNT_INC); |
571 | cx_write(8 + 4, 8); | 571 | cx_write(8 + 4, 8); |
@@ -573,47 +573,47 @@ int cx25821_sram_channel_setup_audio(struct cx25821_dev *dev, | |||
573 | 573 | ||
574 | /* write CDT */ | 574 | /* write CDT */ |
575 | for (i = 0; i < lines; i++) { | 575 | for (i = 0; i < lines; i++) { |
576 | cx_write(cdt + 16*i, ch->fifo_start + bpl*i); | 576 | cx_write(cdt + 16*i, ch->fifo_start + bpl*i); |
577 | cx_write(cdt + 16*i + 4, 0); | 577 | cx_write(cdt + 16*i + 4, 0); |
578 | cx_write(cdt + 16*i + 8, 0); | 578 | cx_write(cdt + 16*i + 8, 0); |
579 | cx_write(cdt + 16*i + 12, 0); | 579 | cx_write(cdt + 16*i + 12, 0); |
580 | } | 580 | } |
581 | 581 | ||
582 | /* write CMDS */ | 582 | /* write CMDS */ |
583 | if (ch->jumponly) | 583 | if (ch->jumponly) |
584 | { | 584 | { |
585 | cx_write(ch->cmds_start + 0, 8); | 585 | cx_write(ch->cmds_start + 0, 8); |
586 | } | 586 | } |
587 | else | 587 | else |
588 | { | 588 | { |
589 | cx_write(ch->cmds_start + 0, risc); | 589 | cx_write(ch->cmds_start + 0, risc); |
590 | } | 590 | } |
591 | 591 | ||
592 | cx_write(ch->cmds_start + 4, 0); /* 64 bits 63-32 */ | 592 | cx_write(ch->cmds_start + 4, 0); /* 64 bits 63-32 */ |
593 | cx_write(ch->cmds_start + 8, cdt); | 593 | cx_write(ch->cmds_start + 8, cdt); |
594 | cx_write(ch->cmds_start + 12, (lines*16) >> 3); | 594 | cx_write(ch->cmds_start + 12, (lines*16) >> 3); |
595 | cx_write(ch->cmds_start + 16, ch->ctrl_start); | 595 | cx_write(ch->cmds_start + 16, ch->ctrl_start); |
596 | 596 | ||
597 | //IQ size | 597 | //IQ size |
598 | if (ch->jumponly) | 598 | if (ch->jumponly) |
599 | { | 599 | { |
600 | cx_write(ch->cmds_start + 20, 0x80000000 | (64 >> 2)); | 600 | cx_write(ch->cmds_start + 20, 0x80000000 | (64 >> 2)); |
601 | } | 601 | } |
602 | else | 602 | else |
603 | { | 603 | { |
604 | cx_write(ch->cmds_start + 20, 64 >> 2); | 604 | cx_write(ch->cmds_start + 20, 64 >> 2); |
605 | } | 605 | } |
606 | 606 | ||
607 | //zero out | 607 | //zero out |
608 | for (i = 24; i < 80; i += 4) | 608 | for (i = 24; i < 80; i += 4) |
609 | cx_write(ch->cmds_start + i, 0); | 609 | cx_write(ch->cmds_start + i, 0); |
610 | 610 | ||
611 | /* fill registers */ | 611 | /* fill registers */ |
612 | cx_write(ch->ptr1_reg, ch->fifo_start); | 612 | cx_write(ch->ptr1_reg, ch->fifo_start); |
613 | cx_write(ch->ptr2_reg, cdt); | 613 | cx_write(ch->ptr2_reg, cdt); |
614 | cx_write(ch->cnt2_reg, (lines*16) >> 3); | 614 | cx_write(ch->cnt2_reg, (lines*16) >> 3); |
615 | cx_write(ch->cnt1_reg, (bpl >> 3) - 1); | 615 | cx_write(ch->cnt1_reg, (bpl >> 3) - 1); |
616 | 616 | ||
617 | return 0; | 617 | return 0; |
618 | } | 618 | } |
619 | 619 | ||
@@ -621,46 +621,46 @@ int cx25821_sram_channel_setup_audio(struct cx25821_dev *dev, | |||
621 | void cx25821_sram_channel_dump(struct cx25821_dev *dev, struct sram_channel *ch) | 621 | void cx25821_sram_channel_dump(struct cx25821_dev *dev, struct sram_channel *ch) |
622 | { | 622 | { |
623 | static char *name[] = { | 623 | static char *name[] = { |
624 | "init risc lo", | 624 | "init risc lo", |
625 | "init risc hi", | 625 | "init risc hi", |
626 | "cdt base", | 626 | "cdt base", |
627 | "cdt size", | 627 | "cdt size", |
628 | "iq base", | 628 | "iq base", |
629 | "iq size", | 629 | "iq size", |
630 | "risc pc lo", | 630 | "risc pc lo", |
631 | "risc pc hi", | 631 | "risc pc hi", |
632 | "iq wr ptr", | 632 | "iq wr ptr", |
633 | "iq rd ptr", | 633 | "iq rd ptr", |
634 | "cdt current", | 634 | "cdt current", |
635 | "pci target lo", | 635 | "pci target lo", |
636 | "pci target hi", | 636 | "pci target hi", |
637 | "line / byte", | 637 | "line / byte", |
638 | }; | 638 | }; |
639 | u32 risc; | 639 | u32 risc; |
640 | unsigned int i, j, n; | 640 | unsigned int i, j, n; |
641 | 641 | ||
642 | printk(KERN_WARNING "%s: %s - dma channel status dump\n", dev->name, ch->name); | 642 | printk(KERN_WARNING "%s: %s - dma channel status dump\n", dev->name, ch->name); |
643 | for (i = 0; i < ARRAY_SIZE(name); i++) | 643 | for (i = 0; i < ARRAY_SIZE(name); i++) |
644 | printk(KERN_WARNING "cmds + 0x%2x: %-15s: 0x%08x\n", i*4, name[i], | 644 | printk(KERN_WARNING "cmds + 0x%2x: %-15s: 0x%08x\n", i*4, name[i], |
645 | cx_read(ch->cmds_start + 4*i)); | 645 | cx_read(ch->cmds_start + 4*i)); |
646 | 646 | ||
647 | j=i*4; | 647 | j=i*4; |
648 | for (i = 0; i < 4; ) { | 648 | for (i = 0; i < 4; ) { |
649 | risc = cx_read(ch->cmds_start + 4 * (i + 14)); | 649 | risc = cx_read(ch->cmds_start + 4 * (i + 14)); |
650 | printk(KERN_WARNING "cmds + 0x%2x: risc%d: ", j+i*4, i); | 650 | printk(KERN_WARNING "cmds + 0x%2x: risc%d: ", j+i*4, i); |
651 | i +=cx25821_risc_decode(risc); | 651 | i +=cx25821_risc_decode(risc); |
652 | } | 652 | } |
653 | 653 | ||
654 | for (i = 0; i < (64 >> 2); i += n) { | 654 | for (i = 0; i < (64 >> 2); i += n) { |
655 | risc = cx_read(ch->ctrl_start + 4 * i); | 655 | risc = cx_read(ch->ctrl_start + 4 * i); |
656 | /* No consideration for bits 63-32 */ | 656 | /* No consideration for bits 63-32 */ |
657 | 657 | ||
658 | printk(KERN_WARNING "ctrl + 0x%2x (0x%08x): iq %x: ", i*4, ch->ctrl_start + 4 * i, i); | 658 | printk(KERN_WARNING "ctrl + 0x%2x (0x%08x): iq %x: ", i*4, ch->ctrl_start + 4 * i, i); |
659 | n = cx25821_risc_decode(risc); | 659 | n = cx25821_risc_decode(risc); |
660 | for (j = 1; j < n; j++) { | 660 | for (j = 1; j < n; j++) { |
661 | risc = cx_read(ch->ctrl_start + 4 * (i + j)); | 661 | risc = cx_read(ch->ctrl_start + 4 * (i + j)); |
662 | printk(KERN_WARNING "ctrl + 0x%2x : iq %x: 0x%08x [ arg #%d ]\n", 4*(i+j), i+j, risc, j); | 662 | printk(KERN_WARNING "ctrl + 0x%2x : iq %x: 0x%08x [ arg #%d ]\n", 4*(i+j), i+j, risc, j); |
663 | } | 663 | } |
664 | } | 664 | } |
665 | 665 | ||
666 | printk(KERN_WARNING " : fifo: 0x%08x -> 0x%x\n", ch->fifo_start, ch->fifo_start+ch->fifo_size); | 666 | printk(KERN_WARNING " : fifo: 0x%08x -> 0x%x\n", ch->fifo_start, ch->fifo_start+ch->fifo_size); |
@@ -674,50 +674,50 @@ void cx25821_sram_channel_dump(struct cx25821_dev *dev, struct sram_channel *ch) | |||
674 | void cx25821_sram_channel_dump_audio(struct cx25821_dev *dev, struct sram_channel *ch) | 674 | void cx25821_sram_channel_dump_audio(struct cx25821_dev *dev, struct sram_channel *ch) |
675 | { | 675 | { |
676 | static char *name[] = { | 676 | static char *name[] = { |
677 | "init risc lo", | 677 | "init risc lo", |
678 | "init risc hi", | 678 | "init risc hi", |
679 | "cdt base", | 679 | "cdt base", |
680 | "cdt size", | 680 | "cdt size", |
681 | "iq base", | 681 | "iq base", |
682 | "iq size", | 682 | "iq size", |
683 | "risc pc lo", | 683 | "risc pc lo", |
684 | "risc pc hi", | 684 | "risc pc hi", |
685 | "iq wr ptr", | 685 | "iq wr ptr", |
686 | "iq rd ptr", | 686 | "iq rd ptr", |
687 | "cdt current", | 687 | "cdt current", |
688 | "pci target lo", | 688 | "pci target lo", |
689 | "pci target hi", | 689 | "pci target hi", |
690 | "line / byte", | 690 | "line / byte", |
691 | }; | 691 | }; |
692 | 692 | ||
693 | u32 risc, value, tmp; | 693 | u32 risc, value, tmp; |
694 | unsigned int i, j, n; | 694 | unsigned int i, j, n; |
695 | 695 | ||
696 | 696 | ||
697 | printk(KERN_INFO "\n%s: %s - dma Audio channel status dump\n", dev->name, ch->name); | 697 | printk(KERN_INFO "\n%s: %s - dma Audio channel status dump\n", dev->name, ch->name); |
698 | 698 | ||
699 | for (i = 0; i < ARRAY_SIZE(name); i++) | 699 | for (i = 0; i < ARRAY_SIZE(name); i++) |
700 | printk(KERN_INFO "%s: cmds + 0x%2x: %-15s: 0x%08x\n", dev->name, i*4, name[i], cx_read(ch->cmds_start + 4*i)); | 700 | printk(KERN_INFO "%s: cmds + 0x%2x: %-15s: 0x%08x\n", dev->name, i*4, name[i], cx_read(ch->cmds_start + 4*i)); |
701 | 701 | ||
702 | 702 | ||
703 | j=i*4; | 703 | j=i*4; |
704 | for (i = 0; i < 4; ) { | 704 | for (i = 0; i < 4; ) { |
705 | risc = cx_read(ch->cmds_start + 4 * (i + 14)); | 705 | risc = cx_read(ch->cmds_start + 4 * (i + 14)); |
706 | printk(KERN_WARNING "cmds + 0x%2x: risc%d: ", j+i*4, i); | 706 | printk(KERN_WARNING "cmds + 0x%2x: risc%d: ", j+i*4, i); |
707 | i += cx25821_risc_decode(risc); | 707 | i += cx25821_risc_decode(risc); |
708 | } | 708 | } |
709 | 709 | ||
710 | for (i = 0; i < (64 >> 2); i += n) { | 710 | for (i = 0; i < (64 >> 2); i += n) { |
711 | risc = cx_read(ch->ctrl_start + 4 * i); | 711 | risc = cx_read(ch->ctrl_start + 4 * i); |
712 | /* No consideration for bits 63-32 */ | 712 | /* No consideration for bits 63-32 */ |
713 | 713 | ||
714 | printk(KERN_WARNING "ctrl + 0x%2x (0x%08x): iq %x: ", i*4, ch->ctrl_start + 4 * i, i); | 714 | printk(KERN_WARNING "ctrl + 0x%2x (0x%08x): iq %x: ", i*4, ch->ctrl_start + 4 * i, i); |
715 | n = cx25821_risc_decode(risc); | 715 | n = cx25821_risc_decode(risc); |
716 | 716 | ||
717 | for (j = 1; j < n; j++) { | 717 | for (j = 1; j < n; j++) { |
718 | risc = cx_read(ch->ctrl_start + 4 * (i + j)); | 718 | risc = cx_read(ch->ctrl_start + 4 * (i + j)); |
719 | printk(KERN_WARNING "ctrl + 0x%2x : iq %x: 0x%08x [ arg #%d ]\n", 4*(i+j), i+j, risc, j); | 719 | printk(KERN_WARNING "ctrl + 0x%2x : iq %x: 0x%08x [ arg #%d ]\n", 4*(i+j), i+j, risc, j); |
720 | } | 720 | } |
721 | } | 721 | } |
722 | 722 | ||
723 | printk(KERN_WARNING " : fifo: 0x%08x -> 0x%x\n", ch->fifo_start, ch->fifo_start+ch->fifo_size); | 723 | printk(KERN_WARNING " : fifo: 0x%08x -> 0x%x\n", ch->fifo_start, ch->fifo_start+ch->fifo_size); |
@@ -726,24 +726,24 @@ void cx25821_sram_channel_dump_audio(struct cx25821_dev *dev, struct sram_channe | |||
726 | printk(KERN_WARNING " : ptr2_reg: 0x%08x\n", cx_read(ch->ptr2_reg)); | 726 | printk(KERN_WARNING " : ptr2_reg: 0x%08x\n", cx_read(ch->ptr2_reg)); |
727 | printk(KERN_WARNING " : cnt1_reg: 0x%08x\n", cx_read(ch->cnt1_reg)); | 727 | printk(KERN_WARNING " : cnt1_reg: 0x%08x\n", cx_read(ch->cnt1_reg)); |
728 | printk(KERN_WARNING " : cnt2_reg: 0x%08x\n", cx_read(ch->cnt2_reg)); | 728 | printk(KERN_WARNING " : cnt2_reg: 0x%08x\n", cx_read(ch->cnt2_reg)); |
729 | 729 | ||
730 | for( i=0; i < 4; i++) | 730 | for( i=0; i < 4; i++) |
731 | { | 731 | { |
732 | risc = cx_read(ch->cmds_start + 56 + (i*4)); | 732 | risc = cx_read(ch->cmds_start + 56 + (i*4)); |
733 | printk(KERN_WARNING "instruction %d = 0x%x\n", i, risc); | 733 | printk(KERN_WARNING "instruction %d = 0x%x\n", i, risc); |
734 | } | 734 | } |
735 | 735 | ||
736 | //read data from the first cdt buffer | 736 | //read data from the first cdt buffer |
737 | risc = cx_read(AUD_A_CDT); | 737 | risc = cx_read(AUD_A_CDT); |
738 | printk(KERN_WARNING "\nread cdt loc=0x%x\n", risc); | 738 | printk(KERN_WARNING "\nread cdt loc=0x%x\n", risc); |
739 | for(i=0; i<8; i++) | 739 | for(i=0; i<8; i++) |
740 | { | 740 | { |
741 | n = cx_read(risc+i*4); | 741 | n = cx_read(risc+i*4); |
742 | printk(KERN_WARNING "0x%x ", n); | 742 | printk(KERN_WARNING "0x%x ", n); |
743 | } | 743 | } |
744 | printk(KERN_WARNING "\n\n"); | 744 | printk(KERN_WARNING "\n\n"); |
745 | 745 | ||
746 | 746 | ||
747 | value = cx_read(CLK_RST); | 747 | value = cx_read(CLK_RST); |
748 | CX25821_INFO(" CLK_RST = 0x%x \n\n", value); | 748 | CX25821_INFO(" CLK_RST = 0x%x \n\n", value); |
749 | 749 | ||
@@ -751,22 +751,22 @@ void cx25821_sram_channel_dump_audio(struct cx25821_dev *dev, struct sram_channe | |||
751 | CX25821_INFO(" PLL_A_POST_STAT_BIST = 0x%x \n\n", value); | 751 | CX25821_INFO(" PLL_A_POST_STAT_BIST = 0x%x \n\n", value); |
752 | value = cx_read(PLL_A_INT_FRAC); | 752 | value = cx_read(PLL_A_INT_FRAC); |
753 | CX25821_INFO(" PLL_A_INT_FRAC = 0x%x \n\n", value); | 753 | CX25821_INFO(" PLL_A_INT_FRAC = 0x%x \n\n", value); |
754 | 754 | ||
755 | value = cx_read(PLL_B_POST_STAT_BIST); | 755 | value = cx_read(PLL_B_POST_STAT_BIST); |
756 | CX25821_INFO(" PLL_B_POST_STAT_BIST = 0x%x \n\n", value); | 756 | CX25821_INFO(" PLL_B_POST_STAT_BIST = 0x%x \n\n", value); |
757 | value = cx_read(PLL_B_INT_FRAC); | 757 | value = cx_read(PLL_B_INT_FRAC); |
758 | CX25821_INFO(" PLL_B_INT_FRAC = 0x%x \n\n", value); | 758 | CX25821_INFO(" PLL_B_INT_FRAC = 0x%x \n\n", value); |
759 | 759 | ||
760 | value = cx_read(PLL_C_POST_STAT_BIST); | 760 | value = cx_read(PLL_C_POST_STAT_BIST); |
761 | CX25821_INFO(" PLL_C_POST_STAT_BIST = 0x%x \n\n", value); | 761 | CX25821_INFO(" PLL_C_POST_STAT_BIST = 0x%x \n\n", value); |
762 | value = cx_read(PLL_C_INT_FRAC); | 762 | value = cx_read(PLL_C_INT_FRAC); |
763 | CX25821_INFO(" PLL_C_INT_FRAC = 0x%x \n\n", value); | 763 | CX25821_INFO(" PLL_C_INT_FRAC = 0x%x \n\n", value); |
764 | 764 | ||
765 | value = cx_read(PLL_D_POST_STAT_BIST); | 765 | value = cx_read(PLL_D_POST_STAT_BIST); |
766 | CX25821_INFO(" PLL_D_POST_STAT_BIST = 0x%x \n\n", value); | 766 | CX25821_INFO(" PLL_D_POST_STAT_BIST = 0x%x \n\n", value); |
767 | value = cx_read(PLL_D_INT_FRAC); | 767 | value = cx_read(PLL_D_INT_FRAC); |
768 | CX25821_INFO(" PLL_D_INT_FRAC = 0x%x \n\n", value); | 768 | CX25821_INFO(" PLL_D_INT_FRAC = 0x%x \n\n", value); |
769 | 769 | ||
770 | value = cx25821_i2c_read(&dev->i2c_bus[0], AFE_AB_DIAG_CTRL, &tmp); | 770 | value = cx25821_i2c_read(&dev->i2c_bus[0], AFE_AB_DIAG_CTRL, &tmp); |
771 | CX25821_INFO(" AFE_AB_DIAG_CTRL (0x10900090) = 0x%x \n\n", value); | 771 | CX25821_INFO(" AFE_AB_DIAG_CTRL (0x10900090) = 0x%x \n\n", value); |
772 | } | 772 | } |
@@ -781,16 +781,16 @@ static void cx25821_shutdown(struct cx25821_dev *dev) | |||
781 | /* Disable Video A/B activity */ | 781 | /* Disable Video A/B activity */ |
782 | for(i=0; i<VID_CHANNEL_NUM; i++) | 782 | for(i=0; i<VID_CHANNEL_NUM; i++) |
783 | { | 783 | { |
784 | cx_write(dev->sram_channels[i].dma_ctl, 0); | 784 | cx_write(dev->sram_channels[i].dma_ctl, 0); |
785 | cx_write(dev->sram_channels[i].int_msk, 0); | 785 | cx_write(dev->sram_channels[i].int_msk, 0); |
786 | } | 786 | } |
787 | 787 | ||
788 | for( i = VID_UPSTREAM_SRAM_CHANNEL_I; i <= VID_UPSTREAM_SRAM_CHANNEL_J; i++) | 788 | for( i = VID_UPSTREAM_SRAM_CHANNEL_I; i <= VID_UPSTREAM_SRAM_CHANNEL_J; i++) |
789 | { | 789 | { |
790 | cx_write(dev->sram_channels[i].dma_ctl, 0); | 790 | cx_write(dev->sram_channels[i].dma_ctl, 0); |
791 | cx_write(dev->sram_channels[i].int_msk, 0); | 791 | cx_write(dev->sram_channels[i].int_msk, 0); |
792 | } | 792 | } |
793 | 793 | ||
794 | /* Disable Audio activity */ | 794 | /* Disable Audio activity */ |
795 | cx_write(AUD_INT_DMA_CTL, 0); | 795 | cx_write(AUD_INT_DMA_CTL, 0); |
796 | 796 | ||
@@ -803,14 +803,14 @@ static void cx25821_shutdown(struct cx25821_dev *dev) | |||
803 | } | 803 | } |
804 | 804 | ||
805 | void cx25821_set_pixel_format(struct cx25821_dev *dev, int channel_select, u32 format) | 805 | void cx25821_set_pixel_format(struct cx25821_dev *dev, int channel_select, u32 format) |
806 | { | 806 | { |
807 | struct sram_channel *ch; | 807 | struct sram_channel *ch; |
808 | 808 | ||
809 | if( channel_select <= 7 && channel_select >= 0 ) | 809 | if( channel_select <= 7 && channel_select >= 0 ) |
810 | { | 810 | { |
811 | ch = &cx25821_sram_channels[channel_select]; | 811 | ch = &cx25821_sram_channels[channel_select]; |
812 | cx_write(ch->pix_frmt, format); | 812 | cx_write(ch->pix_frmt, format); |
813 | dev->pixel_formats[channel_select] = format; | 813 | dev->pixel_formats[channel_select] = format; |
814 | } | 814 | } |
815 | } | 815 | } |
816 | 816 | ||
@@ -825,12 +825,12 @@ static void cx25821_initialize(struct cx25821_dev *dev) | |||
825 | int i; | 825 | int i; |
826 | 826 | ||
827 | dprintk(1, "%s()\n", __func__); | 827 | dprintk(1, "%s()\n", __func__); |
828 | 828 | ||
829 | cx25821_shutdown(dev); | 829 | cx25821_shutdown(dev); |
830 | cx_write(PCI_INT_STAT, 0xffffffff); | 830 | cx_write(PCI_INT_STAT, 0xffffffff); |
831 | 831 | ||
832 | for(i=0; i<VID_CHANNEL_NUM; i++) | 832 | for(i=0; i<VID_CHANNEL_NUM; i++) |
833 | cx_write(dev->sram_channels[i].int_stat, 0xffffffff); | 833 | cx_write(dev->sram_channels[i].int_stat, 0xffffffff); |
834 | 834 | ||
835 | 835 | ||
836 | cx_write(AUD_A_INT_STAT, 0xffffffff); | 836 | cx_write(AUD_A_INT_STAT, 0xffffffff); |
@@ -840,26 +840,26 @@ static void cx25821_initialize(struct cx25821_dev *dev) | |||
840 | cx_write(AUD_E_INT_STAT, 0xffffffff); | 840 | cx_write(AUD_E_INT_STAT, 0xffffffff); |
841 | 841 | ||
842 | cx_write(CLK_DELAY, cx_read(CLK_DELAY) & 0x80000000); | 842 | cx_write(CLK_DELAY, cx_read(CLK_DELAY) & 0x80000000); |
843 | cx_write(PAD_CTRL, 0x12); //for I2C | 843 | cx_write(PAD_CTRL, 0x12); //for I2C |
844 | cx25821_registers_init(dev); //init Pecos registers | 844 | cx25821_registers_init(dev); //init Pecos registers |
845 | mdelay(100); | 845 | mdelay(100); |
846 | 846 | ||
847 | 847 | ||
848 | for(i=0; i<VID_CHANNEL_NUM; i++) | 848 | for(i=0; i<VID_CHANNEL_NUM; i++) |
849 | { | 849 | { |
850 | cx25821_set_vip_mode(dev, &dev->sram_channels[i]); | 850 | cx25821_set_vip_mode(dev, &dev->sram_channels[i]); |
851 | cx25821_sram_channel_setup(dev, &dev->sram_channels[i], 1440, 0); | 851 | cx25821_sram_channel_setup(dev, &dev->sram_channels[i], 1440, 0); |
852 | dev->pixel_formats[i] = PIXEL_FRMT_422; | 852 | dev->pixel_formats[i] = PIXEL_FRMT_422; |
853 | dev->use_cif_resolution[i] = FALSE; | 853 | dev->use_cif_resolution[i] = FALSE; |
854 | } | 854 | } |
855 | 855 | ||
856 | //Probably only affect Downstream | 856 | //Probably only affect Downstream |
857 | for( i = VID_UPSTREAM_SRAM_CHANNEL_I; i <= VID_UPSTREAM_SRAM_CHANNEL_J; i++) | 857 | for( i = VID_UPSTREAM_SRAM_CHANNEL_I; i <= VID_UPSTREAM_SRAM_CHANNEL_J; i++) |
858 | { | 858 | { |
859 | cx25821_set_vip_mode(dev, &dev->sram_channels[i]); | 859 | cx25821_set_vip_mode(dev, &dev->sram_channels[i]); |
860 | } | 860 | } |
861 | 861 | ||
862 | cx25821_sram_channel_setup_audio(dev, &dev->sram_channels[SRAM_CH08], 128, 0); | 862 | cx25821_sram_channel_setup_audio(dev, &dev->sram_channels[SRAM_CH08], 128, 0); |
863 | 863 | ||
864 | cx25821_gpio_init(dev); | 864 | cx25821_gpio_init(dev); |
865 | } | 865 | } |
@@ -867,10 +867,10 @@ static void cx25821_initialize(struct cx25821_dev *dev) | |||
867 | static int get_resources(struct cx25821_dev *dev) | 867 | static int get_resources(struct cx25821_dev *dev) |
868 | { | 868 | { |
869 | if (request_mem_region(pci_resource_start(dev->pci, 0), pci_resource_len(dev->pci, 0), dev->name)) | 869 | if (request_mem_region(pci_resource_start(dev->pci, 0), pci_resource_len(dev->pci, 0), dev->name)) |
870 | return 0; | 870 | return 0; |
871 | 871 | ||
872 | printk(KERN_ERR "%s: can't get MMIO memory @ 0x%llx\n", | 872 | printk(KERN_ERR "%s: can't get MMIO memory @ 0x%llx\n", |
873 | dev->name, (unsigned long long)pci_resource_start(dev->pci, 0)); | 873 | dev->name, (unsigned long long)pci_resource_start(dev->pci, 0)); |
874 | 874 | ||
875 | return -EBUSY; | 875 | return -EBUSY; |
876 | } | 876 | } |
@@ -878,7 +878,7 @@ static int get_resources(struct cx25821_dev *dev) | |||
878 | 878 | ||
879 | static void cx25821_dev_checkrevision(struct cx25821_dev *dev) | 879 | static void cx25821_dev_checkrevision(struct cx25821_dev *dev) |
880 | { | 880 | { |
881 | dev->hwrevision = cx_read(RDR_CFG2) & 0xff; | 881 | dev->hwrevision = cx_read(RDR_CFG2) & 0xff; |
882 | 882 | ||
883 | printk(KERN_INFO "%s() Hardware revision = 0x%02x\n", __func__, dev->hwrevision); | 883 | printk(KERN_INFO "%s() Hardware revision = 0x%02x\n", __func__, dev->hwrevision); |
884 | } | 884 | } |
@@ -886,41 +886,41 @@ static void cx25821_dev_checkrevision(struct cx25821_dev *dev) | |||
886 | static void cx25821_iounmap(struct cx25821_dev *dev) | 886 | static void cx25821_iounmap(struct cx25821_dev *dev) |
887 | { | 887 | { |
888 | if (dev == NULL) | 888 | if (dev == NULL) |
889 | return; | 889 | return; |
890 | 890 | ||
891 | /* Releasing IO memory */ | 891 | /* Releasing IO memory */ |
892 | if (dev->lmmio != NULL) | 892 | if (dev->lmmio != NULL) |
893 | { | 893 | { |
894 | CX25821_INFO("Releasing lmmio.\n"); | 894 | CX25821_INFO("Releasing lmmio.\n"); |
895 | iounmap(dev->lmmio); | 895 | iounmap(dev->lmmio); |
896 | dev->lmmio = NULL; | 896 | dev->lmmio = NULL; |
897 | } | 897 | } |
898 | } | 898 | } |
899 | 899 | ||
900 | 900 | ||
901 | static int cx25821_dev_setup(struct cx25821_dev *dev) | 901 | static int cx25821_dev_setup(struct cx25821_dev *dev) |
902 | { | 902 | { |
903 | int io_size = 0, i; | 903 | int io_size = 0, i; |
904 | 904 | ||
905 | struct video_device *video_template[] = { | 905 | struct video_device *video_template[] = { |
906 | &cx25821_video_template0, | 906 | &cx25821_video_template0, |
907 | &cx25821_video_template1, | 907 | &cx25821_video_template1, |
908 | &cx25821_video_template2, | 908 | &cx25821_video_template2, |
909 | &cx25821_video_template3, | 909 | &cx25821_video_template3, |
910 | &cx25821_video_template4, | 910 | &cx25821_video_template4, |
911 | &cx25821_video_template5, | 911 | &cx25821_video_template5, |
912 | &cx25821_video_template6, | 912 | &cx25821_video_template6, |
913 | &cx25821_video_template7, | 913 | &cx25821_video_template7, |
914 | &cx25821_video_template9, | 914 | &cx25821_video_template9, |
915 | &cx25821_video_template10, | 915 | &cx25821_video_template10, |
916 | &cx25821_video_template11, | 916 | &cx25821_video_template11, |
917 | &cx25821_videoioctl_template, | 917 | &cx25821_videoioctl_template, |
918 | }; | 918 | }; |
919 | 919 | ||
920 | printk(KERN_INFO "\n***********************************\n"); | 920 | printk(KERN_INFO "\n***********************************\n"); |
921 | printk(KERN_INFO "cx25821 set up\n"); | 921 | printk(KERN_INFO "cx25821 set up\n"); |
922 | printk(KERN_INFO "***********************************\n\n"); | 922 | printk(KERN_INFO "***********************************\n\n"); |
923 | 923 | ||
924 | mutex_init(&dev->lock); | 924 | mutex_init(&dev->lock); |
925 | 925 | ||
926 | atomic_inc(&dev->refcount); | 926 | atomic_inc(&dev->refcount); |
@@ -934,30 +934,30 @@ static int cx25821_dev_setup(struct cx25821_dev *dev) | |||
934 | 934 | ||
935 | strcpy(cx25821_boards[UNKNOWN_BOARD].name, "unknown"); | 935 | strcpy(cx25821_boards[UNKNOWN_BOARD].name, "unknown"); |
936 | strcpy(cx25821_boards[CX25821_BOARD].name, "cx25821"); | 936 | strcpy(cx25821_boards[CX25821_BOARD].name, "cx25821"); |
937 | 937 | ||
938 | 938 | ||
939 | if( dev->pci->device != 0x8210 ) | 939 | if( dev->pci->device != 0x8210 ) |
940 | { | 940 | { |
941 | printk(KERN_INFO "%s() Exiting. Incorrect Hardware device = 0x%02x\n", | 941 | printk(KERN_INFO "%s() Exiting. Incorrect Hardware device = 0x%02x\n", |
942 | __func__, dev->pci->device); | 942 | __func__, dev->pci->device); |
943 | return -1; | 943 | return -1; |
944 | } | 944 | } |
945 | else | 945 | else |
946 | { | 946 | { |
947 | printk(KERN_INFO "Athena Hardware device = 0x%02x\n", dev->pci->device); | 947 | printk(KERN_INFO "Athena Hardware device = 0x%02x\n", dev->pci->device); |
948 | } | 948 | } |
949 | 949 | ||
950 | /* Apply a sensible clock frequency for the PCIe bridge */ | 950 | /* Apply a sensible clock frequency for the PCIe bridge */ |
951 | dev->clk_freq = 28000000; | 951 | dev->clk_freq = 28000000; |
952 | dev->sram_channels = cx25821_sram_channels; | 952 | dev->sram_channels = cx25821_sram_channels; |
953 | 953 | ||
954 | if(dev->nr > 1) | 954 | if(dev->nr > 1) |
955 | { | 955 | { |
956 | CX25821_INFO("dev->nr > 1!"); | 956 | CX25821_INFO("dev->nr > 1!"); |
957 | } | 957 | } |
958 | 958 | ||
959 | /* board config */ | 959 | /* board config */ |
960 | dev->board = 1; //card[dev->nr]; | 960 | dev->board = 1; //card[dev->nr]; |
961 | dev->_max_num_decoders = MAX_DECODERS; | 961 | dev->_max_num_decoders = MAX_DECODERS; |
962 | 962 | ||
963 | 963 | ||
@@ -977,141 +977,141 @@ static int cx25821_dev_setup(struct cx25821_dev *dev) | |||
977 | 977 | ||
978 | 978 | ||
979 | 979 | ||
980 | if (get_resources(dev) < 0) | 980 | if (get_resources(dev) < 0) |
981 | { | 981 | { |
982 | printk(KERN_ERR "%s No more PCIe resources for " | 982 | printk(KERN_ERR "%s No more PCIe resources for " |
983 | "subsystem: %04x:%04x\n", | 983 | "subsystem: %04x:%04x\n", |
984 | dev->name, dev->pci->subsystem_vendor, | 984 | dev->name, dev->pci->subsystem_vendor, |
985 | dev->pci->subsystem_device); | 985 | dev->pci->subsystem_device); |
986 | 986 | ||
987 | cx25821_devcount--; | 987 | cx25821_devcount--; |
988 | return -ENODEV; | 988 | return -ENODEV; |
989 | } | 989 | } |
990 | 990 | ||
991 | /* PCIe stuff */ | 991 | /* PCIe stuff */ |
992 | dev->base_io_addr = pci_resource_start(dev->pci, 0); | 992 | dev->base_io_addr = pci_resource_start(dev->pci, 0); |
993 | io_size = pci_resource_len(dev->pci, 0); | 993 | io_size = pci_resource_len(dev->pci, 0); |
994 | 994 | ||
995 | if (!dev->base_io_addr) { | 995 | if (!dev->base_io_addr) { |
996 | CX25821_ERR("No PCI Memory resources, exiting!\n"); | 996 | CX25821_ERR("No PCI Memory resources, exiting!\n"); |
997 | return -ENODEV; | 997 | return -ENODEV; |
998 | } | 998 | } |
999 | 999 | ||
1000 | dev->lmmio = ioremap(dev->base_io_addr, pci_resource_len(dev->pci, 0)); | 1000 | dev->lmmio = ioremap(dev->base_io_addr, pci_resource_len(dev->pci, 0)); |
1001 | 1001 | ||
1002 | if (!dev->lmmio) { | 1002 | if (!dev->lmmio) { |
1003 | CX25821_ERR("ioremap failed, maybe increasing __VMALLOC_RESERVE in page.h\n"); | 1003 | CX25821_ERR("ioremap failed, maybe increasing __VMALLOC_RESERVE in page.h\n"); |
1004 | cx25821_iounmap(dev); | 1004 | cx25821_iounmap(dev); |
1005 | return -ENOMEM; | 1005 | return -ENOMEM; |
1006 | } | 1006 | } |
1007 | 1007 | ||
1008 | 1008 | ||
1009 | dev->bmmio = (u8 __iomem *)dev->lmmio; | 1009 | dev->bmmio = (u8 __iomem *)dev->lmmio; |
1010 | 1010 | ||
1011 | printk(KERN_INFO "%s: subsystem: %04x:%04x, board: %s [card=%d,%s]\n", | 1011 | printk(KERN_INFO "%s: subsystem: %04x:%04x, board: %s [card=%d,%s]\n", |
1012 | dev->name, dev->pci->subsystem_vendor, | 1012 | dev->name, dev->pci->subsystem_vendor, |
1013 | dev->pci->subsystem_device, cx25821_boards[dev->board].name, | 1013 | dev->pci->subsystem_device, cx25821_boards[dev->board].name, |
1014 | dev->board, card[dev->nr] == dev->board ? | 1014 | dev->board, card[dev->nr] == dev->board ? |
1015 | "insmod option" : "autodetected"); | 1015 | "insmod option" : "autodetected"); |
1016 | 1016 | ||
1017 | /* init hardware */ | 1017 | /* init hardware */ |
1018 | cx25821_initialize(dev); | 1018 | cx25821_initialize(dev); |
1019 | 1019 | ||
1020 | cx25821_i2c_register(&dev->i2c_bus[0]); | 1020 | cx25821_i2c_register(&dev->i2c_bus[0]); |
1021 | // cx25821_i2c_register(&dev->i2c_bus[1]); | 1021 | // cx25821_i2c_register(&dev->i2c_bus[1]); |
1022 | // cx25821_i2c_register(&dev->i2c_bus[2]); | 1022 | // cx25821_i2c_register(&dev->i2c_bus[2]); |
1023 | 1023 | ||
1024 | CX25821_INFO("i2c register! bus->i2c_rc = %d\n", dev->i2c_bus[0].i2c_rc); | 1024 | CX25821_INFO("i2c register! bus->i2c_rc = %d\n", dev->i2c_bus[0].i2c_rc); |
1025 | 1025 | ||
1026 | cx25821_card_setup(dev); | 1026 | cx25821_card_setup(dev); |
1027 | medusa_video_init(dev); | 1027 | medusa_video_init(dev); |
1028 | 1028 | ||
1029 | for(i = 0; i < VID_CHANNEL_NUM; i++) | 1029 | for(i = 0; i < VID_CHANNEL_NUM; i++) |
1030 | { | 1030 | { |
1031 | if (cx25821_video_register(dev, i, video_template[i]) < 0) { | 1031 | if (cx25821_video_register(dev, i, video_template[i]) < 0) { |
1032 | printk(KERN_ERR "%s() Failed to register analog video adapters on VID channel %d\n", __func__, i); | 1032 | printk(KERN_ERR "%s() Failed to register analog video adapters on VID channel %d\n", __func__, i); |
1033 | } | 1033 | } |
1034 | } | 1034 | } |
1035 | 1035 | ||
1036 | 1036 | ||
1037 | for(i = VID_UPSTREAM_SRAM_CHANNEL_I; i <= AUDIO_UPSTREAM_SRAM_CHANNEL_B; i++) | 1037 | for(i = VID_UPSTREAM_SRAM_CHANNEL_I; i <= AUDIO_UPSTREAM_SRAM_CHANNEL_B; i++) |
1038 | { | 1038 | { |
1039 | //Since we don't have template8 for Audio Downstream | 1039 | //Since we don't have template8 for Audio Downstream |
1040 | if (cx25821_video_register(dev, i, video_template[i-1]) < 0) { | 1040 | if (cx25821_video_register(dev, i, video_template[i-1]) < 0) { |
1041 | printk(KERN_ERR "%s() Failed to register analog video adapters for Upstream channel %d.\n", __func__, i); | 1041 | printk(KERN_ERR "%s() Failed to register analog video adapters for Upstream channel %d.\n", __func__, i); |
1042 | } | 1042 | } |
1043 | } | 1043 | } |
1044 | 1044 | ||
1045 | // register IOCTL device | 1045 | // register IOCTL device |
1046 | dev->ioctl_dev = cx25821_vdev_init(dev, dev->pci, video_template[VIDEO_IOCTL_CH], "video"); | 1046 | dev->ioctl_dev = cx25821_vdev_init(dev, dev->pci, video_template[VIDEO_IOCTL_CH], "video"); |
1047 | 1047 | ||
1048 | if( video_register_device(dev->ioctl_dev, VFL_TYPE_GRABBER, VIDEO_IOCTL_CH) < 0 ) | 1048 | if( video_register_device(dev->ioctl_dev, VFL_TYPE_GRABBER, VIDEO_IOCTL_CH) < 0 ) |
1049 | { | 1049 | { |
1050 | cx25821_videoioctl_unregister(dev); | 1050 | cx25821_videoioctl_unregister(dev); |
1051 | printk(KERN_ERR "%s() Failed to register video adapter for IOCTL so releasing.\n", __func__); | 1051 | printk(KERN_ERR "%s() Failed to register video adapter for IOCTL so releasing.\n", __func__); |
1052 | } | 1052 | } |
1053 | 1053 | ||
1054 | cx25821_dev_checkrevision(dev); | 1054 | cx25821_dev_checkrevision(dev); |
1055 | CX25821_INFO("cx25821 setup done!\n"); | 1055 | CX25821_INFO("cx25821 setup done!\n"); |
1056 | 1056 | ||
1057 | return 0; | 1057 | return 0; |
1058 | } | 1058 | } |
1059 | 1059 | ||
1060 | 1060 | ||
1061 | void cx25821_start_upstream_video_ch1(struct cx25821_dev *dev, struct upstream_user_struct *up_data) | 1061 | void cx25821_start_upstream_video_ch1(struct cx25821_dev *dev, struct upstream_user_struct *up_data) |
1062 | { | 1062 | { |
1063 | dev->_isNTSC = !strcmp(dev->vid_stdname,"NTSC") ? 1 : 0; | 1063 | dev->_isNTSC = !strcmp(dev->vid_stdname,"NTSC") ? 1 : 0; |
1064 | 1064 | ||
1065 | dev->tvnorm = !dev->_isNTSC ? V4L2_STD_PAL_BG : V4L2_STD_NTSC_M; | 1065 | dev->tvnorm = !dev->_isNTSC ? V4L2_STD_PAL_BG : V4L2_STD_NTSC_M; |
1066 | medusa_set_videostandard(dev); | 1066 | medusa_set_videostandard(dev); |
1067 | 1067 | ||
1068 | cx25821_vidupstream_init_ch1(dev, dev->channel_select, dev->pixel_format); | 1068 | cx25821_vidupstream_init_ch1(dev, dev->channel_select, dev->pixel_format); |
1069 | } | 1069 | } |
1070 | 1070 | ||
1071 | 1071 | ||
1072 | void cx25821_start_upstream_video_ch2(struct cx25821_dev *dev, struct upstream_user_struct *up_data) | 1072 | void cx25821_start_upstream_video_ch2(struct cx25821_dev *dev, struct upstream_user_struct *up_data) |
1073 | { | 1073 | { |
1074 | dev->_isNTSC_ch2 = !strcmp(dev->vid_stdname_ch2,"NTSC") ? 1 : 0; | 1074 | dev->_isNTSC_ch2 = !strcmp(dev->vid_stdname_ch2,"NTSC") ? 1 : 0; |
1075 | |||
1076 | dev->tvnorm = !dev->_isNTSC_ch2 ? V4L2_STD_PAL_BG : V4L2_STD_NTSC_M; | ||
1077 | medusa_set_videostandard(dev); | ||
1075 | 1078 | ||
1076 | dev->tvnorm = !dev->_isNTSC_ch2 ? V4L2_STD_PAL_BG : V4L2_STD_NTSC_M; | 1079 | cx25821_vidupstream_init_ch2(dev, dev->channel_select_ch2, dev->pixel_format_ch2); |
1077 | medusa_set_videostandard(dev); | ||
1078 | |||
1079 | cx25821_vidupstream_init_ch2(dev, dev->channel_select_ch2, dev->pixel_format_ch2); | ||
1080 | } | 1080 | } |
1081 | 1081 | ||
1082 | 1082 | ||
1083 | void cx25821_start_upstream_audio(struct cx25821_dev *dev, struct upstream_user_struct *up_data) | 1083 | void cx25821_start_upstream_audio(struct cx25821_dev *dev, struct upstream_user_struct *up_data) |
1084 | { | 1084 | { |
1085 | cx25821_audio_upstream_init(dev, AUDIO_UPSTREAM_SRAM_CHANNEL_B); | 1085 | cx25821_audio_upstream_init(dev, AUDIO_UPSTREAM_SRAM_CHANNEL_B); |
1086 | } | 1086 | } |
1087 | 1087 | ||
1088 | void cx25821_dev_unregister(struct cx25821_dev *dev) | 1088 | void cx25821_dev_unregister(struct cx25821_dev *dev) |
1089 | { | 1089 | { |
1090 | int i; | 1090 | int i; |
1091 | 1091 | ||
1092 | if (!dev->base_io_addr) | 1092 | if (!dev->base_io_addr) |
1093 | return; | 1093 | return; |
1094 | 1094 | ||
1095 | cx25821_free_mem_upstream_ch1(dev); | 1095 | cx25821_free_mem_upstream_ch1(dev); |
1096 | cx25821_free_mem_upstream_ch2(dev); | 1096 | cx25821_free_mem_upstream_ch2(dev); |
1097 | cx25821_free_mem_upstream_audio(dev); | 1097 | cx25821_free_mem_upstream_audio(dev); |
1098 | 1098 | ||
1099 | release_mem_region(dev->base_io_addr, pci_resource_len(dev->pci, 0)); | 1099 | release_mem_region(dev->base_io_addr, pci_resource_len(dev->pci, 0)); |
1100 | 1100 | ||
1101 | if (!atomic_dec_and_test(&dev->refcount)) | 1101 | if (!atomic_dec_and_test(&dev->refcount)) |
1102 | return; | 1102 | return; |
1103 | 1103 | ||
1104 | for(i=0; i < VID_CHANNEL_NUM; i++) | 1104 | for(i=0; i < VID_CHANNEL_NUM; i++) |
1105 | cx25821_video_unregister(dev, i); | 1105 | cx25821_video_unregister(dev, i); |
1106 | |||
1106 | 1107 | ||
1107 | |||
1108 | for(i = VID_UPSTREAM_SRAM_CHANNEL_I; i <= AUDIO_UPSTREAM_SRAM_CHANNEL_B; i++) | 1108 | for(i = VID_UPSTREAM_SRAM_CHANNEL_I; i <= AUDIO_UPSTREAM_SRAM_CHANNEL_B; i++) |
1109 | { | 1109 | { |
1110 | cx25821_video_unregister(dev, i); | 1110 | cx25821_video_unregister(dev, i); |
1111 | } | 1111 | } |
1112 | 1112 | ||
1113 | cx25821_videoioctl_unregister(dev); | 1113 | cx25821_videoioctl_unregister(dev); |
1114 | 1114 | ||
1115 | cx25821_i2c_unregister( &dev->i2c_bus[0] ); | 1115 | cx25821_i2c_unregister( &dev->i2c_bus[0] ); |
1116 | cx25821_iounmap(dev); | 1116 | cx25821_iounmap(dev); |
1117 | } | 1117 | } |
@@ -1119,9 +1119,9 @@ void cx25821_dev_unregister(struct cx25821_dev *dev) | |||
1119 | 1119 | ||
1120 | 1120 | ||
1121 | static __le32 *cx25821_risc_field(__le32 *rp, struct scatterlist *sglist, | 1121 | static __le32 *cx25821_risc_field(__le32 *rp, struct scatterlist *sglist, |
1122 | unsigned int offset, u32 sync_line, | 1122 | unsigned int offset, u32 sync_line, |
1123 | unsigned int bpl, unsigned int padding, | 1123 | unsigned int bpl, unsigned int padding, |
1124 | unsigned int lines) | 1124 | unsigned int lines) |
1125 | { | 1125 | { |
1126 | struct scatterlist *sg; | 1126 | struct scatterlist *sg; |
1127 | unsigned int line, todo; | 1127 | unsigned int line, todo; |
@@ -1129,65 +1129,65 @@ static __le32 *cx25821_risc_field(__le32 *rp, struct scatterlist *sglist, | |||
1129 | /* sync instruction */ | 1129 | /* sync instruction */ |
1130 | if (sync_line != NO_SYNC_LINE) | 1130 | if (sync_line != NO_SYNC_LINE) |
1131 | { | 1131 | { |
1132 | *(rp++) = cpu_to_le32(RISC_RESYNC | sync_line); | 1132 | *(rp++) = cpu_to_le32(RISC_RESYNC | sync_line); |
1133 | } | 1133 | } |
1134 | 1134 | ||
1135 | /* scan lines */ | 1135 | /* scan lines */ |
1136 | sg = sglist; | 1136 | sg = sglist; |
1137 | for (line = 0; line < lines; line++) { | 1137 | for (line = 0; line < lines; line++) { |
1138 | while (offset && offset >= sg_dma_len(sg)) { | 1138 | while (offset && offset >= sg_dma_len(sg)) { |
1139 | offset -= sg_dma_len(sg); | 1139 | offset -= sg_dma_len(sg); |
1140 | sg++; | 1140 | sg++; |
1141 | } | 1141 | } |
1142 | if (bpl <= sg_dma_len(sg)-offset) { | 1142 | if (bpl <= sg_dma_len(sg)-offset) { |
1143 | /* fits into current chunk */ | 1143 | /* fits into current chunk */ |
1144 | *(rp++) = cpu_to_le32(RISC_WRITE|RISC_SOL|RISC_EOL|bpl); | 1144 | *(rp++) = cpu_to_le32(RISC_WRITE|RISC_SOL|RISC_EOL|bpl); |
1145 | *(rp++) = cpu_to_le32(sg_dma_address(sg)+offset); | 1145 | *(rp++) = cpu_to_le32(sg_dma_address(sg)+offset); |
1146 | *(rp++) = cpu_to_le32(0); /* bits 63-32 */ | 1146 | *(rp++) = cpu_to_le32(0); /* bits 63-32 */ |
1147 | offset += bpl; | 1147 | offset += bpl; |
1148 | } else { | 1148 | } else { |
1149 | /* scanline needs to be split */ | 1149 | /* scanline needs to be split */ |
1150 | todo = bpl; | 1150 | todo = bpl; |
1151 | *(rp++) = cpu_to_le32(RISC_WRITE|RISC_SOL|(sg_dma_len(sg)-offset)); | 1151 | *(rp++) = cpu_to_le32(RISC_WRITE|RISC_SOL|(sg_dma_len(sg)-offset)); |
1152 | *(rp++) = cpu_to_le32(sg_dma_address(sg)+offset); | 1152 | *(rp++) = cpu_to_le32(sg_dma_address(sg)+offset); |
1153 | *(rp++) = cpu_to_le32(0); /* bits 63-32 */ | 1153 | *(rp++) = cpu_to_le32(0); /* bits 63-32 */ |
1154 | todo -= (sg_dma_len(sg)-offset); | 1154 | todo -= (sg_dma_len(sg)-offset); |
1155 | offset = 0; | 1155 | offset = 0; |
1156 | sg++; | 1156 | sg++; |
1157 | while (todo > sg_dma_len(sg)) { | 1157 | while (todo > sg_dma_len(sg)) { |
1158 | *(rp++) = cpu_to_le32(RISC_WRITE|sg_dma_len(sg)); | 1158 | *(rp++) = cpu_to_le32(RISC_WRITE|sg_dma_len(sg)); |
1159 | *(rp++) = cpu_to_le32(sg_dma_address(sg)); | 1159 | *(rp++) = cpu_to_le32(sg_dma_address(sg)); |
1160 | *(rp++) = cpu_to_le32(0); /* bits 63-32 */ | 1160 | *(rp++) = cpu_to_le32(0); /* bits 63-32 */ |
1161 | todo -= sg_dma_len(sg); | 1161 | todo -= sg_dma_len(sg); |
1162 | sg++; | 1162 | sg++; |
1163 | } | 1163 | } |
1164 | *(rp++) = cpu_to_le32(RISC_WRITE|RISC_EOL|todo); | 1164 | *(rp++) = cpu_to_le32(RISC_WRITE|RISC_EOL|todo); |
1165 | *(rp++) = cpu_to_le32(sg_dma_address(sg)); | 1165 | *(rp++) = cpu_to_le32(sg_dma_address(sg)); |
1166 | *(rp++) = cpu_to_le32(0); /* bits 63-32 */ | 1166 | *(rp++) = cpu_to_le32(0); /* bits 63-32 */ |
1167 | offset += todo; | 1167 | offset += todo; |
1168 | } | 1168 | } |
1169 | 1169 | ||
1170 | offset += padding; | 1170 | offset += padding; |
1171 | } | 1171 | } |
1172 | 1172 | ||
1173 | return rp; | 1173 | return rp; |
1174 | } | 1174 | } |
1175 | 1175 | ||
1176 | int cx25821_risc_buffer(struct pci_dev *pci, struct btcx_riscmem *risc, | 1176 | int cx25821_risc_buffer(struct pci_dev *pci, struct btcx_riscmem *risc, |
1177 | struct scatterlist *sglist, unsigned int top_offset, | 1177 | struct scatterlist *sglist, unsigned int top_offset, |
1178 | unsigned int bottom_offset, unsigned int bpl, | 1178 | unsigned int bottom_offset, unsigned int bpl, |
1179 | unsigned int padding, unsigned int lines) | 1179 | unsigned int padding, unsigned int lines) |
1180 | { | 1180 | { |
1181 | u32 instructions; | 1181 | u32 instructions; |
1182 | u32 fields; | 1182 | u32 fields; |
1183 | __le32 *rp; | 1183 | __le32 *rp; |
1184 | int rc; | 1184 | int rc; |
1185 | 1185 | ||
1186 | fields = 0; | 1186 | fields = 0; |
1187 | if (UNSET != top_offset) | 1187 | if (UNSET != top_offset) |
1188 | fields++; | 1188 | fields++; |
1189 | if (UNSET != bottom_offset) | 1189 | if (UNSET != bottom_offset) |
1190 | fields++; | 1190 | fields++; |
1191 | 1191 | ||
1192 | /* estimate risc mem: worst case is one write per page border + | 1192 | /* estimate risc mem: worst case is one write per page border + |
1193 | one write per scan line + syncs + jump (all 2 dwords). Padding | 1193 | one write per scan line + syncs + jump (all 2 dwords). Padding |
@@ -1199,19 +1199,19 @@ int cx25821_risc_buffer(struct pci_dev *pci, struct btcx_riscmem *risc, | |||
1199 | rc = btcx_riscmem_alloc(pci, risc, instructions*12); | 1199 | rc = btcx_riscmem_alloc(pci, risc, instructions*12); |
1200 | 1200 | ||
1201 | if (rc < 0) | 1201 | if (rc < 0) |
1202 | return rc; | 1202 | return rc; |
1203 | 1203 | ||
1204 | /* write risc instructions */ | 1204 | /* write risc instructions */ |
1205 | rp = risc->cpu; | 1205 | rp = risc->cpu; |
1206 | 1206 | ||
1207 | if (UNSET != top_offset) | 1207 | if (UNSET != top_offset) |
1208 | { | 1208 | { |
1209 | rp = cx25821_risc_field(rp, sglist, top_offset, 0, bpl, padding, lines); | 1209 | rp = cx25821_risc_field(rp, sglist, top_offset, 0, bpl, padding, lines); |
1210 | } | 1210 | } |
1211 | 1211 | ||
1212 | if (UNSET != bottom_offset) | 1212 | if (UNSET != bottom_offset) |
1213 | { | 1213 | { |
1214 | rp = cx25821_risc_field(rp, sglist, bottom_offset, 0x200, bpl, padding, lines); | 1214 | rp = cx25821_risc_field(rp, sglist, bottom_offset, 0x200, bpl, padding, lines); |
1215 | } | 1215 | } |
1216 | 1216 | ||
1217 | /* save pointer to jmp instruction address */ | 1217 | /* save pointer to jmp instruction address */ |
@@ -1223,71 +1223,71 @@ int cx25821_risc_buffer(struct pci_dev *pci, struct btcx_riscmem *risc, | |||
1223 | 1223 | ||
1224 | 1224 | ||
1225 | static __le32* cx25821_risc_field_audio(__le32 *rp, struct scatterlist *sglist, | 1225 | static __le32* cx25821_risc_field_audio(__le32 *rp, struct scatterlist *sglist, |
1226 | unsigned int offset, u32 sync_line, | 1226 | unsigned int offset, u32 sync_line, |
1227 | unsigned int bpl, unsigned int padding, | 1227 | unsigned int bpl, unsigned int padding, |
1228 | unsigned int lines, unsigned int lpi) | 1228 | unsigned int lines, unsigned int lpi) |
1229 | { | 1229 | { |
1230 | struct scatterlist *sg; | 1230 | struct scatterlist *sg; |
1231 | unsigned int line, todo, sol; | 1231 | unsigned int line, todo, sol; |
1232 | 1232 | ||
1233 | /* sync instruction */ | 1233 | /* sync instruction */ |
1234 | if (sync_line != NO_SYNC_LINE) | 1234 | if (sync_line != NO_SYNC_LINE) |
1235 | *(rp++) = cpu_to_le32(RISC_RESYNC | sync_line); | 1235 | *(rp++) = cpu_to_le32(RISC_RESYNC | sync_line); |
1236 | 1236 | ||
1237 | /* scan lines */ | 1237 | /* scan lines */ |
1238 | sg = sglist; | 1238 | sg = sglist; |
1239 | for (line = 0; line < lines; line++) { | 1239 | for (line = 0; line < lines; line++) { |
1240 | while (offset && offset >= sg_dma_len(sg)) { | 1240 | while (offset && offset >= sg_dma_len(sg)) { |
1241 | offset -= sg_dma_len(sg); | 1241 | offset -= sg_dma_len(sg); |
1242 | sg++; | 1242 | sg++; |
1243 | } | 1243 | } |
1244 | 1244 | ||
1245 | if (lpi && line > 0 && !(line % lpi)) | 1245 | if (lpi && line > 0 && !(line % lpi)) |
1246 | sol = RISC_SOL | RISC_IRQ1 | RISC_CNT_INC; | 1246 | sol = RISC_SOL | RISC_IRQ1 | RISC_CNT_INC; |
1247 | else | 1247 | else |
1248 | sol = RISC_SOL; | 1248 | sol = RISC_SOL; |
1249 | 1249 | ||
1250 | if (bpl <= sg_dma_len(sg)-offset) { | 1250 | if (bpl <= sg_dma_len(sg)-offset) { |
1251 | /* fits into current chunk */ | 1251 | /* fits into current chunk */ |
1252 | *(rp++) = cpu_to_le32(RISC_WRITE|sol|RISC_EOL|bpl); | 1252 | *(rp++) = cpu_to_le32(RISC_WRITE|sol|RISC_EOL|bpl); |
1253 | *(rp++)=cpu_to_le32(sg_dma_address(sg)+offset); | 1253 | *(rp++)=cpu_to_le32(sg_dma_address(sg)+offset); |
1254 | *(rp++)=cpu_to_le32(0); /* bits 63-32 */ | 1254 | *(rp++)=cpu_to_le32(0); /* bits 63-32 */ |
1255 | offset+=bpl; | 1255 | offset+=bpl; |
1256 | } else { | 1256 | } else { |
1257 | /* scanline needs to be split */ | 1257 | /* scanline needs to be split */ |
1258 | todo = bpl; | 1258 | todo = bpl; |
1259 | *(rp++) = cpu_to_le32(RISC_WRITE|sol| | 1259 | *(rp++) = cpu_to_le32(RISC_WRITE|sol| |
1260 | (sg_dma_len(sg)-offset)); | 1260 | (sg_dma_len(sg)-offset)); |
1261 | *(rp++)=cpu_to_le32(sg_dma_address(sg)+offset); | 1261 | *(rp++)=cpu_to_le32(sg_dma_address(sg)+offset); |
1262 | *(rp++)=cpu_to_le32(0); /* bits 63-32 */ | 1262 | *(rp++)=cpu_to_le32(0); /* bits 63-32 */ |
1263 | todo -= (sg_dma_len(sg)-offset); | 1263 | todo -= (sg_dma_len(sg)-offset); |
1264 | offset = 0; | 1264 | offset = 0; |
1265 | sg++; | 1265 | sg++; |
1266 | while (todo > sg_dma_len(sg)) { | 1266 | while (todo > sg_dma_len(sg)) { |
1267 | *(rp++)=cpu_to_le32(RISC_WRITE| | 1267 | *(rp++)=cpu_to_le32(RISC_WRITE| |
1268 | sg_dma_len(sg)); | 1268 | sg_dma_len(sg)); |
1269 | *(rp++)=cpu_to_le32(sg_dma_address(sg)); | 1269 | *(rp++)=cpu_to_le32(sg_dma_address(sg)); |
1270 | *(rp++)=cpu_to_le32(0); /* bits 63-32 */ | 1270 | *(rp++)=cpu_to_le32(0); /* bits 63-32 */ |
1271 | todo -= sg_dma_len(sg); | 1271 | todo -= sg_dma_len(sg); |
1272 | sg++; | 1272 | sg++; |
1273 | } | 1273 | } |
1274 | *(rp++)=cpu_to_le32(RISC_WRITE|RISC_EOL|todo); | 1274 | *(rp++)=cpu_to_le32(RISC_WRITE|RISC_EOL|todo); |
1275 | *(rp++)=cpu_to_le32(sg_dma_address(sg)); | 1275 | *(rp++)=cpu_to_le32(sg_dma_address(sg)); |
1276 | *(rp++)=cpu_to_le32(0); /* bits 63-32 */ | 1276 | *(rp++)=cpu_to_le32(0); /* bits 63-32 */ |
1277 | offset += todo; | 1277 | offset += todo; |
1278 | } | 1278 | } |
1279 | offset += padding; | 1279 | offset += padding; |
1280 | } | 1280 | } |
1281 | 1281 | ||
1282 | return rp; | 1282 | return rp; |
1283 | } | 1283 | } |
1284 | 1284 | ||
1285 | int cx25821_risc_databuffer_audio(struct pci_dev *pci, | 1285 | int cx25821_risc_databuffer_audio(struct pci_dev *pci, |
1286 | struct btcx_riscmem *risc, | 1286 | struct btcx_riscmem *risc, |
1287 | struct scatterlist *sglist, | 1287 | struct scatterlist *sglist, |
1288 | unsigned int bpl, | 1288 | unsigned int bpl, |
1289 | unsigned int lines, | 1289 | unsigned int lines, |
1290 | unsigned int lpi) | 1290 | unsigned int lpi) |
1291 | { | 1291 | { |
1292 | u32 instructions; | 1292 | u32 instructions; |
1293 | __le32 *rp; | 1293 | __le32 *rp; |
@@ -1302,13 +1302,13 @@ int cx25821_risc_databuffer_audio(struct pci_dev *pci, | |||
1302 | instructions += 1; | 1302 | instructions += 1; |
1303 | 1303 | ||
1304 | if ((rc = btcx_riscmem_alloc(pci,risc,instructions*12)) < 0) | 1304 | if ((rc = btcx_riscmem_alloc(pci,risc,instructions*12)) < 0) |
1305 | return rc; | 1305 | return rc; |
1306 | 1306 | ||
1307 | 1307 | ||
1308 | /* write risc instructions */ | 1308 | /* write risc instructions */ |
1309 | rp = risc->cpu; | 1309 | rp = risc->cpu; |
1310 | rp = cx25821_risc_field_audio(rp, sglist, 0, NO_SYNC_LINE, bpl, 0, lines, lpi); | 1310 | rp = cx25821_risc_field_audio(rp, sglist, 0, NO_SYNC_LINE, bpl, 0, lines, lpi); |
1311 | 1311 | ||
1312 | /* save pointer to jmp instruction address */ | 1312 | /* save pointer to jmp instruction address */ |
1313 | risc->jmp = rp; | 1313 | risc->jmp = rp; |
1314 | BUG_ON((risc->jmp - risc->cpu + 2) * sizeof (*risc->cpu) > risc->size); | 1314 | BUG_ON((risc->jmp - risc->cpu + 2) * sizeof (*risc->cpu) > risc->size); |
@@ -1324,18 +1324,18 @@ int cx25821_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc,u32 reg, | |||
1324 | rc = btcx_riscmem_alloc(pci, risc, 4*16); | 1324 | rc = btcx_riscmem_alloc(pci, risc, 4*16); |
1325 | 1325 | ||
1326 | if (rc < 0) | 1326 | if (rc < 0) |
1327 | return rc; | 1327 | return rc; |
1328 | 1328 | ||
1329 | /* write risc instructions */ | 1329 | /* write risc instructions */ |
1330 | rp = risc->cpu; | 1330 | rp = risc->cpu; |
1331 | 1331 | ||
1332 | *(rp++) = cpu_to_le32(RISC_WRITECR | RISC_IRQ1); | 1332 | *(rp++) = cpu_to_le32(RISC_WRITECR | RISC_IRQ1); |
1333 | *(rp++) = cpu_to_le32(reg); | 1333 | *(rp++) = cpu_to_le32(reg); |
1334 | *(rp++) = cpu_to_le32(value); | 1334 | *(rp++) = cpu_to_le32(value); |
1335 | *(rp++) = cpu_to_le32(mask); | 1335 | *(rp++) = cpu_to_le32(mask); |
1336 | *(rp++) = cpu_to_le32(RISC_JUMP); | 1336 | *(rp++) = cpu_to_le32(RISC_JUMP); |
1337 | *(rp++) = cpu_to_le32(risc->dma); | 1337 | *(rp++) = cpu_to_le32(risc->dma); |
1338 | *(rp++) = cpu_to_le32(0); /* bits 63-32 */ | 1338 | *(rp++) = cpu_to_le32(0); /* bits 63-32 */ |
1339 | return 0; | 1339 | return 0; |
1340 | } | 1340 | } |
1341 | 1341 | ||
@@ -1363,111 +1363,111 @@ static irqreturn_t cx25821_irq(int irq, void *dev_id) | |||
1363 | pci_status = cx_read(PCI_INT_STAT); | 1363 | pci_status = cx_read(PCI_INT_STAT); |
1364 | pci_mask = cx_read(PCI_INT_MSK); | 1364 | pci_mask = cx_read(PCI_INT_MSK); |
1365 | 1365 | ||
1366 | 1366 | ||
1367 | if (pci_status == 0) | 1367 | if (pci_status == 0) |
1368 | goto out; | 1368 | goto out; |
1369 | 1369 | ||
1370 | for(i = 0; i < VID_CHANNEL_NUM; i++) | 1370 | for(i = 0; i < VID_CHANNEL_NUM; i++) |
1371 | { | 1371 | { |
1372 | if(pci_status & mask[i]) | 1372 | if(pci_status & mask[i]) |
1373 | { | 1373 | { |
1374 | vid_status = cx_read(dev->sram_channels[i].int_stat); | 1374 | vid_status = cx_read(dev->sram_channels[i].int_stat); |
1375 | 1375 | ||
1376 | if(vid_status) | 1376 | if(vid_status) |
1377 | handled += cx25821_video_irq(dev, i, vid_status); | 1377 | handled += cx25821_video_irq(dev, i, vid_status); |
1378 | 1378 | ||
1379 | cx_write(PCI_INT_STAT, mask[i]); | 1379 | cx_write(PCI_INT_STAT, mask[i]); |
1380 | } | 1380 | } |
1381 | } | 1381 | } |
1382 | 1382 | ||
1383 | out: | 1383 | out: |
1384 | return IRQ_RETVAL(handled); | 1384 | return IRQ_RETVAL(handled); |
1385 | } | 1385 | } |
1386 | 1386 | ||
1387 | void cx25821_print_irqbits(char *name, char *tag, char **strings, | 1387 | void cx25821_print_irqbits(char *name, char *tag, char **strings, |
1388 | int len, u32 bits, u32 mask) | 1388 | int len, u32 bits, u32 mask) |
1389 | { | 1389 | { |
1390 | unsigned int i; | 1390 | unsigned int i; |
1391 | 1391 | ||
1392 | printk(KERN_DEBUG "%s: %s [0x%x]", name, tag, bits); | 1392 | printk(KERN_DEBUG "%s: %s [0x%x]", name, tag, bits); |
1393 | 1393 | ||
1394 | for (i = 0; i < len; i++) { | 1394 | for (i = 0; i < len; i++) { |
1395 | if (!(bits & (1 << i))) | 1395 | if (!(bits & (1 << i))) |
1396 | continue; | 1396 | continue; |
1397 | if (strings[i]) | 1397 | if (strings[i]) |
1398 | printk(" %s", strings[i]); | 1398 | printk(" %s", strings[i]); |
1399 | else | 1399 | else |
1400 | printk(" %d", i); | 1400 | printk(" %d", i); |
1401 | if (!(mask & (1 << i))) | 1401 | if (!(mask & (1 << i))) |
1402 | continue; | 1402 | continue; |
1403 | printk("*"); | 1403 | printk("*"); |
1404 | } | 1404 | } |
1405 | printk("\n"); | 1405 | printk("\n"); |
1406 | } | 1406 | } |
1407 | 1407 | ||
1408 | struct cx25821_dev* cx25821_dev_get(struct pci_dev *pci) | 1408 | struct cx25821_dev* cx25821_dev_get(struct pci_dev *pci) |
1409 | { | 1409 | { |
1410 | struct cx25821_dev *dev = pci_get_drvdata(pci); | 1410 | struct cx25821_dev *dev = pci_get_drvdata(pci); |
1411 | return dev; | 1411 | return dev; |
1412 | } | 1412 | } |
1413 | 1413 | ||
1414 | static int __devinit cx25821_initdev(struct pci_dev *pci_dev, const struct pci_device_id *pci_id) | 1414 | static int __devinit cx25821_initdev(struct pci_dev *pci_dev, const struct pci_device_id *pci_id) |
1415 | { | 1415 | { |
1416 | struct cx25821_dev *dev; | 1416 | struct cx25821_dev *dev; |
1417 | int err = 0; | 1417 | int err = 0; |
1418 | 1418 | ||
1419 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); | 1419 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); |
1420 | if (NULL == dev) | 1420 | if (NULL == dev) |
1421 | return -ENOMEM; | 1421 | return -ENOMEM; |
1422 | 1422 | ||
1423 | 1423 | ||
1424 | err = v4l2_device_register(&pci_dev->dev, &dev->v4l2_dev); | 1424 | err = v4l2_device_register(&pci_dev->dev, &dev->v4l2_dev); |
1425 | if (err < 0) | 1425 | if (err < 0) |
1426 | goto fail_free; | 1426 | goto fail_free; |
1427 | 1427 | ||
1428 | /* pci init */ | 1428 | /* pci init */ |
1429 | dev->pci = pci_dev; | 1429 | dev->pci = pci_dev; |
1430 | if (pci_enable_device(pci_dev)) | 1430 | if (pci_enable_device(pci_dev)) |
1431 | { | 1431 | { |
1432 | err = -EIO; | 1432 | err = -EIO; |
1433 | 1433 | ||
1434 | printk(KERN_INFO "pci enable failed! "); | 1434 | printk(KERN_INFO "pci enable failed! "); |
1435 | 1435 | ||
1436 | goto fail_unregister_device; | 1436 | goto fail_unregister_device; |
1437 | } | 1437 | } |
1438 | 1438 | ||
1439 | printk(KERN_INFO "cx25821 Athena pci enable ! \n"); | 1439 | printk(KERN_INFO "cx25821 Athena pci enable ! \n"); |
1440 | 1440 | ||
1441 | if (cx25821_dev_setup(dev) < 0) | 1441 | if (cx25821_dev_setup(dev) < 0) |
1442 | { | 1442 | { |
1443 | err = -EINVAL; | 1443 | err = -EINVAL; |
1444 | goto fail_unregister_device; | 1444 | goto fail_unregister_device; |
1445 | } | 1445 | } |
1446 | 1446 | ||
1447 | /* print pci info */ | 1447 | /* print pci info */ |
1448 | pci_read_config_byte(pci_dev, PCI_CLASS_REVISION, &dev->pci_rev); | 1448 | pci_read_config_byte(pci_dev, PCI_CLASS_REVISION, &dev->pci_rev); |
1449 | pci_read_config_byte(pci_dev, PCI_LATENCY_TIMER, &dev->pci_lat); | 1449 | pci_read_config_byte(pci_dev, PCI_LATENCY_TIMER, &dev->pci_lat); |
1450 | printk(KERN_INFO "%s/0: found at %s, rev: %d, irq: %d, " | 1450 | printk(KERN_INFO "%s/0: found at %s, rev: %d, irq: %d, " |
1451 | "latency: %d, mmio: 0x%llx\n", dev->name, | 1451 | "latency: %d, mmio: 0x%llx\n", dev->name, |
1452 | pci_name(pci_dev), dev->pci_rev, pci_dev->irq, | 1452 | pci_name(pci_dev), dev->pci_rev, pci_dev->irq, |
1453 | dev->pci_lat, | 1453 | dev->pci_lat, |
1454 | (unsigned long long)dev->base_io_addr ); | 1454 | (unsigned long long)dev->base_io_addr ); |
1455 | 1455 | ||
1456 | 1456 | ||
1457 | pci_set_master(pci_dev); | 1457 | pci_set_master(pci_dev); |
1458 | if (!pci_dma_supported(pci_dev, 0xffffffff)) | 1458 | if (!pci_dma_supported(pci_dev, 0xffffffff)) |
1459 | { | 1459 | { |
1460 | printk("%s/0: Oops: no 32bit PCI DMA ???\n", dev->name); | 1460 | printk("%s/0: Oops: no 32bit PCI DMA ???\n", dev->name); |
1461 | err = -EIO; | 1461 | err = -EIO; |
1462 | goto fail_irq; | 1462 | goto fail_irq; |
1463 | } | 1463 | } |
1464 | 1464 | ||
1465 | err = request_irq(pci_dev->irq, cx25821_irq, IRQF_SHARED | IRQF_DISABLED, dev->name, dev); | 1465 | err = request_irq(pci_dev->irq, cx25821_irq, IRQF_SHARED | IRQF_DISABLED, dev->name, dev); |
1466 | 1466 | ||
1467 | if (err < 0) | 1467 | if (err < 0) |
1468 | { | 1468 | { |
1469 | printk(KERN_ERR "%s: can't get IRQ %d\n", dev->name, pci_dev->irq); | 1469 | printk(KERN_ERR "%s: can't get IRQ %d\n", dev->name, pci_dev->irq); |
1470 | goto fail_irq; | 1470 | goto fail_irq; |
1471 | } | 1471 | } |
1472 | 1472 | ||
1473 | return 0; | 1473 | return 0; |
@@ -1475,10 +1475,10 @@ static int __devinit cx25821_initdev(struct pci_dev *pci_dev, const struct pci_d | |||
1475 | fail_irq: | 1475 | fail_irq: |
1476 | printk(KERN_INFO "cx25821 cx25821_initdev() can't get IRQ ! \n"); | 1476 | printk(KERN_INFO "cx25821 cx25821_initdev() can't get IRQ ! \n"); |
1477 | cx25821_dev_unregister(dev); | 1477 | cx25821_dev_unregister(dev); |
1478 | 1478 | ||
1479 | fail_unregister_device: | 1479 | fail_unregister_device: |
1480 | v4l2_device_unregister(&dev->v4l2_dev); | 1480 | v4l2_device_unregister(&dev->v4l2_dev); |
1481 | 1481 | ||
1482 | fail_free: | 1482 | fail_free: |
1483 | kfree(dev); | 1483 | kfree(dev); |
1484 | return err; | 1484 | return err; |
@@ -1488,40 +1488,40 @@ static void __devexit cx25821_finidev(struct pci_dev *pci_dev) | |||
1488 | { | 1488 | { |
1489 | struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev); | 1489 | struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev); |
1490 | struct cx25821_dev *dev = get_cx25821(v4l2_dev); | 1490 | struct cx25821_dev *dev = get_cx25821(v4l2_dev); |
1491 | 1491 | ||
1492 | cx25821_shutdown(dev); | 1492 | cx25821_shutdown(dev); |
1493 | pci_disable_device(pci_dev); | 1493 | pci_disable_device(pci_dev); |
1494 | 1494 | ||
1495 | /* unregister stuff */ | 1495 | /* unregister stuff */ |
1496 | if( pci_dev->irq ) | 1496 | if( pci_dev->irq ) |
1497 | free_irq(pci_dev->irq, dev); | 1497 | free_irq(pci_dev->irq, dev); |
1498 | 1498 | ||
1499 | 1499 | ||
1500 | mutex_lock(&devlist); | 1500 | mutex_lock(&devlist); |
1501 | list_del(&dev->devlist); | 1501 | list_del(&dev->devlist); |
1502 | mutex_unlock(&devlist); | 1502 | mutex_unlock(&devlist); |
1503 | 1503 | ||
1504 | cx25821_dev_unregister(dev); | 1504 | cx25821_dev_unregister(dev); |
1505 | v4l2_device_unregister(v4l2_dev); | 1505 | v4l2_device_unregister(v4l2_dev); |
1506 | kfree(dev); | 1506 | kfree(dev); |
1507 | } | 1507 | } |
1508 | 1508 | ||
1509 | static struct pci_device_id cx25821_pci_tbl[] = { | 1509 | static struct pci_device_id cx25821_pci_tbl[] = { |
1510 | { | 1510 | { |
1511 | /* CX25821 Athena*/ | 1511 | /* CX25821 Athena*/ |
1512 | .vendor = 0x14f1, | 1512 | .vendor = 0x14f1, |
1513 | .device = 0x8210, | 1513 | .device = 0x8210, |
1514 | .subvendor = 0x14f1, | 1514 | .subvendor = 0x14f1, |
1515 | .subdevice = 0x0920, | 1515 | .subdevice = 0x0920, |
1516 | }, | 1516 | }, |
1517 | { | 1517 | { |
1518 | /* --- end of list --- */ | 1518 | /* --- end of list --- */ |
1519 | } | 1519 | } |
1520 | }; | 1520 | }; |
1521 | 1521 | ||
1522 | MODULE_DEVICE_TABLE(pci, cx25821_pci_tbl); | 1522 | MODULE_DEVICE_TABLE(pci, cx25821_pci_tbl); |
1523 | 1523 | ||
1524 | static struct pci_driver cx25821_pci_driver = | 1524 | static struct pci_driver cx25821_pci_driver = |
1525 | { | 1525 | { |
1526 | .name = "cx25821", | 1526 | .name = "cx25821", |
1527 | .id_table = cx25821_pci_tbl, | 1527 | .id_table = cx25821_pci_tbl, |
@@ -1534,11 +1534,11 @@ static struct pci_driver cx25821_pci_driver = | |||
1534 | 1534 | ||
1535 | static int cx25821_init(void) | 1535 | static int cx25821_init(void) |
1536 | { | 1536 | { |
1537 | INIT_LIST_HEAD(&cx25821_devlist); | 1537 | INIT_LIST_HEAD(&cx25821_devlist); |
1538 | printk(KERN_INFO "cx25821 driver version %d.%d.%d loaded\n", | 1538 | printk(KERN_INFO "cx25821 driver version %d.%d.%d loaded\n", |
1539 | (CX25821_VERSION_CODE >> 16) & 0xff, | 1539 | (CX25821_VERSION_CODE >> 16) & 0xff, |
1540 | (CX25821_VERSION_CODE >> 8) & 0xff, | 1540 | (CX25821_VERSION_CODE >> 8) & 0xff, |
1541 | CX25821_VERSION_CODE & 0xff); | 1541 | CX25821_VERSION_CODE & 0xff); |
1542 | return pci_register_driver(&cx25821_pci_driver); | 1542 | return pci_register_driver(&cx25821_pci_driver); |
1543 | } | 1543 | } |
1544 | 1544 | ||
diff --git a/drivers/staging/cx25821/cx25821-gpio.c b/drivers/staging/cx25821/cx25821-gpio.c index aa029fe3438..074c19682af 100644 --- a/drivers/staging/cx25821/cx25821-gpio.c +++ b/drivers/staging/cx25821/cx25821-gpio.c | |||
@@ -25,17 +25,17 @@ | |||
25 | 25 | ||
26 | /********************* GPIO stuffs *********************/ | 26 | /********************* GPIO stuffs *********************/ |
27 | void cx25821_set_gpiopin_direction( struct cx25821_dev *dev, | 27 | void cx25821_set_gpiopin_direction( struct cx25821_dev *dev, |
28 | int pin_number, | 28 | int pin_number, |
29 | int pin_logic_value) | 29 | int pin_logic_value) |
30 | { | 30 | { |
31 | int bit = pin_number; | 31 | int bit = pin_number; |
32 | u32 gpio_oe_reg = GPIO_LO_OE; | 32 | u32 gpio_oe_reg = GPIO_LO_OE; |
33 | u32 gpio_register = 0; | 33 | u32 gpio_register = 0; |
34 | u32 value = 0; | 34 | u32 value = 0; |
35 | 35 | ||
36 | // Check for valid pinNumber | 36 | // Check for valid pinNumber |
37 | if ( pin_number >= 47 ) | 37 | if ( pin_number >= 47 ) |
38 | return; | 38 | return; |
39 | 39 | ||
40 | 40 | ||
41 | if ( pin_number > 31 ) | 41 | if ( pin_number > 31 ) |
@@ -46,32 +46,32 @@ void cx25821_set_gpiopin_direction( struct cx25821_dev *dev, | |||
46 | 46 | ||
47 | // Here we will make sure that the GPIOs 0 and 1 are output. keep the rest as is | 47 | // Here we will make sure that the GPIOs 0 and 1 are output. keep the rest as is |
48 | gpio_register = cx_read( gpio_oe_reg ); | 48 | gpio_register = cx_read( gpio_oe_reg ); |
49 | 49 | ||
50 | if (pin_logic_value == 1) | 50 | if (pin_logic_value == 1) |
51 | { | 51 | { |
52 | value = gpio_register | Set_GPIO_Bit(bit) ; | 52 | value = gpio_register | Set_GPIO_Bit(bit) ; |
53 | } | 53 | } |
54 | else | 54 | else |
55 | { | 55 | { |
56 | value = gpio_register & Clear_GPIO_Bit(bit) ; | 56 | value = gpio_register & Clear_GPIO_Bit(bit) ; |
57 | } | 57 | } |
58 | 58 | ||
59 | cx_write( gpio_oe_reg, value ); | 59 | cx_write( gpio_oe_reg, value ); |
60 | } | 60 | } |
61 | 61 | ||
62 | static void cx25821_set_gpiopin_logicvalue( struct cx25821_dev *dev, | 62 | static void cx25821_set_gpiopin_logicvalue( struct cx25821_dev *dev, |
63 | int pin_number, | 63 | int pin_number, |
64 | int pin_logic_value) | 64 | int pin_logic_value) |
65 | { | 65 | { |
66 | int bit = pin_number; | 66 | int bit = pin_number; |
67 | u32 gpio_reg = GPIO_LO; | 67 | u32 gpio_reg = GPIO_LO; |
68 | u32 value = 0; | 68 | u32 value = 0; |
69 | 69 | ||
70 | 70 | ||
71 | // Check for valid pinNumber | 71 | // Check for valid pinNumber |
72 | if (pin_number >= 47) | 72 | if (pin_number >= 47) |
73 | return; | 73 | return; |
74 | 74 | ||
75 | cx25821_set_gpiopin_direction(dev, pin_number, 0); // change to output direction | 75 | cx25821_set_gpiopin_direction(dev, pin_number, 0); // change to output direction |
76 | 76 | ||
77 | 77 | ||
@@ -82,15 +82,15 @@ static void cx25821_set_gpiopin_logicvalue( struct cx25821_dev *dev, | |||
82 | } | 82 | } |
83 | 83 | ||
84 | value = cx_read( gpio_reg ); | 84 | value = cx_read( gpio_reg ); |
85 | 85 | ||
86 | 86 | ||
87 | if (pin_logic_value == 0) | 87 | if (pin_logic_value == 0) |
88 | { | 88 | { |
89 | value &= Clear_GPIO_Bit(bit); | 89 | value &= Clear_GPIO_Bit(bit); |
90 | } | 90 | } |
91 | else | 91 | else |
92 | { | 92 | { |
93 | value |= Set_GPIO_Bit(bit); | 93 | value |= Set_GPIO_Bit(bit); |
94 | } | 94 | } |
95 | 95 | ||
96 | cx_write( gpio_reg, value); | 96 | cx_write( gpio_reg, value); |
@@ -102,15 +102,15 @@ void cx25821_gpio_init(struct cx25821_dev *dev) | |||
102 | { | 102 | { |
103 | return; | 103 | return; |
104 | } | 104 | } |
105 | 105 | ||
106 | switch (dev->board) | 106 | switch (dev->board) |
107 | { | 107 | { |
108 | case CX25821_BOARD_CONEXANT_ATHENA10: | 108 | case CX25821_BOARD_CONEXANT_ATHENA10: |
109 | default: | 109 | default: |
110 | //set GPIO 5 to select the path for Medusa/Athena | 110 | //set GPIO 5 to select the path for Medusa/Athena |
111 | cx25821_set_gpiopin_logicvalue(dev, 5, 1); | 111 | cx25821_set_gpiopin_logicvalue(dev, 5, 1); |
112 | mdelay(20); | 112 | mdelay(20); |
113 | break; | 113 | break; |
114 | } | 114 | } |
115 | 115 | ||
116 | } | 116 | } |
diff --git a/drivers/staging/cx25821/cx25821-i2c.c b/drivers/staging/cx25821/cx25821-i2c.c index 16303f80d4f..0667b3f8eb9 100644 --- a/drivers/staging/cx25821/cx25821-i2c.c +++ b/drivers/staging/cx25821/cx25821-i2c.c | |||
@@ -88,9 +88,9 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap, const struct i2c_msg *msg | |||
88 | dprintk(1, "%s(msg->len=%d)\n", __func__, msg->len); | 88 | dprintk(1, "%s(msg->len=%d)\n", __func__, msg->len); |
89 | 89 | ||
90 | /* Deal with i2c probe functions with zero payload */ | 90 | /* Deal with i2c probe functions with zero payload */ |
91 | if (msg->len == 0) | 91 | if (msg->len == 0) |
92 | { | 92 | { |
93 | cx_write(bus->reg_addr, msg->addr << 25); | 93 | cx_write(bus->reg_addr, msg->addr << 25); |
94 | cx_write(bus->reg_ctrl, bus->i2c_period | (1 << 2)); | 94 | cx_write(bus->reg_ctrl, bus->i2c_period | (1 << 2)); |
95 | 95 | ||
96 | if (!i2c_wait_done(i2c_adap)) | 96 | if (!i2c_wait_done(i2c_adap)) |
@@ -106,7 +106,7 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap, const struct i2c_msg *msg | |||
106 | /* dev, reg + first byte */ | 106 | /* dev, reg + first byte */ |
107 | addr = (msg->addr << 25) | msg->buf[0]; | 107 | addr = (msg->addr << 25) | msg->buf[0]; |
108 | wdata = msg->buf[0]; | 108 | wdata = msg->buf[0]; |
109 | 109 | ||
110 | ctrl = bus->i2c_period | (1 << 12) | (1 << 2); | 110 | ctrl = bus->i2c_period | (1 << 12) | (1 << 2); |
111 | 111 | ||
112 | if (msg->len > 1) | 112 | if (msg->len > 1) |
@@ -125,7 +125,7 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap, const struct i2c_msg *msg | |||
125 | if (retval == 0) | 125 | if (retval == 0) |
126 | goto eio; | 126 | goto eio; |
127 | 127 | ||
128 | if (i2c_debug) | 128 | if (i2c_debug) |
129 | { | 129 | { |
130 | if (!(ctrl & I2C_NOSTOP)) | 130 | if (!(ctrl & I2C_NOSTOP)) |
131 | printk(" >\n"); | 131 | printk(" >\n"); |
@@ -152,14 +152,14 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap, const struct i2c_msg *msg | |||
152 | if (retval == 0) | 152 | if (retval == 0) |
153 | goto eio; | 153 | goto eio; |
154 | 154 | ||
155 | if (i2c_debug) | 155 | if (i2c_debug) |
156 | { | 156 | { |
157 | dprintk(1, " %02x", msg->buf[cnt]); | 157 | dprintk(1, " %02x", msg->buf[cnt]); |
158 | if (!(ctrl & I2C_NOSTOP)) | 158 | if (!(ctrl & I2C_NOSTOP)) |
159 | dprintk(1, " >\n"); | 159 | dprintk(1, " >\n"); |
160 | } | 160 | } |
161 | } | 161 | } |
162 | 162 | ||
163 | return msg->len; | 163 | return msg->len; |
164 | 164 | ||
165 | eio: | 165 | eio: |
@@ -244,18 +244,18 @@ static int i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, int num) | |||
244 | 244 | ||
245 | dprintk(1, "%s(num = %d)\n", __func__, num); | 245 | dprintk(1, "%s(num = %d)\n", __func__, num); |
246 | 246 | ||
247 | for (i = 0 ; i < num; i++) | 247 | for (i = 0 ; i < num; i++) |
248 | { | 248 | { |
249 | dprintk(1, "%s(num = %d) addr = 0x%02x len = 0x%x\n", | 249 | dprintk(1, "%s(num = %d) addr = 0x%02x len = 0x%x\n", |
250 | __func__, num, msgs[i].addr, msgs[i].len); | 250 | __func__, num, msgs[i].addr, msgs[i].len); |
251 | 251 | ||
252 | if (msgs[i].flags & I2C_M_RD) | 252 | if (msgs[i].flags & I2C_M_RD) |
253 | { | 253 | { |
254 | /* read */ | 254 | /* read */ |
255 | retval = i2c_readbytes(i2c_adap, &msgs[i], 0); | 255 | retval = i2c_readbytes(i2c_adap, &msgs[i], 0); |
256 | } | 256 | } |
257 | else if (i + 1 < num && (msgs[i + 1].flags & I2C_M_RD) && | 257 | else if (i + 1 < num && (msgs[i + 1].flags & I2C_M_RD) && |
258 | msgs[i].addr == msgs[i + 1].addr) | 258 | msgs[i].addr == msgs[i + 1].addr) |
259 | { | 259 | { |
260 | /* write then read from same address */ | 260 | /* write then read from same address */ |
261 | retval = i2c_sendbytes(i2c_adap, &msgs[i], msgs[i + 1].len); | 261 | retval = i2c_sendbytes(i2c_adap, &msgs[i], msgs[i + 1].len); |
@@ -264,13 +264,13 @@ static int i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, int num) | |||
264 | goto err; | 264 | goto err; |
265 | i++; | 265 | i++; |
266 | retval = i2c_readbytes(i2c_adap, &msgs[i], 1); | 266 | retval = i2c_readbytes(i2c_adap, &msgs[i], 1); |
267 | } | 267 | } |
268 | else | 268 | else |
269 | { | 269 | { |
270 | /* write */ | 270 | /* write */ |
271 | retval = i2c_sendbytes(i2c_adap, &msgs[i], 0); | 271 | retval = i2c_sendbytes(i2c_adap, &msgs[i], 0); |
272 | } | 272 | } |
273 | 273 | ||
274 | if (retval < 0) | 274 | if (retval < 0) |
275 | goto err; | 275 | goto err; |
276 | } | 276 | } |
@@ -283,9 +283,9 @@ static int i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, int num) | |||
283 | 283 | ||
284 | static u32 cx25821_functionality(struct i2c_adapter *adap) | 284 | static u32 cx25821_functionality(struct i2c_adapter *adap) |
285 | { | 285 | { |
286 | return I2C_FUNC_SMBUS_EMUL | | 286 | return I2C_FUNC_SMBUS_EMUL | |
287 | I2C_FUNC_I2C | | 287 | I2C_FUNC_I2C | |
288 | I2C_FUNC_SMBUS_WORD_DATA | | 288 | I2C_FUNC_SMBUS_WORD_DATA | |
289 | I2C_FUNC_SMBUS_READ_WORD_DATA | | 289 | I2C_FUNC_SMBUS_READ_WORD_DATA | |
290 | I2C_FUNC_SMBUS_WRITE_WORD_DATA; | 290 | I2C_FUNC_SMBUS_WRITE_WORD_DATA; |
291 | } | 291 | } |
@@ -334,7 +334,7 @@ int cx25821_i2c_register(struct cx25821_i2c *bus) | |||
334 | 334 | ||
335 | //set up the I2c | 335 | //set up the I2c |
336 | bus->i2c_client.addr = (0x88>>1); | 336 | bus->i2c_client.addr = (0x88>>1); |
337 | 337 | ||
338 | return bus->i2c_rc; | 338 | return bus->i2c_rc; |
339 | } | 339 | } |
340 | 340 | ||
@@ -375,19 +375,19 @@ int cx25821_i2c_read(struct cx25821_i2c *bus, u16 reg_addr, int *value) | |||
375 | int v = 0; | 375 | int v = 0; |
376 | u8 addr[2] = {0, 0}; | 376 | u8 addr[2] = {0, 0}; |
377 | u8 buf[4] = {0,0,0,0}; | 377 | u8 buf[4] = {0,0,0,0}; |
378 | 378 | ||
379 | struct i2c_msg msgs[2]={ | 379 | struct i2c_msg msgs[2]={ |
380 | { | 380 | { |
381 | .addr = client->addr, | 381 | .addr = client->addr, |
382 | .flags = 0, | 382 | .flags = 0, |
383 | .len = 2, | 383 | .len = 2, |
384 | .buf = addr, | 384 | .buf = addr, |
385 | }, { | 385 | }, { |
386 | .addr = client->addr, | 386 | .addr = client->addr, |
387 | .flags = I2C_M_RD, | 387 | .flags = I2C_M_RD, |
388 | .len = 4, | 388 | .len = 4, |
389 | .buf = buf, | 389 | .buf = buf, |
390 | } | 390 | } |
391 | }; | 391 | }; |
392 | 392 | ||
393 | 393 | ||
@@ -401,23 +401,23 @@ int cx25821_i2c_read(struct cx25821_i2c *bus, u16 reg_addr, int *value) | |||
401 | v = (buf[3]<<24) | (buf[2]<<16) | (buf[1]<<8) | buf[0]; | 401 | v = (buf[3]<<24) | (buf[2]<<16) | (buf[1]<<8) | buf[0]; |
402 | *value = v; | 402 | *value = v; |
403 | 403 | ||
404 | return v; | 404 | return v; |
405 | } | 405 | } |
406 | 406 | ||
407 | 407 | ||
408 | int cx25821_i2c_write(struct cx25821_i2c *bus, u16 reg_addr, int value) | 408 | int cx25821_i2c_write(struct cx25821_i2c *bus, u16 reg_addr, int value) |
409 | { | 409 | { |
410 | struct i2c_client *client = &bus->i2c_client; | 410 | struct i2c_client *client = &bus->i2c_client; |
411 | int retval = 0; | 411 | int retval = 0; |
412 | u8 buf[6] = {0, 0, 0, 0, 0, 0}; | 412 | u8 buf[6] = {0, 0, 0, 0, 0, 0}; |
413 | 413 | ||
414 | struct i2c_msg msgs[1]={ | 414 | struct i2c_msg msgs[1]={ |
415 | { | 415 | { |
416 | .addr = client->addr, | 416 | .addr = client->addr, |
417 | .flags = 0, | 417 | .flags = 0, |
418 | .len = 6, | 418 | .len = 6, |
419 | .buf = buf, | 419 | .buf = buf, |
420 | } | 420 | } |
421 | }; | 421 | }; |
422 | 422 | ||
423 | 423 | ||
diff --git a/drivers/staging/cx25821/cx25821-medusa-video.c b/drivers/staging/cx25821/cx25821-medusa-video.c index 6225f1079bc..84c68b3c5b5 100644 --- a/drivers/staging/cx25821/cx25821-medusa-video.c +++ b/drivers/staging/cx25821/cx25821-medusa-video.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the Conexant CX25821 PCIe bridge | 2 | * Driver for the Conexant CX25821 PCIe bridge |
3 | * | 3 | * |
4 | * Copyright (C) 2009 Conexant Systems Inc. | 4 | * Copyright (C) 2009 Conexant Systems Inc. |
5 | * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com> | 5 | * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com> |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify | 7 | * This program is free software; you can redistribute it and/or modify |
@@ -38,52 +38,52 @@ static void medusa_enable_bluefield_output(struct cx25821_dev *dev, int channel, | |||
38 | int out_ctrl = OUT_CTRL1; | 38 | int out_ctrl = OUT_CTRL1; |
39 | int out_ctrl_ns = OUT_CTRL_NS; | 39 | int out_ctrl_ns = OUT_CTRL_NS; |
40 | 40 | ||
41 | 41 | ||
42 | switch (channel) | 42 | switch (channel) |
43 | { | 43 | { |
44 | default: | 44 | default: |
45 | case VDEC_A: | 45 | case VDEC_A: |
46 | break; | 46 | break; |
47 | case VDEC_B: | 47 | case VDEC_B: |
48 | out_ctrl = VDEC_B_OUT_CTRL1; | 48 | out_ctrl = VDEC_B_OUT_CTRL1; |
49 | out_ctrl_ns = VDEC_B_OUT_CTRL_NS; | 49 | out_ctrl_ns = VDEC_B_OUT_CTRL_NS; |
50 | break; | 50 | break; |
51 | case VDEC_C: | 51 | case VDEC_C: |
52 | out_ctrl = VDEC_C_OUT_CTRL1; | 52 | out_ctrl = VDEC_C_OUT_CTRL1; |
53 | out_ctrl_ns = VDEC_C_OUT_CTRL_NS; | 53 | out_ctrl_ns = VDEC_C_OUT_CTRL_NS; |
54 | break; | 54 | break; |
55 | case VDEC_D: | 55 | case VDEC_D: |
56 | out_ctrl = VDEC_D_OUT_CTRL1; | 56 | out_ctrl = VDEC_D_OUT_CTRL1; |
57 | out_ctrl_ns = VDEC_D_OUT_CTRL_NS; | 57 | out_ctrl_ns = VDEC_D_OUT_CTRL_NS; |
58 | break; | 58 | break; |
59 | case VDEC_E: | 59 | case VDEC_E: |
60 | out_ctrl = VDEC_E_OUT_CTRL1; | 60 | out_ctrl = VDEC_E_OUT_CTRL1; |
61 | out_ctrl_ns = VDEC_E_OUT_CTRL_NS; | 61 | out_ctrl_ns = VDEC_E_OUT_CTRL_NS; |
62 | return; | 62 | return; |
63 | case VDEC_F: | 63 | case VDEC_F: |
64 | out_ctrl = VDEC_F_OUT_CTRL1; | 64 | out_ctrl = VDEC_F_OUT_CTRL1; |
65 | out_ctrl_ns = VDEC_F_OUT_CTRL_NS; | 65 | out_ctrl_ns = VDEC_F_OUT_CTRL_NS; |
66 | return; | 66 | return; |
67 | case VDEC_G: | 67 | case VDEC_G: |
68 | out_ctrl = VDEC_G_OUT_CTRL1; | 68 | out_ctrl = VDEC_G_OUT_CTRL1; |
69 | out_ctrl_ns = VDEC_G_OUT_CTRL_NS; | 69 | out_ctrl_ns = VDEC_G_OUT_CTRL_NS; |
70 | return; | 70 | return; |
71 | case VDEC_H: | 71 | case VDEC_H: |
72 | out_ctrl = VDEC_H_OUT_CTRL1; | 72 | out_ctrl = VDEC_H_OUT_CTRL1; |
73 | out_ctrl_ns = VDEC_H_OUT_CTRL_NS; | 73 | out_ctrl_ns = VDEC_H_OUT_CTRL_NS; |
74 | return; | 74 | return; |
75 | } | 75 | } |
76 | 76 | ||
77 | value = cx25821_i2c_read(&dev->i2c_bus[0], out_ctrl, &tmp); | 77 | value = cx25821_i2c_read(&dev->i2c_bus[0], out_ctrl, &tmp); |
78 | value &= 0xFFFFFF7F; // clear BLUE_FIELD_EN | 78 | value &= 0xFFFFFF7F; // clear BLUE_FIELD_EN |
79 | if (enable) | 79 | if (enable) |
80 | value |= 0x00000080; // set BLUE_FIELD_EN | 80 | value |= 0x00000080; // set BLUE_FIELD_EN |
81 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], out_ctrl, value); | 81 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], out_ctrl, value); |
82 | 82 | ||
83 | value = cx25821_i2c_read(&dev->i2c_bus[0], out_ctrl_ns, &tmp); | 83 | value = cx25821_i2c_read(&dev->i2c_bus[0], out_ctrl_ns, &tmp); |
84 | value &= 0xFFFFFF7F; | 84 | value &= 0xFFFFFF7F; |
85 | if (enable) | 85 | if (enable) |
86 | value |= 0x00000080; // set BLUE_FIELD_EN | 86 | value |= 0x00000080; // set BLUE_FIELD_EN |
87 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], out_ctrl_ns, value); | 87 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], out_ctrl_ns, value); |
88 | } | 88 | } |
89 | 89 | ||
@@ -97,93 +97,93 @@ static int medusa_initialize_ntsc(struct cx25821_dev *dev) | |||
97 | 97 | ||
98 | mutex_lock(&dev->lock); | 98 | mutex_lock(&dev->lock); |
99 | 99 | ||
100 | 100 | ||
101 | for (i=0; i < MAX_DECODERS; i++) | 101 | for (i=0; i < MAX_DECODERS; i++) |
102 | { | 102 | { |
103 | // set video format NTSC-M | 103 | // set video format NTSC-M |
104 | value = cx25821_i2c_read(&dev->i2c_bus[0], MODE_CTRL+(0x200*i), &tmp); | 104 | value = cx25821_i2c_read(&dev->i2c_bus[0], MODE_CTRL+(0x200*i), &tmp); |
105 | value &= 0xFFFFFFF0; | 105 | value &= 0xFFFFFFF0; |
106 | value |= 0x10001; // enable the fast locking mode bit[16] | 106 | value |= 0x10001; // enable the fast locking mode bit[16] |
107 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], MODE_CTRL+(0x200*i), value); | 107 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], MODE_CTRL+(0x200*i), value); |
108 | 108 | ||
109 | // resolution NTSC 720x480 | 109 | // resolution NTSC 720x480 |
110 | value = cx25821_i2c_read(&dev->i2c_bus[0], HORIZ_TIM_CTRL+(0x200*i), &tmp); | 110 | value = cx25821_i2c_read(&dev->i2c_bus[0], HORIZ_TIM_CTRL+(0x200*i), &tmp); |
111 | value &= 0x00C00C00; | 111 | value &= 0x00C00C00; |
112 | value |= 0x612D0074; | 112 | value |= 0x612D0074; |
113 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], HORIZ_TIM_CTRL+(0x200*i), value); | 113 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], HORIZ_TIM_CTRL+(0x200*i), value); |
114 | 114 | ||
115 | value = cx25821_i2c_read(&dev->i2c_bus[0], VERT_TIM_CTRL+(0x200*i), &tmp); | 115 | value = cx25821_i2c_read(&dev->i2c_bus[0], VERT_TIM_CTRL+(0x200*i), &tmp); |
116 | value &= 0x00C00C00; | 116 | value &= 0x00C00C00; |
117 | value |= 0x1C1E001A; // vblank_cnt + 2 to get camera ID | 117 | value |= 0x1C1E001A; // vblank_cnt + 2 to get camera ID |
118 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], VERT_TIM_CTRL+(0x200*i), value); | 118 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], VERT_TIM_CTRL+(0x200*i), value); |
119 | 119 | ||
120 | // chroma subcarrier step size | 120 | // chroma subcarrier step size |
121 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], SC_STEP_SIZE+(0x200*i), 0x43E00000); | 121 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], SC_STEP_SIZE+(0x200*i), 0x43E00000); |
122 | 122 | ||
123 | // enable VIP optional active | 123 | // enable VIP optional active |
124 | value = cx25821_i2c_read(&dev->i2c_bus[0], OUT_CTRL_NS+(0x200*i), &tmp); | 124 | value = cx25821_i2c_read(&dev->i2c_bus[0], OUT_CTRL_NS+(0x200*i), &tmp); |
125 | value &= 0xFFFBFFFF; | 125 | value &= 0xFFFBFFFF; |
126 | value |= 0x00040000; | 126 | value |= 0x00040000; |
127 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], OUT_CTRL_NS+(0x200*i), value); | 127 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], OUT_CTRL_NS+(0x200*i), value); |
128 | 128 | ||
129 | // enable VIP optional active (VIP_OPT_AL) for direct output. | 129 | // enable VIP optional active (VIP_OPT_AL) for direct output. |
130 | value = cx25821_i2c_read(&dev->i2c_bus[0], OUT_CTRL1+(0x200*i), &tmp); | 130 | value = cx25821_i2c_read(&dev->i2c_bus[0], OUT_CTRL1+(0x200*i), &tmp); |
131 | value &= 0xFFFBFFFF; | 131 | value &= 0xFFFBFFFF; |
132 | value |= 0x00040000; | 132 | value |= 0x00040000; |
133 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], OUT_CTRL1+(0x200*i), value); | 133 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], OUT_CTRL1+(0x200*i), value); |
134 | 134 | ||
135 | // clear VPRES_VERT_EN bit, fixes the chroma run away problem | 135 | // clear VPRES_VERT_EN bit, fixes the chroma run away problem |
136 | // when the input switching rate < 16 fields | 136 | // when the input switching rate < 16 fields |
137 | // | 137 | // |
138 | value = cx25821_i2c_read(&dev->i2c_bus[0], MISC_TIM_CTRL+(0x200*i), &tmp); | 138 | value = cx25821_i2c_read(&dev->i2c_bus[0], MISC_TIM_CTRL+(0x200*i), &tmp); |
139 | value = setBitAtPos(value, 14); // disable special play detection | 139 | value = setBitAtPos(value, 14); // disable special play detection |
140 | value = clearBitAtPos(value, 15); | 140 | value = clearBitAtPos(value, 15); |
141 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], MISC_TIM_CTRL+(0x200*i), value); | 141 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], MISC_TIM_CTRL+(0x200*i), value); |
142 | 142 | ||
143 | // set vbi_gate_en to 0 | 143 | // set vbi_gate_en to 0 |
144 | value = cx25821_i2c_read(&dev->i2c_bus[0], DFE_CTRL1+(0x200*i), &tmp); | 144 | value = cx25821_i2c_read(&dev->i2c_bus[0], DFE_CTRL1+(0x200*i), &tmp); |
145 | value = clearBitAtPos(value, 29); | 145 | value = clearBitAtPos(value, 29); |
146 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DFE_CTRL1+(0x200*i), value); | 146 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DFE_CTRL1+(0x200*i), value); |
147 | 147 | ||
148 | // Enable the generation of blue field output if no video | 148 | // Enable the generation of blue field output if no video |
149 | medusa_enable_bluefield_output(dev, i, 1); | 149 | medusa_enable_bluefield_output(dev, i, 1); |
150 | } | 150 | } |
151 | 151 | ||
152 | 152 | ||
153 | for (i=0; i < MAX_ENCODERS; i++) | 153 | for (i=0; i < MAX_ENCODERS; i++) |
154 | { | 154 | { |
155 | // NTSC hclock | 155 | // NTSC hclock |
156 | value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_1+(0x100*i), &tmp); | 156 | value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_1+(0x100*i), &tmp); |
157 | value &= 0xF000FC00; | 157 | value &= 0xF000FC00; |
158 | value |= 0x06B402D0; | 158 | value |= 0x06B402D0; |
159 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_1+(0x100*i), value); | 159 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_1+(0x100*i), value); |
160 | 160 | ||
161 | // burst begin and burst end | 161 | // burst begin and burst end |
162 | value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_2+(0x100*i), &tmp); | 162 | value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_2+(0x100*i), &tmp); |
163 | value &= 0xFF000000; | 163 | value &= 0xFF000000; |
164 | value |= 0x007E9054; | 164 | value |= 0x007E9054; |
165 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_2+(0x100*i), value); | 165 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_2+(0x100*i), value); |
166 | 166 | ||
167 | value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_3+(0x100*i), &tmp); | 167 | value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_3+(0x100*i), &tmp); |
168 | value &= 0xFC00FE00; | 168 | value &= 0xFC00FE00; |
169 | value |= 0x00EC00F0; | 169 | value |= 0x00EC00F0; |
170 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_3+(0x100*i), value); | 170 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_3+(0x100*i), value); |
171 | 171 | ||
172 | // set NTSC vblank, no phase alternation, 7.5 IRE pedestal | 172 | // set NTSC vblank, no phase alternation, 7.5 IRE pedestal |
173 | value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_4+(0x100*i), &tmp); | 173 | value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_4+(0x100*i), &tmp); |
174 | value &= 0x00FCFFFF; | 174 | value &= 0x00FCFFFF; |
175 | value |= 0x13020000; | 175 | value |= 0x13020000; |
176 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_4+(0x100*i), value); | 176 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_4+(0x100*i), value); |
177 | 177 | ||
178 | value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_5+(0x100*i), &tmp); | 178 | value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_5+(0x100*i), &tmp); |
179 | value &= 0xFFFF0000; | 179 | value &= 0xFFFF0000; |
180 | value |= 0x0000E575; | 180 | value |= 0x0000E575; |
181 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_5+(0x100*i), value); | 181 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_5+(0x100*i), value); |
182 | 182 | ||
183 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_6+(0x100*i), 0x009A89C1); | 183 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_6+(0x100*i), 0x009A89C1); |
184 | 184 | ||
185 | // Subcarrier Increment | 185 | // Subcarrier Increment |
186 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_7+(0x100*i), 0x21F07C1F); | 186 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_7+(0x100*i), 0x21F07C1F); |
187 | } | 187 | } |
188 | 188 | ||
189 | 189 | ||
@@ -206,23 +206,23 @@ static int medusa_PALCombInit(struct cx25821_dev *dev, int dec) | |||
206 | { | 206 | { |
207 | int ret_val = -1; | 207 | int ret_val = -1; |
208 | u32 value = 0, tmp = 0; | 208 | u32 value = 0, tmp = 0; |
209 | 209 | ||
210 | // Setup for 2D threshold | 210 | // Setup for 2D threshold |
211 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], COMB_2D_HFS_CFG+(0x200*dec), 0x20002861); | 211 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], COMB_2D_HFS_CFG+(0x200*dec), 0x20002861); |
212 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], COMB_2D_HFD_CFG+(0x200*dec), 0x20002861); | 212 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], COMB_2D_HFD_CFG+(0x200*dec), 0x20002861); |
213 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], COMB_2D_LF_CFG+(0x200*dec), 0x200A1023); | 213 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], COMB_2D_LF_CFG+(0x200*dec), 0x200A1023); |
214 | 214 | ||
215 | // Setup flat chroma and luma thresholds | 215 | // Setup flat chroma and luma thresholds |
216 | value = cx25821_i2c_read(&dev->i2c_bus[0], COMB_FLAT_THRESH_CTRL+(0x200*dec), &tmp); | 216 | value = cx25821_i2c_read(&dev->i2c_bus[0], COMB_FLAT_THRESH_CTRL+(0x200*dec), &tmp); |
217 | value &= 0x06230000; | 217 | value &= 0x06230000; |
218 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], COMB_FLAT_THRESH_CTRL+(0x200*dec), value); | 218 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], COMB_FLAT_THRESH_CTRL+(0x200*dec), value); |
219 | 219 | ||
220 | // set comb 2D blend | 220 | // set comb 2D blend |
221 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], COMB_2D_BLEND+(0x200*dec), 0x210F0F0F); | 221 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], COMB_2D_BLEND+(0x200*dec), 0x210F0F0F); |
222 | 222 | ||
223 | // COMB MISC CONTROL | 223 | // COMB MISC CONTROL |
224 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], COMB_MISC_CTRL+(0x200*dec), 0x41120A7F); | 224 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], COMB_MISC_CTRL+(0x200*dec), 0x41120A7F); |
225 | 225 | ||
226 | return ret_val; | 226 | return ret_val; |
227 | } | 227 | } |
228 | 228 | ||
@@ -235,110 +235,110 @@ static int medusa_initialize_pal(struct cx25821_dev *dev) | |||
235 | u32 tmp = 0; | 235 | u32 tmp = 0; |
236 | 236 | ||
237 | mutex_lock(&dev->lock); | 237 | mutex_lock(&dev->lock); |
238 | 238 | ||
239 | for (i=0; i < MAX_DECODERS; i++) | 239 | for (i=0; i < MAX_DECODERS; i++) |
240 | { | 240 | { |
241 | // set video format PAL-BDGHI | 241 | // set video format PAL-BDGHI |
242 | value = cx25821_i2c_read(&dev->i2c_bus[0], MODE_CTRL+(0x200*i), &tmp); | 242 | value = cx25821_i2c_read(&dev->i2c_bus[0], MODE_CTRL+(0x200*i), &tmp); |
243 | value &= 0xFFFFFFF0; | 243 | value &= 0xFFFFFFF0; |
244 | value |= 0x10004; // enable the fast locking mode bit[16] | 244 | value |= 0x10004; // enable the fast locking mode bit[16] |
245 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], MODE_CTRL+(0x200*i), value); | 245 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], MODE_CTRL+(0x200*i), value); |
246 | 246 | ||
247 | 247 | ||
248 | // resolution PAL 720x576 | 248 | // resolution PAL 720x576 |
249 | value = cx25821_i2c_read(&dev->i2c_bus[0], HORIZ_TIM_CTRL+(0x200*i), &tmp); | 249 | value = cx25821_i2c_read(&dev->i2c_bus[0], HORIZ_TIM_CTRL+(0x200*i), &tmp); |
250 | value &= 0x00C00C00; | 250 | value &= 0x00C00C00; |
251 | value |= 0x632D007D; | 251 | value |= 0x632D007D; |
252 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], HORIZ_TIM_CTRL+(0x200*i), value); | 252 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], HORIZ_TIM_CTRL+(0x200*i), value); |
253 | 253 | ||
254 | // vblank656_cnt=x26, vactive_cnt=240h, vblank_cnt=x24 | 254 | // vblank656_cnt=x26, vactive_cnt=240h, vblank_cnt=x24 |
255 | value = cx25821_i2c_read(&dev->i2c_bus[0], VERT_TIM_CTRL+(0x200*i), &tmp); | 255 | value = cx25821_i2c_read(&dev->i2c_bus[0], VERT_TIM_CTRL+(0x200*i), &tmp); |
256 | value &= 0x00C00C00; | 256 | value &= 0x00C00C00; |
257 | value |= 0x28240026; // vblank_cnt + 2 to get camera ID | 257 | value |= 0x28240026; // vblank_cnt + 2 to get camera ID |
258 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], VERT_TIM_CTRL+(0x200*i), value); | 258 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], VERT_TIM_CTRL+(0x200*i), value); |
259 | 259 | ||
260 | // chroma subcarrier step size | 260 | // chroma subcarrier step size |
261 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], SC_STEP_SIZE+(0x200*i), 0x5411E2D0); | 261 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], SC_STEP_SIZE+(0x200*i), 0x5411E2D0); |
262 | 262 | ||
263 | // enable VIP optional active | 263 | // enable VIP optional active |
264 | value = cx25821_i2c_read(&dev->i2c_bus[0], OUT_CTRL_NS+(0x200*i), &tmp); | 264 | value = cx25821_i2c_read(&dev->i2c_bus[0], OUT_CTRL_NS+(0x200*i), &tmp); |
265 | value &= 0xFFFBFFFF; | 265 | value &= 0xFFFBFFFF; |
266 | value |= 0x00040000; | 266 | value |= 0x00040000; |
267 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], OUT_CTRL_NS+(0x200*i), value); | 267 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], OUT_CTRL_NS+(0x200*i), value); |
268 | 268 | ||
269 | // enable VIP optional active (VIP_OPT_AL) for direct output. | 269 | // enable VIP optional active (VIP_OPT_AL) for direct output. |
270 | value = cx25821_i2c_read(&dev->i2c_bus[0], OUT_CTRL1+(0x200*i), &tmp); | 270 | value = cx25821_i2c_read(&dev->i2c_bus[0], OUT_CTRL1+(0x200*i), &tmp); |
271 | value &= 0xFFFBFFFF; | 271 | value &= 0xFFFBFFFF; |
272 | value |= 0x00040000; | 272 | value |= 0x00040000; |
273 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], OUT_CTRL1+(0x200*i), value); | 273 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], OUT_CTRL1+(0x200*i), value); |
274 | 274 | ||
275 | // clear VPRES_VERT_EN bit, fixes the chroma run away problem | 275 | // clear VPRES_VERT_EN bit, fixes the chroma run away problem |
276 | // when the input switching rate < 16 fields | 276 | // when the input switching rate < 16 fields |
277 | value = cx25821_i2c_read(&dev->i2c_bus[0], MISC_TIM_CTRL+(0x200*i), &tmp); | 277 | value = cx25821_i2c_read(&dev->i2c_bus[0], MISC_TIM_CTRL+(0x200*i), &tmp); |
278 | value = setBitAtPos(value, 14); // disable special play detection | 278 | value = setBitAtPos(value, 14); // disable special play detection |
279 | value = clearBitAtPos(value, 15); | 279 | value = clearBitAtPos(value, 15); |
280 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], MISC_TIM_CTRL+(0x200*i), value); | 280 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], MISC_TIM_CTRL+(0x200*i), value); |
281 | 281 | ||
282 | // set vbi_gate_en to 0 | 282 | // set vbi_gate_en to 0 |
283 | value = cx25821_i2c_read(&dev->i2c_bus[0], DFE_CTRL1+(0x200*i), &tmp); | 283 | value = cx25821_i2c_read(&dev->i2c_bus[0], DFE_CTRL1+(0x200*i), &tmp); |
284 | value = clearBitAtPos(value, 29); | 284 | value = clearBitAtPos(value, 29); |
285 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DFE_CTRL1+(0x200*i), value); | 285 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DFE_CTRL1+(0x200*i), value); |
286 | 286 | ||
287 | medusa_PALCombInit(dev, i); | 287 | medusa_PALCombInit(dev, i); |
288 | 288 | ||
289 | // Enable the generation of blue field output if no video | 289 | // Enable the generation of blue field output if no video |
290 | medusa_enable_bluefield_output(dev, i, 1); | 290 | medusa_enable_bluefield_output(dev, i, 1); |
291 | } | 291 | } |
292 | 292 | ||
293 | 293 | ||
294 | for (i=0; i < MAX_ENCODERS; i++) | 294 | for (i=0; i < MAX_ENCODERS; i++) |
295 | { | 295 | { |
296 | // PAL hclock | 296 | // PAL hclock |
297 | value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_1+(0x100*i), &tmp); | 297 | value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_1+(0x100*i), &tmp); |
298 | value &= 0xF000FC00; | 298 | value &= 0xF000FC00; |
299 | value |= 0x06C002D0; | 299 | value |= 0x06C002D0; |
300 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_1+(0x100*i), value); | 300 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_1+(0x100*i), value); |
301 | 301 | ||
302 | // burst begin and burst end | 302 | // burst begin and burst end |
303 | value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_2+(0x100*i), &tmp); | 303 | value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_2+(0x100*i), &tmp); |
304 | value &= 0xFF000000; | 304 | value &= 0xFF000000; |
305 | value |= 0x007E9754; | 305 | value |= 0x007E9754; |
306 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_2+(0x100*i), value); | 306 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_2+(0x100*i), value); |
307 | 307 | ||
308 | // hblank and vactive | 308 | // hblank and vactive |
309 | value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_3+(0x100*i), &tmp); | 309 | value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_3+(0x100*i), &tmp); |
310 | value &= 0xFC00FE00; | 310 | value &= 0xFC00FE00; |
311 | value |= 0x00FC0120; | 311 | value |= 0x00FC0120; |
312 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_3+(0x100*i), value); | 312 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_3+(0x100*i), value); |
313 | 313 | ||
314 | // set PAL vblank, phase alternation, 0 IRE pedestal | 314 | // set PAL vblank, phase alternation, 0 IRE pedestal |
315 | value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_4+(0x100*i), &tmp); | 315 | value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_4+(0x100*i), &tmp); |
316 | value &= 0x00FCFFFF; | 316 | value &= 0x00FCFFFF; |
317 | value |= 0x14010000; | 317 | value |= 0x14010000; |
318 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_4+(0x100*i), value); | 318 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_4+(0x100*i), value); |
319 | 319 | ||
320 | 320 | ||
321 | value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_5+(0x100*i), &tmp); | 321 | value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_5+(0x100*i), &tmp); |
322 | value &= 0xFFFF0000; | 322 | value &= 0xFFFF0000; |
323 | value |= 0x0000F078; | 323 | value |= 0x0000F078; |
324 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_5+(0x100*i), value); | 324 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_5+(0x100*i), value); |
325 | 325 | ||
326 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_6+(0x100*i), 0x00A493CF); | 326 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_6+(0x100*i), 0x00A493CF); |
327 | 327 | ||
328 | // Subcarrier Increment | 328 | // Subcarrier Increment |
329 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_7+(0x100*i), 0x2A098ACB); | 329 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_7+(0x100*i), 0x2A098ACB); |
330 | } | 330 | } |
331 | 331 | ||
332 | 332 | ||
333 | //set picture resolutions | 333 | //set picture resolutions |
334 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], HSCALE_CTRL, 0x0); //0 - 720 | 334 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], HSCALE_CTRL, 0x0); //0 - 720 |
335 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], VSCALE_CTRL, 0x0); //0 - 576 | 335 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], VSCALE_CTRL, 0x0); //0 - 576 |
336 | 336 | ||
337 | // set Bypass input format to PAL 625 lines | 337 | // set Bypass input format to PAL 625 lines |
338 | value = cx25821_i2c_read(&dev->i2c_bus[0], BYP_AB_CTRL, &tmp); | 338 | value = cx25821_i2c_read(&dev->i2c_bus[0], BYP_AB_CTRL, &tmp); |
339 | value &= 0xFFF7FDFF; | 339 | value &= 0xFFF7FDFF; |
340 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], BYP_AB_CTRL, value); | 340 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], BYP_AB_CTRL, value); |
341 | 341 | ||
342 | mutex_unlock(&dev->lock); | 342 | mutex_unlock(&dev->lock); |
343 | 343 | ||
344 | return ret_val; | 344 | return ret_val; |
@@ -350,26 +350,26 @@ int medusa_set_videostandard(struct cx25821_dev *dev) | |||
350 | int status = STATUS_SUCCESS; | 350 | int status = STATUS_SUCCESS; |
351 | u32 value = 0, tmp = 0; | 351 | u32 value = 0, tmp = 0; |
352 | 352 | ||
353 | 353 | ||
354 | if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) | 354 | if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) |
355 | { | 355 | { |
356 | status = medusa_initialize_pal(dev); | 356 | status = medusa_initialize_pal(dev); |
357 | } | 357 | } |
358 | else | 358 | else |
359 | { | 359 | { |
360 | status = medusa_initialize_ntsc(dev); | 360 | status = medusa_initialize_ntsc(dev); |
361 | } | 361 | } |
362 | 362 | ||
363 | // Enable DENC_A output | 363 | // Enable DENC_A output |
364 | value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_4, &tmp); | 364 | value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_4, &tmp); |
365 | value = setBitAtPos(value, 4); | 365 | value = setBitAtPos(value, 4); |
366 | status = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_4, value); | 366 | status = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_4, value); |
367 | 367 | ||
368 | // Enable DENC_B output | 368 | // Enable DENC_B output |
369 | value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_B_REG_4, &tmp); | 369 | value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_B_REG_4, &tmp); |
370 | value = setBitAtPos(value, 4); | 370 | value = setBitAtPos(value, 4); |
371 | status = cx25821_i2c_write(&dev->i2c_bus[0], DENC_B_REG_4, value); | 371 | status = cx25821_i2c_write(&dev->i2c_bus[0], DENC_B_REG_4, value); |
372 | 372 | ||
373 | return status; | 373 | return status; |
374 | } | 374 | } |
375 | 375 | ||
@@ -380,7 +380,7 @@ void medusa_set_resolution(struct cx25821_dev *dev, int width, int decoder_selec | |||
380 | int decoder_count = 0; | 380 | int decoder_count = 0; |
381 | int ret_val = 0; | 381 | int ret_val = 0; |
382 | u32 hscale = 0x0; | 382 | u32 hscale = 0x0; |
383 | u32 vscale = 0x0; | 383 | u32 vscale = 0x0; |
384 | const int MAX_WIDTH = 720; | 384 | const int MAX_WIDTH = 720; |
385 | 385 | ||
386 | mutex_lock(&dev->lock); | 386 | mutex_lock(&dev->lock); |
@@ -388,55 +388,55 @@ void medusa_set_resolution(struct cx25821_dev *dev, int width, int decoder_selec | |||
388 | // validate the width - cannot be negative | 388 | // validate the width - cannot be negative |
389 | if (width > MAX_WIDTH) | 389 | if (width > MAX_WIDTH) |
390 | { | 390 | { |
391 | printk("cx25821 %s() : width %d > MAX_WIDTH %d ! resetting to MAX_WIDTH \n", __func__, width, MAX_WIDTH); | 391 | printk("cx25821 %s() : width %d > MAX_WIDTH %d ! resetting to MAX_WIDTH \n", __func__, width, MAX_WIDTH); |
392 | width = MAX_WIDTH; | 392 | width = MAX_WIDTH; |
393 | } | 393 | } |
394 | 394 | ||
395 | if( decoder_select <= 7 && decoder_select >= 0 ) | 395 | if( decoder_select <= 7 && decoder_select >= 0 ) |
396 | { | 396 | { |
397 | decoder = decoder_select; | 397 | decoder = decoder_select; |
398 | decoder_count = decoder_select + 1; | 398 | decoder_count = decoder_select + 1; |
399 | } | 399 | } |
400 | else | 400 | else |
401 | { | 401 | { |
402 | decoder = 0; | 402 | decoder = 0; |
403 | decoder_count = _num_decoders; | 403 | decoder_count = _num_decoders; |
404 | } | 404 | } |
405 | |||
406 | |||
407 | switch( width ) | ||
408 | { | ||
409 | case 320: | ||
410 | hscale = 0x13E34B; | ||
411 | vscale = 0x0; | ||
412 | break; | ||
413 | |||
414 | case 352: | ||
415 | hscale = 0x10A273; | ||
416 | vscale = 0x0; | ||
417 | break; | ||
418 | |||
419 | case 176: | ||
420 | hscale = 0x3115B2; | ||
421 | vscale = 0x1E00; | ||
422 | break; | ||
423 | 405 | ||
424 | case 160: | ||
425 | hscale = 0x378D84; | ||
426 | vscale = 0x1E00; | ||
427 | break; | ||
428 | 406 | ||
429 | default: //720 | 407 | switch( width ) |
430 | hscale = 0x0; | 408 | { |
431 | vscale = 0x0; | 409 | case 320: |
432 | break; | 410 | hscale = 0x13E34B; |
433 | } | 411 | vscale = 0x0; |
412 | break; | ||
413 | |||
414 | case 352: | ||
415 | hscale = 0x10A273; | ||
416 | vscale = 0x0; | ||
417 | break; | ||
418 | |||
419 | case 176: | ||
420 | hscale = 0x3115B2; | ||
421 | vscale = 0x1E00; | ||
422 | break; | ||
423 | |||
424 | case 160: | ||
425 | hscale = 0x378D84; | ||
426 | vscale = 0x1E00; | ||
427 | break; | ||
428 | |||
429 | default: //720 | ||
430 | hscale = 0x0; | ||
431 | vscale = 0x0; | ||
432 | break; | ||
433 | } | ||
434 | 434 | ||
435 | for( ; decoder < decoder_count; decoder++) | 435 | for( ; decoder < decoder_count; decoder++) |
436 | { | 436 | { |
437 | // write scaling values for each decoder | 437 | // write scaling values for each decoder |
438 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], HSCALE_CTRL+(0x200*decoder), hscale); | 438 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], HSCALE_CTRL+(0x200*decoder), hscale); |
439 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], VSCALE_CTRL+(0x200*decoder), vscale); | 439 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], VSCALE_CTRL+(0x200*decoder), vscale); |
440 | } | 440 | } |
441 | 441 | ||
442 | mutex_unlock(&dev->lock); | 442 | mutex_unlock(&dev->lock); |
@@ -448,52 +448,52 @@ static void medusa_set_decoderduration(struct cx25821_dev *dev, int decoder, int | |||
448 | u32 fld_cnt = 0; | 448 | u32 fld_cnt = 0; |
449 | u32 tmp = 0; | 449 | u32 tmp = 0; |
450 | u32 disp_cnt_reg = DISP_AB_CNT; | 450 | u32 disp_cnt_reg = DISP_AB_CNT; |
451 | 451 | ||
452 | mutex_lock(&dev->lock); | 452 | mutex_lock(&dev->lock); |
453 | 453 | ||
454 | // no support | 454 | // no support |
455 | if (decoder < VDEC_A && decoder > VDEC_H) | 455 | if (decoder < VDEC_A && decoder > VDEC_H) |
456 | { | 456 | { |
457 | mutex_unlock(&dev->lock); | 457 | mutex_unlock(&dev->lock); |
458 | return; | 458 | return; |
459 | } | 459 | } |
460 | 460 | ||
461 | switch (decoder) | 461 | switch (decoder) |
462 | { | 462 | { |
463 | default: | 463 | default: |
464 | break; | 464 | break; |
465 | case VDEC_C: | 465 | case VDEC_C: |
466 | case VDEC_D: | 466 | case VDEC_D: |
467 | disp_cnt_reg = DISP_CD_CNT; | 467 | disp_cnt_reg = DISP_CD_CNT; |
468 | break; | 468 | break; |
469 | case VDEC_E: | 469 | case VDEC_E: |
470 | case VDEC_F: | 470 | case VDEC_F: |
471 | disp_cnt_reg = DISP_EF_CNT; | 471 | disp_cnt_reg = DISP_EF_CNT; |
472 | break; | 472 | break; |
473 | case VDEC_G: | 473 | case VDEC_G: |
474 | case VDEC_H: | 474 | case VDEC_H: |
475 | disp_cnt_reg = DISP_GH_CNT; | 475 | disp_cnt_reg = DISP_GH_CNT; |
476 | break; | 476 | break; |
477 | } | 477 | } |
478 | 478 | ||
479 | _display_field_cnt[decoder] = duration; | 479 | _display_field_cnt[decoder] = duration; |
480 | 480 | ||
481 | // update hardware | 481 | // update hardware |
482 | fld_cnt = cx25821_i2c_read(&dev->i2c_bus[0], disp_cnt_reg, &tmp); | 482 | fld_cnt = cx25821_i2c_read(&dev->i2c_bus[0], disp_cnt_reg, &tmp); |
483 | 483 | ||
484 | if (!(decoder % 2)) // EVEN decoder | 484 | if (!(decoder % 2)) // EVEN decoder |
485 | { | 485 | { |
486 | fld_cnt &= 0xFFFF0000; | 486 | fld_cnt &= 0xFFFF0000; |
487 | fld_cnt |= duration; | 487 | fld_cnt |= duration; |
488 | } | 488 | } |
489 | else | 489 | else |
490 | { | 490 | { |
491 | fld_cnt &= 0x0000FFFF; | 491 | fld_cnt &= 0x0000FFFF; |
492 | fld_cnt |= ((u32)duration) << 16; | 492 | fld_cnt |= ((u32)duration) << 16; |
493 | } | 493 | } |
494 | 494 | ||
495 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], disp_cnt_reg, fld_cnt); | 495 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], disp_cnt_reg, fld_cnt); |
496 | 496 | ||
497 | mutex_unlock(&dev->lock); | 497 | mutex_unlock(&dev->lock); |
498 | } | 498 | } |
499 | 499 | ||
@@ -514,7 +514,7 @@ static int mapM( | |||
514 | 514 | ||
515 | if((srcMin == srcMax) || (srcVal < srcMin) || (srcVal > srcMax)) | 515 | if((srcMin == srcMax) || (srcVal < srcMin) || (srcVal > srcMax)) |
516 | { | 516 | { |
517 | return -1; | 517 | return -1; |
518 | } | 518 | } |
519 | 519 | ||
520 | // This is the overall expression used: | 520 | // This is the overall expression used: |
@@ -527,7 +527,7 @@ static int mapM( | |||
527 | 527 | ||
528 | if(2 * ( numerator % denominator ) >= denominator) | 528 | if(2 * ( numerator % denominator ) >= denominator) |
529 | { | 529 | { |
530 | quotient++; | 530 | quotient++; |
531 | } | 531 | } |
532 | 532 | ||
533 | *dstVal = quotient + dstMin; | 533 | *dstVal = quotient + dstMin; |
@@ -540,12 +540,12 @@ static unsigned long convert_to_twos(long numeric, unsigned long bits_len) | |||
540 | unsigned char temp; | 540 | unsigned char temp; |
541 | 541 | ||
542 | if (numeric >= 0) | 542 | if (numeric >= 0) |
543 | return numeric; | 543 | return numeric; |
544 | else | 544 | else |
545 | { | 545 | { |
546 | temp = ~(abs(numeric) & 0xFF); | 546 | temp = ~(abs(numeric) & 0xFF); |
547 | temp += 1; | 547 | temp += 1; |
548 | return temp; | 548 | return temp; |
549 | } | 549 | } |
550 | } | 550 | } |
551 | ///////////////////////////////////////////////////////////////////////////////////////// | 551 | ///////////////////////////////////////////////////////////////////////////////////////// |
@@ -558,8 +558,8 @@ int medusa_set_brightness(struct cx25821_dev *dev, int brightness, int decoder) | |||
558 | mutex_lock(&dev->lock); | 558 | mutex_lock(&dev->lock); |
559 | if((brightness > VIDEO_PROCAMP_MAX) || (brightness < VIDEO_PROCAMP_MIN)) | 559 | if((brightness > VIDEO_PROCAMP_MAX) || (brightness < VIDEO_PROCAMP_MIN)) |
560 | { | 560 | { |
561 | mutex_unlock(&dev->lock); | 561 | mutex_unlock(&dev->lock); |
562 | return -1; | 562 | return -1; |
563 | } | 563 | } |
564 | ret_val = mapM(VIDEO_PROCAMP_MIN, VIDEO_PROCAMP_MAX, brightness, SIGNED_BYTE_MIN, SIGNED_BYTE_MAX, &value); | 564 | ret_val = mapM(VIDEO_PROCAMP_MIN, VIDEO_PROCAMP_MAX, brightness, SIGNED_BYTE_MIN, SIGNED_BYTE_MAX, &value); |
565 | value = convert_to_twos(value, 8); | 565 | value = convert_to_twos(value, 8); |
@@ -578,11 +578,11 @@ int medusa_set_contrast(struct cx25821_dev *dev, int contrast, int decoder) | |||
578 | u32 val = 0, tmp = 0; | 578 | u32 val = 0, tmp = 0; |
579 | 579 | ||
580 | mutex_lock(&dev->lock); | 580 | mutex_lock(&dev->lock); |
581 | 581 | ||
582 | if((contrast > VIDEO_PROCAMP_MAX) || (contrast < VIDEO_PROCAMP_MIN)) | 582 | if((contrast > VIDEO_PROCAMP_MAX) || (contrast < VIDEO_PROCAMP_MIN)) |
583 | { | 583 | { |
584 | mutex_unlock(&dev->lock); | 584 | mutex_unlock(&dev->lock); |
585 | return -1; | 585 | return -1; |
586 | } | 586 | } |
587 | 587 | ||
588 | ret_val = mapM(VIDEO_PROCAMP_MIN, VIDEO_PROCAMP_MAX, contrast, UNSIGNED_BYTE_MIN, UNSIGNED_BYTE_MAX, &value); | 588 | ret_val = mapM(VIDEO_PROCAMP_MIN, VIDEO_PROCAMP_MAX, contrast, UNSIGNED_BYTE_MIN, UNSIGNED_BYTE_MAX, &value); |
@@ -602,15 +602,15 @@ int medusa_set_hue(struct cx25821_dev *dev, int hue, int decoder) | |||
602 | u32 val = 0, tmp = 0; | 602 | u32 val = 0, tmp = 0; |
603 | 603 | ||
604 | mutex_lock(&dev->lock); | 604 | mutex_lock(&dev->lock); |
605 | 605 | ||
606 | if((hue > VIDEO_PROCAMP_MAX) || (hue < VIDEO_PROCAMP_MIN)) | 606 | if((hue > VIDEO_PROCAMP_MAX) || (hue < VIDEO_PROCAMP_MIN)) |
607 | { | 607 | { |
608 | mutex_unlock(&dev->lock); | 608 | mutex_unlock(&dev->lock); |
609 | return -1; | 609 | return -1; |
610 | } | 610 | } |
611 | 611 | ||
612 | ret_val = mapM(VIDEO_PROCAMP_MIN, VIDEO_PROCAMP_MAX, hue, SIGNED_BYTE_MIN, SIGNED_BYTE_MAX, &value); | 612 | ret_val = mapM(VIDEO_PROCAMP_MIN, VIDEO_PROCAMP_MAX, hue, SIGNED_BYTE_MIN, SIGNED_BYTE_MAX, &value); |
613 | 613 | ||
614 | value = convert_to_twos(value, 8); | 614 | value = convert_to_twos(value, 8); |
615 | val = cx25821_i2c_read(&dev->i2c_bus[0], VDEC_A_HUE_CTRL+(0x200*decoder), &tmp); | 615 | val = cx25821_i2c_read(&dev->i2c_bus[0], VDEC_A_HUE_CTRL+(0x200*decoder), &tmp); |
616 | val &= 0xFFFFFF00; | 616 | val &= 0xFFFFFF00; |
@@ -628,25 +628,25 @@ int medusa_set_saturation(struct cx25821_dev *dev, int saturation, int decoder) | |||
628 | int ret_val = 0; | 628 | int ret_val = 0; |
629 | int value = 0; | 629 | int value = 0; |
630 | u32 val = 0, tmp = 0; | 630 | u32 val = 0, tmp = 0; |
631 | 631 | ||
632 | mutex_lock(&dev->lock); | 632 | mutex_lock(&dev->lock); |
633 | 633 | ||
634 | if((saturation > VIDEO_PROCAMP_MAX) || (saturation < VIDEO_PROCAMP_MIN)) | 634 | if((saturation > VIDEO_PROCAMP_MAX) || (saturation < VIDEO_PROCAMP_MIN)) |
635 | { | 635 | { |
636 | mutex_unlock(&dev->lock); | 636 | mutex_unlock(&dev->lock); |
637 | return -1; | 637 | return -1; |
638 | } | 638 | } |
639 | 639 | ||
640 | ret_val = mapM(VIDEO_PROCAMP_MIN, VIDEO_PROCAMP_MAX, saturation, UNSIGNED_BYTE_MIN, UNSIGNED_BYTE_MAX, &value); | 640 | ret_val = mapM(VIDEO_PROCAMP_MIN, VIDEO_PROCAMP_MAX, saturation, UNSIGNED_BYTE_MIN, UNSIGNED_BYTE_MAX, &value); |
641 | 641 | ||
642 | val = cx25821_i2c_read(&dev->i2c_bus[0], VDEC_A_USAT_CTRL+(0x200*decoder), &tmp); | 642 | val = cx25821_i2c_read(&dev->i2c_bus[0], VDEC_A_USAT_CTRL+(0x200*decoder), &tmp); |
643 | val &= 0xFFFFFF00; | 643 | val &= 0xFFFFFF00; |
644 | ret_val |= cx25821_i2c_write(&dev->i2c_bus[0], VDEC_A_USAT_CTRL+(0x200*decoder), val | value); | 644 | ret_val |= cx25821_i2c_write(&dev->i2c_bus[0], VDEC_A_USAT_CTRL+(0x200*decoder), val | value); |
645 | 645 | ||
646 | val = cx25821_i2c_read(&dev->i2c_bus[0], VDEC_A_VSAT_CTRL+(0x200*decoder), &tmp); | 646 | val = cx25821_i2c_read(&dev->i2c_bus[0], VDEC_A_VSAT_CTRL+(0x200*decoder), &tmp); |
647 | val &= 0xFFFFFF00; | 647 | val &= 0xFFFFFF00; |
648 | ret_val |= cx25821_i2c_write(&dev->i2c_bus[0], VDEC_A_VSAT_CTRL+(0x200*decoder), val | value); | 648 | ret_val |= cx25821_i2c_write(&dev->i2c_bus[0], VDEC_A_VSAT_CTRL+(0x200*decoder), val | value); |
649 | 649 | ||
650 | mutex_unlock(&dev->lock); | 650 | mutex_unlock(&dev->lock); |
651 | return ret_val; | 651 | return ret_val; |
652 | } | 652 | } |
@@ -660,75 +660,75 @@ int medusa_video_init(struct cx25821_dev *dev) | |||
660 | u32 value = 0, tmp = 0; | 660 | u32 value = 0, tmp = 0; |
661 | int ret_val = 0; | 661 | int ret_val = 0; |
662 | int i=0; | 662 | int i=0; |
663 | 663 | ||
664 | mutex_lock(&dev->lock); | 664 | mutex_lock(&dev->lock); |
665 | 665 | ||
666 | _num_decoders = dev->_max_num_decoders; | 666 | _num_decoders = dev->_max_num_decoders; |
667 | 667 | ||
668 | 668 | ||
669 | // disable Auto source selection on all video decoders | 669 | // disable Auto source selection on all video decoders |
670 | value = cx25821_i2c_read(&dev->i2c_bus[0], MON_A_CTRL, &tmp); | 670 | value = cx25821_i2c_read(&dev->i2c_bus[0], MON_A_CTRL, &tmp); |
671 | value &= 0xFFFFF0FF; | 671 | value &= 0xFFFFF0FF; |
672 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], MON_A_CTRL, value); | 672 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], MON_A_CTRL, value); |
673 | 673 | ||
674 | if (ret_val < 0) | 674 | if (ret_val < 0) |
675 | { | 675 | { |
676 | mutex_unlock(&dev->lock); | 676 | mutex_unlock(&dev->lock); |
677 | return -EINVAL; | 677 | return -EINVAL; |
678 | } | 678 | } |
679 | 679 | ||
680 | // Turn off Master source switch enable | 680 | // Turn off Master source switch enable |
681 | value = cx25821_i2c_read(&dev->i2c_bus[0], MON_A_CTRL, &tmp); | 681 | value = cx25821_i2c_read(&dev->i2c_bus[0], MON_A_CTRL, &tmp); |
682 | value &= 0xFFFFFFDF; | 682 | value &= 0xFFFFFFDF; |
683 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], MON_A_CTRL, value); | 683 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], MON_A_CTRL, value); |
684 | 684 | ||
685 | if (ret_val < 0) | 685 | if (ret_val < 0) |
686 | { | 686 | { |
687 | mutex_unlock(&dev->lock); | 687 | mutex_unlock(&dev->lock); |
688 | return -EINVAL; | 688 | return -EINVAL; |
689 | } | 689 | } |
690 | 690 | ||
691 | mutex_unlock(&dev->lock); | 691 | mutex_unlock(&dev->lock); |
692 | 692 | ||
693 | for (i=0; i < _num_decoders; i++) | 693 | for (i=0; i < _num_decoders; i++) |
694 | { | 694 | { |
695 | medusa_set_decoderduration(dev, i, _display_field_cnt[i]); | 695 | medusa_set_decoderduration(dev, i, _display_field_cnt[i]); |
696 | } | 696 | } |
697 | 697 | ||
698 | mutex_lock(&dev->lock); | 698 | mutex_lock(&dev->lock); |
699 | 699 | ||
700 | // Select monitor as DENC A input, power up the DAC | 700 | // Select monitor as DENC A input, power up the DAC |
701 | value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_AB_CTRL, &tmp); | 701 | value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_AB_CTRL, &tmp); |
702 | value &= 0xFF70FF70; | 702 | value &= 0xFF70FF70; |
703 | value |= 0x00090008; // set en_active | 703 | value |= 0x00090008; // set en_active |
704 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_AB_CTRL, value); | 704 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_AB_CTRL, value); |
705 | 705 | ||
706 | if (ret_val < 0) | 706 | if (ret_val < 0) |
707 | { | 707 | { |
708 | mutex_unlock(&dev->lock); | 708 | mutex_unlock(&dev->lock); |
709 | return -EINVAL; | 709 | return -EINVAL; |
710 | } | 710 | } |
711 | 711 | ||
712 | // enable input is VIP/656 | 712 | // enable input is VIP/656 |
713 | value = cx25821_i2c_read(&dev->i2c_bus[0], BYP_AB_CTRL, &tmp); | 713 | value = cx25821_i2c_read(&dev->i2c_bus[0], BYP_AB_CTRL, &tmp); |
714 | value |= 0x00040100; // enable VIP | 714 | value |= 0x00040100; // enable VIP |
715 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], BYP_AB_CTRL, value); | 715 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], BYP_AB_CTRL, value); |
716 | 716 | ||
717 | if (ret_val < 0) | 717 | if (ret_val < 0) |
718 | { | 718 | { |
719 | mutex_unlock(&dev->lock); | 719 | mutex_unlock(&dev->lock); |
720 | return -EINVAL; | 720 | return -EINVAL; |
721 | } | 721 | } |
722 | 722 | ||
723 | // select AFE clock to output mode | 723 | // select AFE clock to output mode |
724 | value = cx25821_i2c_read(&dev->i2c_bus[0], AFE_AB_DIAG_CTRL, &tmp); | 724 | value = cx25821_i2c_read(&dev->i2c_bus[0], AFE_AB_DIAG_CTRL, &tmp); |
725 | value &= 0x83FFFFFF; | 725 | value &= 0x83FFFFFF; |
726 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], AFE_AB_DIAG_CTRL, value | 0x10000000); | 726 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], AFE_AB_DIAG_CTRL, value | 0x10000000); |
727 | 727 | ||
728 | if (ret_val < 0) | 728 | if (ret_val < 0) |
729 | { | 729 | { |
730 | mutex_unlock(&dev->lock); | 730 | mutex_unlock(&dev->lock); |
731 | return -EINVAL; | 731 | return -EINVAL; |
732 | } | 732 | } |
733 | 733 | ||
734 | // Turn on all of the data out and control output pins. | 734 | // Turn on all of the data out and control output pins. |
@@ -736,34 +736,34 @@ int medusa_video_init(struct cx25821_dev *dev) | |||
736 | value &= 0xFEF0FE00; | 736 | value &= 0xFEF0FE00; |
737 | if (_num_decoders == MAX_DECODERS) | 737 | if (_num_decoders == MAX_DECODERS) |
738 | { | 738 | { |
739 | // Note: The octal board does not support control pins(bit16-19). | 739 | // Note: The octal board does not support control pins(bit16-19). |
740 | // These bits are ignored in the octal board. | 740 | // These bits are ignored in the octal board. |
741 | value |= 0x010001F8; // disable VDEC A-C port, default to Mobilygen Interface | 741 | value |= 0x010001F8; // disable VDEC A-C port, default to Mobilygen Interface |
742 | } | 742 | } |
743 | else | 743 | else |
744 | { | 744 | { |
745 | value |= 0x010F0108; // disable VDEC A-C port, default to Mobilygen Interface | 745 | value |= 0x010F0108; // disable VDEC A-C port, default to Mobilygen Interface |
746 | } | 746 | } |
747 | 747 | ||
748 | value |= 7; | 748 | value |= 7; |
749 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], PIN_OE_CTRL, value); | 749 | ret_val = cx25821_i2c_write(&dev->i2c_bus[0], PIN_OE_CTRL, value); |
750 | if (ret_val < 0) | 750 | if (ret_val < 0) |
751 | { | 751 | { |
752 | mutex_unlock(&dev->lock); | 752 | mutex_unlock(&dev->lock); |
753 | return -EINVAL; | 753 | return -EINVAL; |
754 | } | 754 | } |
755 | 755 | ||
756 | mutex_unlock(&dev->lock); | 756 | mutex_unlock(&dev->lock); |
757 | 757 | ||
758 | 758 | ||
759 | ret_val = medusa_set_videostandard(dev); | 759 | ret_val = medusa_set_videostandard(dev); |
760 | 760 | ||
761 | 761 | ||
762 | if (ret_val < 0) | 762 | if (ret_val < 0) |
763 | { | 763 | { |
764 | mutex_unlock(&dev->lock); | 764 | mutex_unlock(&dev->lock); |
765 | return -EINVAL; | 765 | return -EINVAL; |
766 | } | 766 | } |
767 | 767 | ||
768 | return 1; | 768 | return 1; |
769 | } | 769 | } |
diff --git a/drivers/staging/cx25821/cx25821-medusa-video.h b/drivers/staging/cx25821/cx25821-medusa-video.h index 0ba3cc7db5a..f7cb16a7089 100644 --- a/drivers/staging/cx25821/cx25821-medusa-video.h +++ b/drivers/staging/cx25821/cx25821-medusa-video.h | |||
@@ -26,7 +26,7 @@ | |||
26 | #include "cx25821-medusa-defines.h" | 26 | #include "cx25821-medusa-defines.h" |
27 | 27 | ||
28 | 28 | ||
29 | // Color control constants | 29 | // Color control constants |
30 | #define VIDEO_PROCAMP_MIN 0 | 30 | #define VIDEO_PROCAMP_MIN 0 |
31 | #define VIDEO_PROCAMP_MAX 10000 | 31 | #define VIDEO_PROCAMP_MAX 10000 |
32 | #define UNSIGNED_BYTE_MIN 0 | 32 | #define UNSIGNED_BYTE_MIN 0 |
diff --git a/drivers/staging/cx25821/cx25821-reg.h b/drivers/staging/cx25821/cx25821-reg.h index 82f4f16b831..3d98124650c 100644 --- a/drivers/staging/cx25821/cx25821-reg.h +++ b/drivers/staging/cx25821/cx25821-reg.h | |||
@@ -1481,7 +1481,7 @@ | |||
1481 | //***************************************************************************** | 1481 | //***************************************************************************** |
1482 | #define I2C1_ADDR 0x180000 // I2C #1 address | 1482 | #define I2C1_ADDR 0x180000 // I2C #1 address |
1483 | #define FLD_I2C_DADDR 0xfe000000 // RW [31:25] I2C Device Address | 1483 | #define FLD_I2C_DADDR 0xfe000000 // RW [31:25] I2C Device Address |
1484 | // RO [24] reserved | 1484 | // RO [24] reserved |
1485 | //***************************************************************************** | 1485 | //***************************************************************************** |
1486 | #define FLD_I2C_SADDR 0x00FFFFFF // RW [23:0] I2C Sub-address | 1486 | #define FLD_I2C_SADDR 0x00FFFFFF // RW [23:0] I2C Sub-address |
1487 | 1487 | ||
@@ -1494,15 +1494,15 @@ | |||
1494 | #define FLD_I2C_PERIOD 0xFF000000 // RW [31:24] | 1494 | #define FLD_I2C_PERIOD 0xFF000000 // RW [31:24] |
1495 | #define FLD_I2C_SCL_IN 0x00200000 // RW [21] | 1495 | #define FLD_I2C_SCL_IN 0x00200000 // RW [21] |
1496 | #define FLD_I2C_SDA_IN 0x00100000 // RW [20] | 1496 | #define FLD_I2C_SDA_IN 0x00100000 // RW [20] |
1497 | // RO [19:18] reserved | 1497 | // RO [19:18] reserved |
1498 | #define FLD_I2C_SCL_OUT 0x00020000 // RW [17] | 1498 | #define FLD_I2C_SCL_OUT 0x00020000 // RW [17] |
1499 | #define FLD_I2C_SDA_OUT 0x00010000 // RW [16] | 1499 | #define FLD_I2C_SDA_OUT 0x00010000 // RW [16] |
1500 | // RO [15] reserved | 1500 | // RO [15] reserved |
1501 | #define FLD_I2C_DATA_LEN 0x00007000 // RW [14:12] | 1501 | #define FLD_I2C_DATA_LEN 0x00007000 // RW [14:12] |
1502 | #define FLD_I2C_SADDR_INC 0x00000800 // RW [11] | 1502 | #define FLD_I2C_SADDR_INC 0x00000800 // RW [11] |
1503 | // RO [10:9] reserved | 1503 | // RO [10:9] reserved |
1504 | #define FLD_I2C_SADDR_LEN 0x00000300 // RW [9:8] | 1504 | #define FLD_I2C_SADDR_LEN 0x00000300 // RW [9:8] |
1505 | // RO [7:6] reserved | 1505 | // RO [7:6] reserved |
1506 | #define FLD_I2C_SOFT 0x00000020 // RW [5] | 1506 | #define FLD_I2C_SOFT 0x00000020 // RW [5] |
1507 | #define FLD_I2C_NOSTOP 0x00000010 // RW [4] | 1507 | #define FLD_I2C_NOSTOP 0x00000010 // RW [4] |
1508 | #define FLD_I2C_EXTEND 0x00000008 // RW [3] | 1508 | #define FLD_I2C_EXTEND 0x00000008 // RW [3] |
@@ -1588,13 +1588,13 @@ | |||
1588 | 1588 | ||
1589 | //***************************************************************************** | 1589 | //***************************************************************************** |
1590 | // Motion Detection | 1590 | // Motion Detection |
1591 | #define MD_CH0_GRID_BLOCK_YCNT 0x170014 | 1591 | #define MD_CH0_GRID_BLOCK_YCNT 0x170014 |
1592 | #define MD_CH1_GRID_BLOCK_YCNT 0x170094 | 1592 | #define MD_CH1_GRID_BLOCK_YCNT 0x170094 |
1593 | #define MD_CH2_GRID_BLOCK_YCNT 0x170114 | 1593 | #define MD_CH2_GRID_BLOCK_YCNT 0x170114 |
1594 | #define MD_CH3_GRID_BLOCK_YCNT 0x170194 | 1594 | #define MD_CH3_GRID_BLOCK_YCNT 0x170194 |
1595 | #define MD_CH4_GRID_BLOCK_YCNT 0x170214 | 1595 | #define MD_CH4_GRID_BLOCK_YCNT 0x170214 |
1596 | #define MD_CH5_GRID_BLOCK_YCNT 0x170294 | 1596 | #define MD_CH5_GRID_BLOCK_YCNT 0x170294 |
1597 | #define MD_CH6_GRID_BLOCK_YCNT 0x170314 | 1597 | #define MD_CH6_GRID_BLOCK_YCNT 0x170314 |
1598 | #define MD_CH7_GRID_BLOCK_YCNT 0x170394 | 1598 | #define MD_CH7_GRID_BLOCK_YCNT 0x170394 |
1599 | 1599 | ||
1600 | #define PIXEL_FRMT_422 4 | 1600 | #define PIXEL_FRMT_422 4 |
diff --git a/drivers/staging/cx25821/cx25821-video-upstream-ch2.c b/drivers/staging/cx25821/cx25821-video-upstream-ch2.c index ca91b832b01..720729efc31 100644 --- a/drivers/staging/cx25821/cx25821-video-upstream-ch2.c +++ b/drivers/staging/cx25821/cx25821-video-upstream-ch2.c | |||
@@ -44,97 +44,97 @@ static int _intr_msk = FLD_VID_SRC_RISC1 | FLD_VID_SRC_UF | FLD_VID_SRC_SYNC | F | |||
44 | 44 | ||
45 | 45 | ||
46 | static __le32 *cx25821_update_riscprogram_ch2( struct cx25821_dev *dev, | 46 | static __le32 *cx25821_update_riscprogram_ch2( struct cx25821_dev *dev, |
47 | __le32 *rp, unsigned int offset, unsigned int bpl, | 47 | __le32 *rp, unsigned int offset, unsigned int bpl, |
48 | u32 sync_line, unsigned int lines, int fifo_enable, int field_type) | 48 | u32 sync_line, unsigned int lines, int fifo_enable, int field_type) |
49 | { | 49 | { |
50 | unsigned int line, i; | 50 | unsigned int line, i; |
51 | int dist_betwn_starts = bpl * 2; | 51 | int dist_betwn_starts = bpl * 2; |
52 | 52 | ||
53 | 53 | ||
54 | *(rp++) = cpu_to_le32(RISC_RESYNC | sync_line); | 54 | *(rp++) = cpu_to_le32(RISC_RESYNC | sync_line); |
55 | 55 | ||
56 | 56 | ||
57 | if( USE_RISC_NOOP_VIDEO ) | 57 | if( USE_RISC_NOOP_VIDEO ) |
58 | { | 58 | { |
59 | for( i = 0; i < NUM_NO_OPS; i++ ) | 59 | for( i = 0; i < NUM_NO_OPS; i++ ) |
60 | { | 60 | { |
61 | *(rp++) = cpu_to_le32(RISC_NOOP); | 61 | *(rp++) = cpu_to_le32(RISC_NOOP); |
62 | } | 62 | } |
63 | } | 63 | } |
64 | 64 | ||
65 | /* scan lines */ | 65 | /* scan lines */ |
66 | for (line = 0; line < lines; line++) | 66 | for (line = 0; line < lines; line++) |
67 | { | 67 | { |
68 | *(rp++) = cpu_to_le32(RISC_READ|RISC_SOL|RISC_EOL|bpl); | 68 | *(rp++) = cpu_to_le32(RISC_READ|RISC_SOL|RISC_EOL|bpl); |
69 | *(rp++) = cpu_to_le32(dev->_data_buf_phys_addr_ch2+offset); | 69 | *(rp++) = cpu_to_le32(dev->_data_buf_phys_addr_ch2+offset); |
70 | *(rp++) = cpu_to_le32(0); /* bits 63-32 */ | 70 | *(rp++) = cpu_to_le32(0); /* bits 63-32 */ |
71 | 71 | ||
72 | if ( (lines <= NTSC_FIELD_HEIGHT) || (line < (NTSC_FIELD_HEIGHT-1)) || !(dev->_isNTSC_ch2) ) | 72 | if ( (lines <= NTSC_FIELD_HEIGHT) || (line < (NTSC_FIELD_HEIGHT-1)) || !(dev->_isNTSC_ch2) ) |
73 | { | 73 | { |
74 | offset += dist_betwn_starts; | 74 | offset += dist_betwn_starts; |
75 | } | 75 | } |
76 | } | 76 | } |
77 | 77 | ||
78 | return rp; | 78 | return rp; |
79 | } | 79 | } |
80 | 80 | ||
81 | static __le32 *cx25821_risc_field_upstream_ch2( struct cx25821_dev *dev, | 81 | static __le32 *cx25821_risc_field_upstream_ch2( struct cx25821_dev *dev, |
82 | __le32 *rp, | 82 | __le32 *rp, |
83 | dma_addr_t databuf_phys_addr, | 83 | dma_addr_t databuf_phys_addr, |
84 | unsigned int offset, u32 sync_line, unsigned int bpl, | 84 | unsigned int offset, u32 sync_line, unsigned int bpl, |
85 | unsigned int lines, int fifo_enable, int field_type) | 85 | unsigned int lines, int fifo_enable, int field_type) |
86 | { | 86 | { |
87 | unsigned int line, i; | 87 | unsigned int line, i; |
88 | struct sram_channel *sram_ch = &dev->sram_channels[dev->_channel2_upstream_select]; | 88 | struct sram_channel *sram_ch = &dev->sram_channels[dev->_channel2_upstream_select]; |
89 | int dist_betwn_starts = bpl * 2; | 89 | int dist_betwn_starts = bpl * 2; |
90 | 90 | ||
91 | 91 | ||
92 | /* sync instruction */ | 92 | /* sync instruction */ |
93 | if (sync_line != NO_SYNC_LINE) | 93 | if (sync_line != NO_SYNC_LINE) |
94 | { | 94 | { |
95 | *(rp++) = cpu_to_le32(RISC_RESYNC | sync_line); | 95 | *(rp++) = cpu_to_le32(RISC_RESYNC | sync_line); |
96 | } | 96 | } |
97 | 97 | ||
98 | 98 | ||
99 | if( USE_RISC_NOOP_VIDEO ) | 99 | if( USE_RISC_NOOP_VIDEO ) |
100 | { | 100 | { |
101 | for( i = 0; i < NUM_NO_OPS; i++ ) | 101 | for( i = 0; i < NUM_NO_OPS; i++ ) |
102 | { | 102 | { |
103 | *(rp++) = cpu_to_le32(RISC_NOOP); | 103 | *(rp++) = cpu_to_le32(RISC_NOOP); |
104 | } | 104 | } |
105 | } | 105 | } |
106 | 106 | ||
107 | /* scan lines */ | 107 | /* scan lines */ |
108 | for (line = 0; line < lines; line++) | 108 | for (line = 0; line < lines; line++) |
109 | { | 109 | { |
110 | *(rp++) = cpu_to_le32(RISC_READ|RISC_SOL|RISC_EOL|bpl); | 110 | *(rp++) = cpu_to_le32(RISC_READ|RISC_SOL|RISC_EOL|bpl); |
111 | *(rp++) = cpu_to_le32(databuf_phys_addr+offset); | 111 | *(rp++) = cpu_to_le32(databuf_phys_addr+offset); |
112 | *(rp++) = cpu_to_le32(0); /* bits 63-32 */ | 112 | *(rp++) = cpu_to_le32(0); /* bits 63-32 */ |
113 | 113 | ||
114 | 114 | ||
115 | if ( (lines <= NTSC_FIELD_HEIGHT) || (line < (NTSC_FIELD_HEIGHT-1)) || !(dev->_isNTSC_ch2) ) | 115 | if ( (lines <= NTSC_FIELD_HEIGHT) || (line < (NTSC_FIELD_HEIGHT-1)) || !(dev->_isNTSC_ch2) ) |
116 | { | 116 | { |
117 | offset += dist_betwn_starts; | 117 | offset += dist_betwn_starts; |
118 | } | 118 | } |
119 | 119 | ||
120 | 120 | ||
121 | // check if we need to enable the FIFO after the first 4 lines | 121 | // check if we need to enable the FIFO after the first 4 lines |
122 | // For the upstream video channel, the risc engine will enable the FIFO. | 122 | // For the upstream video channel, the risc engine will enable the FIFO. |
123 | if ( fifo_enable && line == 3 ) | 123 | if ( fifo_enable && line == 3 ) |
124 | { | 124 | { |
125 | *(rp++) = RISC_WRITECR; | 125 | *(rp++) = RISC_WRITECR; |
126 | *(rp++) = sram_ch->dma_ctl; | 126 | *(rp++) = sram_ch->dma_ctl; |
127 | *(rp++) = FLD_VID_FIFO_EN; | 127 | *(rp++) = FLD_VID_FIFO_EN; |
128 | *(rp++) = 0x00000001; | 128 | *(rp++) = 0x00000001; |
129 | } | 129 | } |
130 | } | 130 | } |
131 | 131 | ||
132 | return rp; | 132 | return rp; |
133 | } | 133 | } |
134 | 134 | ||
135 | int cx25821_risc_buffer_upstream_ch2( struct cx25821_dev *dev, struct pci_dev *pci, | 135 | int cx25821_risc_buffer_upstream_ch2( struct cx25821_dev *dev, struct pci_dev *pci, |
136 | unsigned int top_offset, | 136 | unsigned int top_offset, |
137 | unsigned int bpl, unsigned int lines) | 137 | unsigned int bpl, unsigned int lines) |
138 | { | 138 | { |
139 | __le32 *rp; | 139 | __le32 *rp; |
140 | int fifo_enable = 0; | 140 | int fifo_enable = 0; |
@@ -148,57 +148,57 @@ int cx25821_risc_buffer_upstream_ch2( struct cx25821_dev *dev, struct pci_dev *p | |||
148 | unsigned int bottom_offset = bpl; | 148 | unsigned int bottom_offset = bpl; |
149 | dma_addr_t risc_phys_jump_addr; | 149 | dma_addr_t risc_phys_jump_addr; |
150 | 150 | ||
151 | 151 | ||
152 | if( dev->_isNTSC_ch2 ) | 152 | if( dev->_isNTSC_ch2 ) |
153 | { | 153 | { |
154 | odd_num_lines = singlefield_lines + 1; | 154 | odd_num_lines = singlefield_lines + 1; |
155 | risc_program_size = FRAME1_VID_PROG_SIZE; | 155 | risc_program_size = FRAME1_VID_PROG_SIZE; |
156 | frame_size = (bpl == Y411_LINE_SZ) ? FRAME_SIZE_NTSC_Y411 : FRAME_SIZE_NTSC_Y422; | 156 | frame_size = (bpl == Y411_LINE_SZ) ? FRAME_SIZE_NTSC_Y411 : FRAME_SIZE_NTSC_Y422; |
157 | } | 157 | } |
158 | else | 158 | else |
159 | { | 159 | { |
160 | risc_program_size = PAL_VID_PROG_SIZE; | 160 | risc_program_size = PAL_VID_PROG_SIZE; |
161 | frame_size = (bpl == Y411_LINE_SZ) ? FRAME_SIZE_PAL_Y411 : FRAME_SIZE_PAL_Y422; | 161 | frame_size = (bpl == Y411_LINE_SZ) ? FRAME_SIZE_PAL_Y411 : FRAME_SIZE_PAL_Y422; |
162 | } | 162 | } |
163 | 163 | ||
164 | 164 | ||
165 | /* Virtual address of Risc buffer program */ | 165 | /* Virtual address of Risc buffer program */ |
166 | rp = dev->_dma_virt_addr_ch2; | 166 | rp = dev->_dma_virt_addr_ch2; |
167 | 167 | ||
168 | for( frame = 0; frame < NUM_FRAMES; frame++ ) | 168 | for( frame = 0; frame < NUM_FRAMES; frame++ ) |
169 | { | 169 | { |
170 | databuf_offset = frame_size * frame; | 170 | databuf_offset = frame_size * frame; |
171 | 171 | ||
172 | 172 | ||
173 | if (UNSET != top_offset) | 173 | if (UNSET != top_offset) |
174 | { | 174 | { |
175 | fifo_enable = (frame == 0) ? FIFO_ENABLE : FIFO_DISABLE; | 175 | fifo_enable = (frame == 0) ? FIFO_ENABLE : FIFO_DISABLE; |
176 | rp = cx25821_risc_field_upstream_ch2(dev, rp, dev->_data_buf_phys_addr_ch2 + databuf_offset, top_offset, 0, bpl, odd_num_lines, fifo_enable, ODD_FIELD); | 176 | rp = cx25821_risc_field_upstream_ch2(dev, rp, dev->_data_buf_phys_addr_ch2 + databuf_offset, top_offset, 0, bpl, odd_num_lines, fifo_enable, ODD_FIELD); |
177 | } | 177 | } |
178 | 178 | ||
179 | fifo_enable = FIFO_DISABLE; | 179 | fifo_enable = FIFO_DISABLE; |
180 | 180 | ||
181 | 181 | ||
182 | //Even field | 182 | //Even field |
183 | rp = cx25821_risc_field_upstream_ch2(dev, rp, dev->_data_buf_phys_addr_ch2 + databuf_offset, bottom_offset, 0x200, bpl, singlefield_lines, fifo_enable, EVEN_FIELD); | 183 | rp = cx25821_risc_field_upstream_ch2(dev, rp, dev->_data_buf_phys_addr_ch2 + databuf_offset, bottom_offset, 0x200, bpl, singlefield_lines, fifo_enable, EVEN_FIELD); |
184 | 184 | ||
185 | 185 | ||
186 | if( frame == 0 ) | 186 | if( frame == 0 ) |
187 | { | 187 | { |
188 | risc_flag = RISC_CNT_RESET; | 188 | risc_flag = RISC_CNT_RESET; |
189 | risc_phys_jump_addr = dev->_dma_phys_start_addr_ch2 + risc_program_size; | 189 | risc_phys_jump_addr = dev->_dma_phys_start_addr_ch2 + risc_program_size; |
190 | } | 190 | } |
191 | else | 191 | else |
192 | { | 192 | { |
193 | risc_flag = RISC_CNT_INC; | 193 | risc_flag = RISC_CNT_INC; |
194 | risc_phys_jump_addr = dev->_dma_phys_start_addr_ch2; | 194 | risc_phys_jump_addr = dev->_dma_phys_start_addr_ch2; |
195 | } | 195 | } |
196 | 196 | ||
197 | 197 | ||
198 | // Loop to 2ndFrameRISC or to Start of Risc program & generate IRQ | 198 | // Loop to 2ndFrameRISC or to Start of Risc program & generate IRQ |
199 | *(rp++) = cpu_to_le32(RISC_JUMP|RISC_IRQ1|risc_flag); | 199 | *(rp++) = cpu_to_le32(RISC_JUMP|RISC_IRQ1|risc_flag); |
200 | *(rp++) = cpu_to_le32(risc_phys_jump_addr); | 200 | *(rp++) = cpu_to_le32(risc_phys_jump_addr); |
201 | *(rp++) = cpu_to_le32(0); | 201 | *(rp++) = cpu_to_le32(0); |
202 | } | 202 | } |
203 | 203 | ||
204 | return 0; | 204 | return 0; |
@@ -212,8 +212,8 @@ void cx25821_stop_upstream_video_ch2(struct cx25821_dev *dev) | |||
212 | 212 | ||
213 | if( !dev->_is_running_ch2 ) | 213 | if( !dev->_is_running_ch2 ) |
214 | { | 214 | { |
215 | printk("cx25821: No video file is currently running so return!\n"); | 215 | printk("cx25821: No video file is currently running so return!\n"); |
216 | return; | 216 | return; |
217 | } | 217 | } |
218 | 218 | ||
219 | //Disable RISC interrupts | 219 | //Disable RISC interrupts |
@@ -226,8 +226,8 @@ void cx25821_stop_upstream_video_ch2(struct cx25821_dev *dev) | |||
226 | 226 | ||
227 | //Clear data buffer memory | 227 | //Clear data buffer memory |
228 | if( dev->_data_buf_virt_addr_ch2 ) | 228 | if( dev->_data_buf_virt_addr_ch2 ) |
229 | memset( dev->_data_buf_virt_addr_ch2, 0, dev->_data_buf_size_ch2 ); | 229 | memset( dev->_data_buf_virt_addr_ch2, 0, dev->_data_buf_size_ch2 ); |
230 | 230 | ||
231 | dev->_is_running_ch2 = 0; | 231 | dev->_is_running_ch2 = 0; |
232 | dev->_is_first_frame_ch2 = 0; | 232 | dev->_is_first_frame_ch2 = 0; |
233 | dev->_frame_count_ch2 = 0; | 233 | dev->_frame_count_ch2 = 0; |
@@ -235,12 +235,12 @@ void cx25821_stop_upstream_video_ch2(struct cx25821_dev *dev) | |||
235 | 235 | ||
236 | if( dev->_irq_queues_ch2 ) | 236 | if( dev->_irq_queues_ch2 ) |
237 | { | 237 | { |
238 | kfree(dev->_irq_queues_ch2); | 238 | kfree(dev->_irq_queues_ch2); |
239 | dev->_irq_queues_ch2 = NULL; | 239 | dev->_irq_queues_ch2 = NULL; |
240 | } | 240 | } |
241 | 241 | ||
242 | if( dev->_filename_ch2 != NULL ) | 242 | if( dev->_filename_ch2 != NULL ) |
243 | kfree(dev->_filename_ch2); | 243 | kfree(dev->_filename_ch2); |
244 | 244 | ||
245 | tmp = cx_read( VID_CH_MODE_SEL ); | 245 | tmp = cx_read( VID_CH_MODE_SEL ); |
246 | cx_write( VID_CH_MODE_SEL, tmp & 0xFFFFFE00); | 246 | cx_write( VID_CH_MODE_SEL, tmp & 0xFFFFFE00); |
@@ -250,19 +250,19 @@ void cx25821_free_mem_upstream_ch2(struct cx25821_dev *dev) | |||
250 | { | 250 | { |
251 | if( dev->_is_running_ch2 ) | 251 | if( dev->_is_running_ch2 ) |
252 | { | 252 | { |
253 | cx25821_stop_upstream_video_ch2(dev); | 253 | cx25821_stop_upstream_video_ch2(dev); |
254 | } | 254 | } |
255 | 255 | ||
256 | if (dev->_dma_virt_addr_ch2) | 256 | if (dev->_dma_virt_addr_ch2) |
257 | { | 257 | { |
258 | pci_free_consistent(dev->pci, dev->_risc_size_ch2, dev->_dma_virt_addr_ch2, dev->_dma_phys_addr_ch2); | 258 | pci_free_consistent(dev->pci, dev->_risc_size_ch2, dev->_dma_virt_addr_ch2, dev->_dma_phys_addr_ch2); |
259 | dev->_dma_virt_addr_ch2 = NULL; | 259 | dev->_dma_virt_addr_ch2 = NULL; |
260 | } | 260 | } |
261 | 261 | ||
262 | if (dev->_data_buf_virt_addr_ch2) | 262 | if (dev->_data_buf_virt_addr_ch2) |
263 | { | 263 | { |
264 | pci_free_consistent(dev->pci, dev->_data_buf_size_ch2, dev->_data_buf_virt_addr_ch2, dev->_data_buf_phys_addr_ch2); | 264 | pci_free_consistent(dev->pci, dev->_data_buf_size_ch2, dev->_data_buf_virt_addr_ch2, dev->_data_buf_phys_addr_ch2); |
265 | dev->_data_buf_virt_addr_ch2 = NULL; | 265 | dev->_data_buf_virt_addr_ch2 = NULL; |
266 | } | 266 | } |
267 | } | 267 | } |
268 | 268 | ||
@@ -280,84 +280,84 @@ int cx25821_get_frame_ch2(struct cx25821_dev *dev, struct sram_channel *sram_ch | |||
280 | loff_t file_offset; | 280 | loff_t file_offset; |
281 | loff_t pos; | 281 | loff_t pos; |
282 | mm_segment_t old_fs; | 282 | mm_segment_t old_fs; |
283 | 283 | ||
284 | 284 | ||
285 | if( dev->_file_status_ch2 == END_OF_FILE ) | 285 | if( dev->_file_status_ch2 == END_OF_FILE ) |
286 | return 0; | 286 | return 0; |
287 | 287 | ||
288 | if( dev->_isNTSC_ch2 ) | 288 | if( dev->_isNTSC_ch2 ) |
289 | { | 289 | { |
290 | frame_size = (line_size == Y411_LINE_SZ) ? FRAME_SIZE_NTSC_Y411 : FRAME_SIZE_NTSC_Y422; | 290 | frame_size = (line_size == Y411_LINE_SZ) ? FRAME_SIZE_NTSC_Y411 : FRAME_SIZE_NTSC_Y422; |
291 | } | 291 | } |
292 | else | 292 | else |
293 | { | 293 | { |
294 | frame_size = (line_size == Y411_LINE_SZ) ? FRAME_SIZE_PAL_Y411 : FRAME_SIZE_PAL_Y422; | 294 | frame_size = (line_size == Y411_LINE_SZ) ? FRAME_SIZE_PAL_Y411 : FRAME_SIZE_PAL_Y422; |
295 | } | 295 | } |
296 | 296 | ||
297 | frame_offset = (frame_index_temp > 0) ? frame_size : 0; | 297 | frame_offset = (frame_index_temp > 0) ? frame_size : 0; |
298 | file_offset = dev->_frame_count_ch2 * frame_size; | 298 | file_offset = dev->_frame_count_ch2 * frame_size; |
299 | 299 | ||
300 | 300 | ||
301 | myfile = filp_open( dev->_filename_ch2, O_RDONLY | O_LARGEFILE, 0 ); | 301 | myfile = filp_open( dev->_filename_ch2, O_RDONLY | O_LARGEFILE, 0 ); |
302 | 302 | ||
303 | 303 | ||
304 | if (IS_ERR(myfile)) | 304 | if (IS_ERR(myfile)) |
305 | { | 305 | { |
306 | const int open_errno = -PTR_ERR(myfile); | 306 | const int open_errno = -PTR_ERR(myfile); |
307 | printk("%s(): ERROR opening file(%s) with errno = %d! \n", __func__, dev->_filename_ch2, open_errno); | 307 | printk("%s(): ERROR opening file(%s) with errno = %d! \n", __func__, dev->_filename_ch2, open_errno); |
308 | return PTR_ERR(myfile); | 308 | return PTR_ERR(myfile); |
309 | } | 309 | } |
310 | else | 310 | else |
311 | { | 311 | { |
312 | if( !(myfile->f_op) ) | 312 | if( !(myfile->f_op) ) |
313 | { | 313 | { |
314 | printk("%s: File has no file operations registered!", __func__); | 314 | printk("%s: File has no file operations registered!", __func__); |
315 | filp_close(myfile, NULL); | 315 | filp_close(myfile, NULL); |
316 | return -EIO; | 316 | return -EIO; |
317 | } | 317 | } |
318 | 318 | ||
319 | 319 | ||
320 | if( !myfile->f_op->read ) | 320 | if( !myfile->f_op->read ) |
321 | { | 321 | { |
322 | printk("%s: File has no READ operations registered!", __func__); | 322 | printk("%s: File has no READ operations registered!", __func__); |
323 | filp_close(myfile, NULL); | 323 | filp_close(myfile, NULL); |
324 | return -EIO; | 324 | return -EIO; |
325 | } | 325 | } |
326 | 326 | ||
327 | pos = myfile->f_pos; | 327 | pos = myfile->f_pos; |
328 | old_fs = get_fs(); | 328 | old_fs = get_fs(); |
329 | set_fs(KERNEL_DS); | 329 | set_fs(KERNEL_DS); |
330 | 330 | ||
331 | 331 | ||
332 | for( i = 0; i < dev->_lines_count_ch2; i++ ) | 332 | for( i = 0; i < dev->_lines_count_ch2; i++ ) |
333 | { | 333 | { |
334 | pos = file_offset; | 334 | pos = file_offset; |
335 | 335 | ||
336 | vfs_read_retval = vfs_read(myfile, mybuf, line_size, &pos); | 336 | vfs_read_retval = vfs_read(myfile, mybuf, line_size, &pos); |
337 | 337 | ||
338 | if( vfs_read_retval > 0 && vfs_read_retval == line_size && dev->_data_buf_virt_addr_ch2 != NULL ) | 338 | if( vfs_read_retval > 0 && vfs_read_retval == line_size && dev->_data_buf_virt_addr_ch2 != NULL ) |
339 | { | 339 | { |
340 | memcpy( (void*)(dev->_data_buf_virt_addr_ch2+frame_offset/4), mybuf, vfs_read_retval); | 340 | memcpy( (void*)(dev->_data_buf_virt_addr_ch2+frame_offset/4), mybuf, vfs_read_retval); |
341 | } | 341 | } |
342 | 342 | ||
343 | file_offset += vfs_read_retval; | 343 | file_offset += vfs_read_retval; |
344 | frame_offset += vfs_read_retval; | 344 | frame_offset += vfs_read_retval; |
345 | 345 | ||
346 | if( vfs_read_retval < line_size ) | 346 | if( vfs_read_retval < line_size ) |
347 | { | 347 | { |
348 | printk(KERN_INFO "Done: exit %s() since no more bytes to read from Video file.\n", __func__ ); | 348 | printk(KERN_INFO "Done: exit %s() since no more bytes to read from Video file.\n", __func__ ); |
349 | break; | 349 | break; |
350 | } | 350 | } |
351 | } | 351 | } |
352 | 352 | ||
353 | if( i > 0 ) | 353 | if( i > 0 ) |
354 | dev->_frame_count_ch2++; | 354 | dev->_frame_count_ch2++; |
355 | 355 | ||
356 | dev->_file_status_ch2 = (vfs_read_retval == line_size) ? IN_PROGRESS : END_OF_FILE; | 356 | dev->_file_status_ch2 = (vfs_read_retval == line_size) ? IN_PROGRESS : END_OF_FILE; |
357 | 357 | ||
358 | 358 | ||
359 | set_fs(old_fs); | 359 | set_fs(old_fs); |
360 | filp_close(myfile, NULL); | 360 | filp_close(myfile, NULL); |
361 | } | 361 | } |
362 | 362 | ||
363 | return 0; | 363 | return 0; |
@@ -369,8 +369,8 @@ static void cx25821_vidups_handler_ch2(struct work_struct *work) | |||
369 | 369 | ||
370 | if( !dev ) | 370 | if( !dev ) |
371 | { | 371 | { |
372 | printk("ERROR %s(): since container_of(work_struct) FAILED! \n", __func__ ); | 372 | printk("ERROR %s(): since container_of(work_struct) FAILED! \n", __func__ ); |
373 | return; | 373 | return; |
374 | } | 374 | } |
375 | 375 | ||
376 | cx25821_get_frame_ch2( dev, &dev->sram_channels[dev->_channel2_upstream_select] ); | 376 | cx25821_get_frame_ch2( dev, &dev->sram_channels[dev->_channel2_upstream_select] ); |
@@ -387,76 +387,76 @@ int cx25821_openfile_ch2(struct cx25821_dev *dev, struct sram_channel *sram_ch) | |||
387 | loff_t pos; | 387 | loff_t pos; |
388 | loff_t offset = (unsigned long)0; | 388 | loff_t offset = (unsigned long)0; |
389 | mm_segment_t old_fs; | 389 | mm_segment_t old_fs; |
390 | 390 | ||
391 | 391 | ||
392 | myfile = filp_open( dev->_filename_ch2, O_RDONLY | O_LARGEFILE, 0 ); | 392 | myfile = filp_open( dev->_filename_ch2, O_RDONLY | O_LARGEFILE, 0 ); |
393 | 393 | ||
394 | 394 | ||
395 | if (IS_ERR(myfile)) | 395 | if (IS_ERR(myfile)) |
396 | { | 396 | { |
397 | const int open_errno = -PTR_ERR(myfile); | 397 | const int open_errno = -PTR_ERR(myfile); |
398 | printk("%s(): ERROR opening file(%s) with errno = %d! \n", __func__, dev->_filename_ch2, open_errno); | 398 | printk("%s(): ERROR opening file(%s) with errno = %d! \n", __func__, dev->_filename_ch2, open_errno); |
399 | return PTR_ERR(myfile); | 399 | return PTR_ERR(myfile); |
400 | } | 400 | } |
401 | else | 401 | else |
402 | { | 402 | { |
403 | if( !(myfile->f_op) ) | 403 | if( !(myfile->f_op) ) |
404 | { | 404 | { |
405 | printk("%s: File has no file operations registered!", __func__); | 405 | printk("%s: File has no file operations registered!", __func__); |
406 | filp_close(myfile, NULL); | 406 | filp_close(myfile, NULL); |
407 | return -EIO; | 407 | return -EIO; |
408 | } | 408 | } |
409 | 409 | ||
410 | 410 | ||
411 | if( !myfile->f_op->read ) | 411 | if( !myfile->f_op->read ) |
412 | { | 412 | { |
413 | printk("%s: File has no READ operations registered! Returning.", __func__); | 413 | printk("%s: File has no READ operations registered! Returning.", __func__); |
414 | filp_close(myfile, NULL); | 414 | filp_close(myfile, NULL); |
415 | return -EIO; | 415 | return -EIO; |
416 | } | 416 | } |
417 | 417 | ||
418 | pos = myfile->f_pos; | 418 | pos = myfile->f_pos; |
419 | old_fs = get_fs(); | 419 | old_fs = get_fs(); |
420 | set_fs(KERNEL_DS); | 420 | set_fs(KERNEL_DS); |
421 | 421 | ||
422 | 422 | ||
423 | for( j = 0; j < NUM_FRAMES; j++ ) | 423 | for( j = 0; j < NUM_FRAMES; j++ ) |
424 | { | 424 | { |
425 | for( i = 0; i < dev->_lines_count_ch2; i++ ) | 425 | for( i = 0; i < dev->_lines_count_ch2; i++ ) |
426 | { | 426 | { |
427 | pos = offset; | 427 | pos = offset; |
428 | 428 | ||
429 | vfs_read_retval = vfs_read(myfile, mybuf, line_size, &pos); | 429 | vfs_read_retval = vfs_read(myfile, mybuf, line_size, &pos); |
430 | 430 | ||
431 | if( vfs_read_retval > 0 && vfs_read_retval == line_size && dev->_data_buf_virt_addr_ch2 != NULL ) | 431 | if( vfs_read_retval > 0 && vfs_read_retval == line_size && dev->_data_buf_virt_addr_ch2 != NULL ) |
432 | { | 432 | { |
433 | memcpy( (void*)(dev->_data_buf_virt_addr_ch2+offset/4), mybuf, vfs_read_retval); | 433 | memcpy( (void*)(dev->_data_buf_virt_addr_ch2+offset/4), mybuf, vfs_read_retval); |
434 | } | 434 | } |
435 | 435 | ||
436 | 436 | ||
437 | offset += vfs_read_retval; | 437 | offset += vfs_read_retval; |
438 | 438 | ||
439 | if( vfs_read_retval < line_size ) | 439 | if( vfs_read_retval < line_size ) |
440 | { | 440 | { |
441 | printk(KERN_INFO "Done: exit %s() since no more bytes to read from Video file.\n", __func__ ); | 441 | printk(KERN_INFO "Done: exit %s() since no more bytes to read from Video file.\n", __func__ ); |
442 | break; | 442 | break; |
443 | } | 443 | } |
444 | } | 444 | } |
445 | 445 | ||
446 | if( i > 0 ) | 446 | if( i > 0 ) |
447 | dev->_frame_count_ch2++; | 447 | dev->_frame_count_ch2++; |
448 | 448 | ||
449 | if( vfs_read_retval < line_size ) | 449 | if( vfs_read_retval < line_size ) |
450 | { | 450 | { |
451 | break; | 451 | break; |
452 | } | 452 | } |
453 | } | 453 | } |
454 | 454 | ||
455 | dev->_file_status_ch2 = (vfs_read_retval == line_size) ? IN_PROGRESS : END_OF_FILE; | 455 | dev->_file_status_ch2 = (vfs_read_retval == line_size) ? IN_PROGRESS : END_OF_FILE; |
456 | 456 | ||
457 | set_fs(old_fs); | 457 | set_fs(old_fs); |
458 | myfile->f_pos = 0; | 458 | myfile->f_pos = 0; |
459 | filp_close(myfile, NULL); | 459 | filp_close(myfile, NULL); |
460 | } | 460 | } |
461 | 461 | ||
462 | return 0; | 462 | return 0; |
@@ -464,17 +464,17 @@ int cx25821_openfile_ch2(struct cx25821_dev *dev, struct sram_channel *sram_ch) | |||
464 | 464 | ||
465 | 465 | ||
466 | static int cx25821_upstream_buffer_prepare_ch2(struct cx25821_dev *dev, | 466 | static int cx25821_upstream_buffer_prepare_ch2(struct cx25821_dev *dev, |
467 | struct sram_channel *sram_ch, | 467 | struct sram_channel *sram_ch, |
468 | int bpl) | 468 | int bpl) |
469 | { | 469 | { |
470 | int ret = 0; | 470 | int ret = 0; |
471 | dma_addr_t dma_addr; | 471 | dma_addr_t dma_addr; |
472 | dma_addr_t data_dma_addr; | 472 | dma_addr_t data_dma_addr; |
473 | 473 | ||
474 | 474 | ||
475 | if( dev->_dma_virt_addr_ch2 != NULL ) | 475 | if( dev->_dma_virt_addr_ch2 != NULL ) |
476 | { | 476 | { |
477 | pci_free_consistent(dev->pci, dev->upstream_riscbuf_size_ch2, dev->_dma_virt_addr_ch2, dev->_dma_phys_addr_ch2); | 477 | pci_free_consistent(dev->pci, dev->upstream_riscbuf_size_ch2, dev->_dma_virt_addr_ch2, dev->_dma_phys_addr_ch2); |
478 | } | 478 | } |
479 | 479 | ||
480 | dev->_dma_virt_addr_ch2 = pci_alloc_consistent(dev->pci, dev->upstream_riscbuf_size_ch2, &dma_addr); | 480 | dev->_dma_virt_addr_ch2 = pci_alloc_consistent(dev->pci, dev->upstream_riscbuf_size_ch2, &dma_addr); |
@@ -486,8 +486,8 @@ static int cx25821_upstream_buffer_prepare_ch2(struct cx25821_dev *dev, | |||
486 | 486 | ||
487 | if (!dev->_dma_virt_addr_ch2) | 487 | if (!dev->_dma_virt_addr_ch2) |
488 | { | 488 | { |
489 | printk("cx25821: FAILED to allocate memory for Risc buffer! Returning.\n"); | 489 | printk("cx25821: FAILED to allocate memory for Risc buffer! Returning.\n"); |
490 | return -ENOMEM; | 490 | return -ENOMEM; |
491 | } | 491 | } |
492 | 492 | ||
493 | 493 | ||
@@ -497,7 +497,7 @@ static int cx25821_upstream_buffer_prepare_ch2(struct cx25821_dev *dev, | |||
497 | 497 | ||
498 | if( dev->_data_buf_virt_addr_ch2 != NULL ) | 498 | if( dev->_data_buf_virt_addr_ch2 != NULL ) |
499 | { | 499 | { |
500 | pci_free_consistent(dev->pci, dev->upstream_databuf_size_ch2, dev->_data_buf_virt_addr_ch2, dev->_data_buf_phys_addr_ch2); | 500 | pci_free_consistent(dev->pci, dev->upstream_databuf_size_ch2, dev->_data_buf_virt_addr_ch2, dev->_data_buf_phys_addr_ch2); |
501 | } | 501 | } |
502 | 502 | ||
503 | //For Video Data buffer allocation | 503 | //For Video Data buffer allocation |
@@ -507,8 +507,8 @@ static int cx25821_upstream_buffer_prepare_ch2(struct cx25821_dev *dev, | |||
507 | 507 | ||
508 | if (!dev->_data_buf_virt_addr_ch2) | 508 | if (!dev->_data_buf_virt_addr_ch2) |
509 | { | 509 | { |
510 | printk("cx25821: FAILED to allocate memory for data buffer! Returning.\n"); | 510 | printk("cx25821: FAILED to allocate memory for data buffer! Returning.\n"); |
511 | return -ENOMEM; | 511 | return -ENOMEM; |
512 | } | 512 | } |
513 | 513 | ||
514 | 514 | ||
@@ -518,15 +518,15 @@ static int cx25821_upstream_buffer_prepare_ch2(struct cx25821_dev *dev, | |||
518 | 518 | ||
519 | ret = cx25821_openfile_ch2(dev, sram_ch); | 519 | ret = cx25821_openfile_ch2(dev, sram_ch); |
520 | if( ret < 0 ) | 520 | if( ret < 0 ) |
521 | return ret; | 521 | return ret; |
522 | 522 | ||
523 | 523 | ||
524 | //Creating RISC programs | 524 | //Creating RISC programs |
525 | ret = cx25821_risc_buffer_upstream_ch2(dev, dev->pci, 0, bpl, dev->_lines_count_ch2 ); | 525 | ret = cx25821_risc_buffer_upstream_ch2(dev, dev->pci, 0, bpl, dev->_lines_count_ch2 ); |
526 | if (ret < 0) | 526 | if (ret < 0) |
527 | { | 527 | { |
528 | printk(KERN_INFO "cx25821: Failed creating Video Upstream Risc programs! \n"); | 528 | printk(KERN_INFO "cx25821: Failed creating Video Upstream Risc programs! \n"); |
529 | goto error; | 529 | goto error; |
530 | } | 530 | } |
531 | 531 | ||
532 | return 0; | 532 | return 0; |
@@ -549,59 +549,59 @@ int cx25821_video_upstream_irq_ch2(struct cx25821_dev *dev, int chan_num, u32 st | |||
549 | 549 | ||
550 | if (status & FLD_VID_SRC_RISC1) | 550 | if (status & FLD_VID_SRC_RISC1) |
551 | { | 551 | { |
552 | // We should only process one program per call | 552 | // We should only process one program per call |
553 | u32 prog_cnt = cx_read( channel->gpcnt ); | 553 | u32 prog_cnt = cx_read( channel->gpcnt ); |
554 | 554 | ||
555 | //Since we've identified our IRQ, clear our bits from the interrupt mask and interrupt status registers | 555 | //Since we've identified our IRQ, clear our bits from the interrupt mask and interrupt status registers |
556 | int_msk_tmp = cx_read(channel->int_msk); | 556 | int_msk_tmp = cx_read(channel->int_msk); |
557 | cx_write(channel->int_msk, int_msk_tmp & ~_intr_msk); | 557 | cx_write(channel->int_msk, int_msk_tmp & ~_intr_msk); |
558 | cx_write( channel->int_stat, _intr_msk ); | 558 | cx_write( channel->int_stat, _intr_msk ); |
559 | 559 | ||
560 | spin_lock(&dev->slock); | 560 | spin_lock(&dev->slock); |
561 | 561 | ||
562 | dev->_frame_index_ch2 = prog_cnt; | 562 | dev->_frame_index_ch2 = prog_cnt; |
563 | 563 | ||
564 | queue_work(dev->_irq_queues_ch2, &dev->_irq_work_entry_ch2); | 564 | queue_work(dev->_irq_queues_ch2, &dev->_irq_work_entry_ch2); |
565 | 565 | ||
566 | 566 | ||
567 | if ( dev->_is_first_frame_ch2 ) | 567 | if ( dev->_is_first_frame_ch2 ) |
568 | { | 568 | { |
569 | dev->_is_first_frame_ch2 = 0; | 569 | dev->_is_first_frame_ch2 = 0; |
570 | 570 | ||
571 | if( dev->_isNTSC_ch2 ) | 571 | if( dev->_isNTSC_ch2 ) |
572 | { | 572 | { |
573 | singlefield_lines += 1; | 573 | singlefield_lines += 1; |
574 | odd_risc_prog_size = ODD_FLD_NTSC_PROG_SIZE; | 574 | odd_risc_prog_size = ODD_FLD_NTSC_PROG_SIZE; |
575 | } | 575 | } |
576 | else | 576 | else |
577 | { | 577 | { |
578 | singlefield_lines = PAL_FIELD_HEIGHT; | 578 | singlefield_lines = PAL_FIELD_HEIGHT; |
579 | odd_risc_prog_size = ODD_FLD_PAL_PROG_SIZE; | 579 | odd_risc_prog_size = ODD_FLD_PAL_PROG_SIZE; |
580 | } | 580 | } |
581 | 581 | ||
582 | 582 | ||
583 | if( dev->_dma_virt_start_addr_ch2 != NULL ) | 583 | if( dev->_dma_virt_start_addr_ch2 != NULL ) |
584 | { | 584 | { |
585 | line_size_in_bytes = (dev->_pixel_format_ch2 == PIXEL_FRMT_411) ? Y411_LINE_SZ : Y422_LINE_SZ; | 585 | line_size_in_bytes = (dev->_pixel_format_ch2 == PIXEL_FRMT_411) ? Y411_LINE_SZ : Y422_LINE_SZ; |
586 | risc_phys_jump_addr = dev->_dma_phys_start_addr_ch2 + odd_risc_prog_size; | 586 | risc_phys_jump_addr = dev->_dma_phys_start_addr_ch2 + odd_risc_prog_size; |
587 | 587 | ||
588 | rp = cx25821_update_riscprogram_ch2(dev, dev->_dma_virt_start_addr_ch2, TOP_OFFSET, line_size_in_bytes, 0x0, singlefield_lines, FIFO_DISABLE, ODD_FIELD); | 588 | rp = cx25821_update_riscprogram_ch2(dev, dev->_dma_virt_start_addr_ch2, TOP_OFFSET, line_size_in_bytes, 0x0, singlefield_lines, FIFO_DISABLE, ODD_FIELD); |
589 | 589 | ||
590 | // Jump to Even Risc program of 1st Frame | 590 | // Jump to Even Risc program of 1st Frame |
591 | *(rp++) = cpu_to_le32(RISC_JUMP); | 591 | *(rp++) = cpu_to_le32(RISC_JUMP); |
592 | *(rp++) = cpu_to_le32(risc_phys_jump_addr); | 592 | *(rp++) = cpu_to_le32(risc_phys_jump_addr); |
593 | *(rp++) = cpu_to_le32(0); | 593 | *(rp++) = cpu_to_le32(0); |
594 | } | 594 | } |
595 | } | 595 | } |
596 | 596 | ||
597 | spin_unlock(&dev->slock); | 597 | spin_unlock(&dev->slock); |
598 | } | 598 | } |
599 | 599 | ||
600 | 600 | ||
601 | if( dev->_file_status_ch2 == END_OF_FILE ) | 601 | if( dev->_file_status_ch2 == END_OF_FILE ) |
602 | { | 602 | { |
603 | printk("cx25821: EOF Channel 2 Framecount = %d\n", dev->_frame_count_ch2 ); | 603 | printk("cx25821: EOF Channel 2 Framecount = %d\n", dev->_frame_count_ch2 ); |
604 | return -1; | 604 | return -1; |
605 | } | 605 | } |
606 | 606 | ||
607 | //ElSE, set the interrupt mask register, re-enable irq. | 607 | //ElSE, set the interrupt mask register, re-enable irq. |
@@ -621,10 +621,10 @@ static irqreturn_t cx25821_upstream_irq_ch2(int irq, void *dev_id) | |||
621 | 621 | ||
622 | 622 | ||
623 | if( !dev ) | 623 | if( !dev ) |
624 | return -1; | 624 | return -1; |
625 | 625 | ||
626 | channel_num = VID_UPSTREAM_SRAM_CHANNEL_J; | 626 | channel_num = VID_UPSTREAM_SRAM_CHANNEL_J; |
627 | 627 | ||
628 | sram_ch = &dev->sram_channels[channel_num]; | 628 | sram_ch = &dev->sram_channels[channel_num]; |
629 | 629 | ||
630 | msk_stat = cx_read(sram_ch->int_mstat); | 630 | msk_stat = cx_read(sram_ch->int_mstat); |
@@ -633,17 +633,17 @@ static irqreturn_t cx25821_upstream_irq_ch2(int irq, void *dev_id) | |||
633 | // Only deal with our interrupt | 633 | // Only deal with our interrupt |
634 | if(vid_status) | 634 | if(vid_status) |
635 | { | 635 | { |
636 | handled = cx25821_video_upstream_irq_ch2(dev, channel_num, vid_status); | 636 | handled = cx25821_video_upstream_irq_ch2(dev, channel_num, vid_status); |
637 | } | 637 | } |
638 | 638 | ||
639 | 639 | ||
640 | if( handled < 0 ) | 640 | if( handled < 0 ) |
641 | { | 641 | { |
642 | cx25821_stop_upstream_video_ch2(dev); | 642 | cx25821_stop_upstream_video_ch2(dev); |
643 | } | 643 | } |
644 | else | 644 | else |
645 | { | 645 | { |
646 | handled += handled; | 646 | handled += handled; |
647 | } | 647 | } |
648 | 648 | ||
649 | return IRQ_RETVAL(handled); | 649 | return IRQ_RETVAL(handled); |
@@ -658,7 +658,7 @@ static void cx25821_set_pixelengine_ch2(struct cx25821_dev *dev, struct sram_cha | |||
658 | u32 value; | 658 | u32 value; |
659 | int vip_mode = PIXEL_ENGINE_VIP1; | 659 | int vip_mode = PIXEL_ENGINE_VIP1; |
660 | 660 | ||
661 | 661 | ||
662 | value = ( (pix_format & 0x3) << 12 ) | ( vip_mode & 0x7 ); | 662 | value = ( (pix_format & 0x3) << 12 ) | ( vip_mode & 0x7 ); |
663 | value &= 0xFFFFFFEF; | 663 | value &= 0xFFFFFFEF; |
664 | value |= dev->_isNTSC_ch2 ? 0 : 0x10; | 664 | value |= dev->_isNTSC_ch2 ? 0 : 0x10; |
@@ -672,7 +672,7 @@ static void cx25821_set_pixelengine_ch2(struct cx25821_dev *dev, struct sram_cha | |||
672 | 672 | ||
673 | if(dev->_isNTSC_ch2) | 673 | if(dev->_isNTSC_ch2) |
674 | { | 674 | { |
675 | odd_num_lines += 1; | 675 | odd_num_lines += 1; |
676 | } | 676 | } |
677 | 677 | ||
678 | value = (num_lines << 16) | odd_num_lines; | 678 | value = (num_lines << 16) | odd_num_lines; |
@@ -685,7 +685,7 @@ static void cx25821_set_pixelengine_ch2(struct cx25821_dev *dev, struct sram_cha | |||
685 | 685 | ||
686 | 686 | ||
687 | int cx25821_start_video_dma_upstream_ch2(struct cx25821_dev *dev, | 687 | int cx25821_start_video_dma_upstream_ch2(struct cx25821_dev *dev, |
688 | struct sram_channel *sram_ch) | 688 | struct sram_channel *sram_ch) |
689 | { | 689 | { |
690 | u32 tmp = 0; | 690 | u32 tmp = 0; |
691 | int err = 0; | 691 | int err = 0; |
@@ -716,8 +716,8 @@ int cx25821_start_video_dma_upstream_ch2(struct cx25821_dev *dev, | |||
716 | err = request_irq(dev->pci->irq, cx25821_upstream_irq_ch2, IRQF_SHARED | IRQF_DISABLED, dev->name, dev); | 716 | err = request_irq(dev->pci->irq, cx25821_upstream_irq_ch2, IRQF_SHARED | IRQF_DISABLED, dev->name, dev); |
717 | if (err < 0) | 717 | if (err < 0) |
718 | { | 718 | { |
719 | printk(KERN_ERR "%s: can't get upstream IRQ %d\n", dev->name, dev->pci->irq); | 719 | printk(KERN_ERR "%s: can't get upstream IRQ %d\n", dev->name, dev->pci->irq); |
720 | goto fail_irq; | 720 | goto fail_irq; |
721 | } | 721 | } |
722 | 722 | ||
723 | // Start the DMA engine | 723 | // Start the DMA engine |
@@ -748,8 +748,8 @@ int cx25821_vidupstream_init_ch2(struct cx25821_dev *dev, int channel_select, in | |||
748 | 748 | ||
749 | if( dev->_is_running_ch2 ) | 749 | if( dev->_is_running_ch2 ) |
750 | { | 750 | { |
751 | printk("Video Channel is still running so return!\n"); | 751 | printk("Video Channel is still running so return!\n"); |
752 | return 0; | 752 | return 0; |
753 | } | 753 | } |
754 | 754 | ||
755 | dev->_channel2_upstream_select = channel_select; | 755 | dev->_channel2_upstream_select = channel_select; |
@@ -761,15 +761,15 @@ int cx25821_vidupstream_init_ch2(struct cx25821_dev *dev, int channel_select, in | |||
761 | 761 | ||
762 | if(!dev->_irq_queues_ch2) | 762 | if(!dev->_irq_queues_ch2) |
763 | { | 763 | { |
764 | printk("cx25821: create_singlethread_workqueue() for Video FAILED!\n"); | 764 | printk("cx25821: create_singlethread_workqueue() for Video FAILED!\n"); |
765 | return -ENOMEM; | 765 | return -ENOMEM; |
766 | } | 766 | } |
767 | 767 | ||
768 | // 656/VIP SRC Upstream Channel I & J and 7 - Host Bus Interface for channel A-C | 768 | // 656/VIP SRC Upstream Channel I & J and 7 - Host Bus Interface for channel A-C |
769 | tmp = cx_read( VID_CH_MODE_SEL ); | 769 | tmp = cx_read( VID_CH_MODE_SEL ); |
770 | cx_write( VID_CH_MODE_SEL, tmp | 0x1B0001FF); | 770 | cx_write( VID_CH_MODE_SEL, tmp | 0x1B0001FF); |
771 | 771 | ||
772 | 772 | ||
773 | dev->_is_running_ch2 = 0; | 773 | dev->_is_running_ch2 = 0; |
774 | dev->_frame_count_ch2 = 0; | 774 | dev->_frame_count_ch2 = 0; |
775 | dev->_file_status_ch2 = RESET_STATUS; | 775 | dev->_file_status_ch2 = RESET_STATUS; |
@@ -779,43 +779,43 @@ int cx25821_vidupstream_init_ch2(struct cx25821_dev *dev, int channel_select, in | |||
779 | data_frame_size = dev->_isNTSC_ch2 ? NTSC_DATA_BUF_SZ : PAL_DATA_BUF_SZ; | 779 | data_frame_size = dev->_isNTSC_ch2 ? NTSC_DATA_BUF_SZ : PAL_DATA_BUF_SZ; |
780 | risc_buffer_size = dev->_isNTSC_ch2 ? NTSC_RISC_BUF_SIZE : PAL_RISC_BUF_SIZE; | 780 | risc_buffer_size = dev->_isNTSC_ch2 ? NTSC_RISC_BUF_SIZE : PAL_RISC_BUF_SIZE; |
781 | 781 | ||
782 | 782 | ||
783 | if( dev->input_filename_ch2 ) | 783 | if( dev->input_filename_ch2 ) |
784 | { | 784 | { |
785 | str_length = strlen(dev->input_filename_ch2); | 785 | str_length = strlen(dev->input_filename_ch2); |
786 | dev->_filename_ch2 = (char *) kmalloc(str_length + 1, GFP_KERNEL); | 786 | dev->_filename_ch2 = (char *) kmalloc(str_length + 1, GFP_KERNEL); |
787 | 787 | ||
788 | if( !dev->_filename_ch2 ) | 788 | if( !dev->_filename_ch2 ) |
789 | goto error; | 789 | goto error; |
790 | 790 | ||
791 | memcpy(dev->_filename_ch2, dev->input_filename_ch2, str_length + 1); | 791 | memcpy(dev->_filename_ch2, dev->input_filename_ch2, str_length + 1); |
792 | } | 792 | } |
793 | else | 793 | else |
794 | { | 794 | { |
795 | str_length = strlen(dev->_defaultname_ch2); | 795 | str_length = strlen(dev->_defaultname_ch2); |
796 | dev->_filename_ch2 = (char *) kmalloc(str_length + 1, GFP_KERNEL); | 796 | dev->_filename_ch2 = (char *) kmalloc(str_length + 1, GFP_KERNEL); |
797 | 797 | ||
798 | if( !dev->_filename_ch2 ) | 798 | if( !dev->_filename_ch2 ) |
799 | goto error; | 799 | goto error; |
800 | 800 | ||
801 | memcpy(dev->_filename_ch2, dev->_defaultname_ch2, str_length + 1); | 801 | memcpy(dev->_filename_ch2, dev->_defaultname_ch2, str_length + 1); |
802 | } | 802 | } |
803 | 803 | ||
804 | 804 | ||
805 | //Default if filename is empty string | 805 | //Default if filename is empty string |
806 | if( strcmp(dev->input_filename_ch2,"") == 0) | 806 | if( strcmp(dev->input_filename_ch2,"") == 0) |
807 | { | 807 | { |
808 | if( dev->_isNTSC_ch2 ) | 808 | if( dev->_isNTSC_ch2 ) |
809 | { | 809 | { |
810 | dev->_filename_ch2 = (dev->_pixel_format_ch2 == PIXEL_FRMT_411) ? "/root/vid411.yuv" : "/root/vidtest.yuv"; | 810 | dev->_filename_ch2 = (dev->_pixel_format_ch2 == PIXEL_FRMT_411) ? "/root/vid411.yuv" : "/root/vidtest.yuv"; |
811 | } | 811 | } |
812 | else | 812 | else |
813 | { | 813 | { |
814 | dev->_filename_ch2 = (dev->_pixel_format_ch2 == PIXEL_FRMT_411) ? "/root/pal411.yuv" : "/root/pal422.yuv"; | 814 | dev->_filename_ch2 = (dev->_pixel_format_ch2 == PIXEL_FRMT_411) ? "/root/pal411.yuv" : "/root/pal422.yuv"; |
815 | } | 815 | } |
816 | } | 816 | } |
817 | 817 | ||
818 | 818 | ||
819 | retval = cx25821_sram_channel_setup_upstream(dev, sram_ch, dev->_line_size_ch2, 0); | 819 | retval = cx25821_sram_channel_setup_upstream(dev, sram_ch, dev->_line_size_ch2, 0); |
820 | 820 | ||
821 | 821 | ||
@@ -830,8 +830,8 @@ int cx25821_vidupstream_init_ch2(struct cx25821_dev *dev, int channel_select, in | |||
830 | retval = cx25821_upstream_buffer_prepare_ch2(dev, sram_ch, dev->_line_size_ch2); | 830 | retval = cx25821_upstream_buffer_prepare_ch2(dev, sram_ch, dev->_line_size_ch2); |
831 | if (retval < 0) | 831 | if (retval < 0) |
832 | { | 832 | { |
833 | printk(KERN_ERR "%s: Failed to set up Video upstream buffers!\n", dev->name); | 833 | printk(KERN_ERR "%s: Failed to set up Video upstream buffers!\n", dev->name); |
834 | goto error; | 834 | goto error; |
835 | } | 835 | } |
836 | 836 | ||
837 | 837 | ||
diff --git a/drivers/staging/cx25821/cx25821-video-upstream-ch2.h b/drivers/staging/cx25821/cx25821-video-upstream-ch2.h index 71de8742be6..02e5b9ba81c 100644 --- a/drivers/staging/cx25821/cx25821-video-upstream-ch2.h +++ b/drivers/staging/cx25821/cx25821-video-upstream-ch2.h | |||
@@ -71,25 +71,25 @@ | |||
71 | 71 | ||
72 | #ifdef USE_RISC_NOOP_VIDEO | 72 | #ifdef USE_RISC_NOOP_VIDEO |
73 | #define PAL_US_VID_PROG_SIZE ((PAL_FIELD_HEIGHT) * 3 * DWORD_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + \ | 73 | #define PAL_US_VID_PROG_SIZE ((PAL_FIELD_HEIGHT) * 3 * DWORD_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + \ |
74 | RISC_SYNC_INSTRUCTION_SIZE + NUM_NO_OPS*DWORD_SIZE) | 74 | RISC_SYNC_INSTRUCTION_SIZE + NUM_NO_OPS*DWORD_SIZE) |
75 | 75 | ||
76 | #define PAL_RISC_BUF_SIZE (2 * PAL_US_VID_PROG_SIZE) | 76 | #define PAL_RISC_BUF_SIZE (2 * PAL_US_VID_PROG_SIZE) |
77 | 77 | ||
78 | #define PAL_VID_PROG_SIZE ((PAL_FIELD_HEIGHT*2) * 3 * DWORD_SIZE + 2*RISC_SYNC_INSTRUCTION_SIZE + \ | 78 | #define PAL_VID_PROG_SIZE ((PAL_FIELD_HEIGHT*2) * 3 * DWORD_SIZE + 2*RISC_SYNC_INSTRUCTION_SIZE + \ |
79 | RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE + 2*NUM_NO_OPS*DWORD_SIZE) | 79 | RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE + 2*NUM_NO_OPS*DWORD_SIZE) |
80 | 80 | ||
81 | #define ODD_FLD_PAL_PROG_SIZE ((PAL_FIELD_HEIGHT) * 3 * DWORD_SIZE + RISC_SYNC_INSTRUCTION_SIZE + \ | 81 | #define ODD_FLD_PAL_PROG_SIZE ((PAL_FIELD_HEIGHT) * 3 * DWORD_SIZE + RISC_SYNC_INSTRUCTION_SIZE + \ |
82 | RISC_WRITECR_INSTRUCTION_SIZE + NUM_NO_OPS*DWORD_SIZE) | 82 | RISC_WRITECR_INSTRUCTION_SIZE + NUM_NO_OPS*DWORD_SIZE) |
83 | 83 | ||
84 | #define NTSC_US_VID_PROG_SIZE ((NTSC_ODD_FLD_LINES + 1) * 3 * DWORD_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + \ | 84 | #define NTSC_US_VID_PROG_SIZE ((NTSC_ODD_FLD_LINES + 1) * 3 * DWORD_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + \ |
85 | JUMP_INSTRUCTION_SIZE + NUM_NO_OPS*DWORD_SIZE) | 85 | JUMP_INSTRUCTION_SIZE + NUM_NO_OPS*DWORD_SIZE) |
86 | 86 | ||
87 | #define NTSC_RISC_BUF_SIZE (2 * (RISC_SYNC_INSTRUCTION_SIZE + NTSC_US_VID_PROG_SIZE)) | 87 | #define NTSC_RISC_BUF_SIZE (2 * (RISC_SYNC_INSTRUCTION_SIZE + NTSC_US_VID_PROG_SIZE)) |
88 | 88 | ||
89 | #define FRAME1_VID_PROG_SIZE ((NTSC_ODD_FLD_LINES + NTSC_FIELD_HEIGHT) * 3 * DWORD_SIZE + 2*RISC_SYNC_INSTRUCTION_SIZE + \ | 89 | #define FRAME1_VID_PROG_SIZE ((NTSC_ODD_FLD_LINES + NTSC_FIELD_HEIGHT) * 3 * DWORD_SIZE + 2*RISC_SYNC_INSTRUCTION_SIZE + \ |
90 | RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE + 2*NUM_NO_OPS*DWORD_SIZE) | 90 | RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE + 2*NUM_NO_OPS*DWORD_SIZE) |
91 | #define ODD_FLD_NTSC_PROG_SIZE ((NTSC_ODD_FLD_LINES) * 3 * DWORD_SIZE + RISC_SYNC_INSTRUCTION_SIZE + \ | 91 | #define ODD_FLD_NTSC_PROG_SIZE ((NTSC_ODD_FLD_LINES) * 3 * DWORD_SIZE + RISC_SYNC_INSTRUCTION_SIZE + \ |
92 | RISC_WRITECR_INSTRUCTION_SIZE + NUM_NO_OPS*DWORD_SIZE) | 92 | RISC_WRITECR_INSTRUCTION_SIZE + NUM_NO_OPS*DWORD_SIZE) |
93 | #endif | 93 | #endif |
94 | 94 | ||
95 | 95 | ||
@@ -97,11 +97,11 @@ | |||
97 | #define PAL_US_VID_PROG_SIZE ((PAL_FIELD_HEIGHT + 1) * 3 * DWORD_SIZE + RISC_WRITECR_INSTRUCTION_SIZE ) | 97 | #define PAL_US_VID_PROG_SIZE ((PAL_FIELD_HEIGHT + 1) * 3 * DWORD_SIZE + RISC_WRITECR_INSTRUCTION_SIZE ) |
98 | #define PAL_RISC_BUF_SIZE ( 2 * (RISC_SYNC_INSTRUCTION_SIZE + PAL_US_VID_PROG_SIZE) ) | 98 | #define PAL_RISC_BUF_SIZE ( 2 * (RISC_SYNC_INSTRUCTION_SIZE + PAL_US_VID_PROG_SIZE) ) |
99 | #define PAL_VID_PROG_SIZE ((PAL_FIELD_HEIGHT*2) * 3 * DWORD_SIZE + 2*RISC_SYNC_INSTRUCTION_SIZE + \ | 99 | #define PAL_VID_PROG_SIZE ((PAL_FIELD_HEIGHT*2) * 3 * DWORD_SIZE + 2*RISC_SYNC_INSTRUCTION_SIZE + \ |
100 | RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE ) | 100 | RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE ) |
101 | #define ODD_FLD_PAL_PROG_SIZE ((PAL_FIELD_HEIGHT) * 3 * DWORD_SIZE + RISC_SYNC_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE ) | 101 | #define ODD_FLD_PAL_PROG_SIZE ((PAL_FIELD_HEIGHT) * 3 * DWORD_SIZE + RISC_SYNC_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE ) |
102 | #define ODD_FLD_NTSC_PROG_SIZE ((NTSC_ODD_FLD_LINES) * 3 * DWORD_SIZE + RISC_SYNC_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE ) | 102 | #define ODD_FLD_NTSC_PROG_SIZE ((NTSC_ODD_FLD_LINES) * 3 * DWORD_SIZE + RISC_SYNC_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE ) |
103 | #define NTSC_US_VID_PROG_SIZE ((NTSC_ODD_FLD_LINES + 1) * 3 * DWORD_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE) | 103 | #define NTSC_US_VID_PROG_SIZE ((NTSC_ODD_FLD_LINES + 1) * 3 * DWORD_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE) |
104 | #define NTSC_RISC_BUF_SIZE (2 * (RISC_SYNC_INSTRUCTION_SIZE + NTSC_US_VID_PROG_SIZE) ) | 104 | #define NTSC_RISC_BUF_SIZE (2 * (RISC_SYNC_INSTRUCTION_SIZE + NTSC_US_VID_PROG_SIZE) ) |
105 | #define FRAME1_VID_PROG_SIZE ((NTSC_ODD_FLD_LINES + NTSC_FIELD_HEIGHT) * 3 * DWORD_SIZE + 2*RISC_SYNC_INSTRUCTION_SIZE + \ | 105 | #define FRAME1_VID_PROG_SIZE ((NTSC_ODD_FLD_LINES + NTSC_FIELD_HEIGHT) * 3 * DWORD_SIZE + 2*RISC_SYNC_INSTRUCTION_SIZE + \ |
106 | RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE ) | 106 | RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE ) |
107 | #endif | 107 | #endif |
diff --git a/drivers/staging/cx25821/cx25821-video-upstream.c b/drivers/staging/cx25821/cx25821-video-upstream.c index 14d204aaa84..0f7a6c5bb1c 100644 --- a/drivers/staging/cx25821/cx25821-video-upstream.c +++ b/drivers/staging/cx25821/cx25821-video-upstream.c | |||
@@ -43,19 +43,19 @@ MODULE_LICENSE("GPL"); | |||
43 | static int _intr_msk = FLD_VID_SRC_RISC1 | FLD_VID_SRC_UF | FLD_VID_SRC_SYNC | FLD_VID_SRC_OPC_ERR; | 43 | static int _intr_msk = FLD_VID_SRC_RISC1 | FLD_VID_SRC_UF | FLD_VID_SRC_SYNC | FLD_VID_SRC_OPC_ERR; |
44 | 44 | ||
45 | int cx25821_sram_channel_setup_upstream(struct cx25821_dev *dev, | 45 | int cx25821_sram_channel_setup_upstream(struct cx25821_dev *dev, |
46 | struct sram_channel *ch, | 46 | struct sram_channel *ch, |
47 | unsigned int bpl, u32 risc) | 47 | unsigned int bpl, u32 risc) |
48 | { | 48 | { |
49 | unsigned int i, lines; | 49 | unsigned int i, lines; |
50 | u32 cdt; | 50 | u32 cdt; |
51 | 51 | ||
52 | 52 | ||
53 | if (ch->cmds_start == 0) { | 53 | if (ch->cmds_start == 0) { |
54 | cx_write(ch->ptr1_reg, 0); | 54 | cx_write(ch->ptr1_reg, 0); |
55 | cx_write(ch->ptr2_reg, 0); | 55 | cx_write(ch->ptr2_reg, 0); |
56 | cx_write(ch->cnt2_reg, 0); | 56 | cx_write(ch->cnt2_reg, 0); |
57 | cx_write(ch->cnt1_reg, 0); | 57 | cx_write(ch->cnt1_reg, 0); |
58 | return 0; | 58 | return 0; |
59 | } | 59 | } |
60 | 60 | ||
61 | bpl = (bpl + 7) & ~7; /* alignment */ | 61 | bpl = (bpl + 7) & ~7; /* alignment */ |
@@ -64,7 +64,7 @@ int cx25821_sram_channel_setup_upstream(struct cx25821_dev *dev, | |||
64 | 64 | ||
65 | if (lines > 4) | 65 | if (lines > 4) |
66 | { | 66 | { |
67 | lines = 4; | 67 | lines = 4; |
68 | } | 68 | } |
69 | 69 | ||
70 | BUG_ON(lines < 2); | 70 | BUG_ON(lines < 2); |
@@ -72,10 +72,10 @@ int cx25821_sram_channel_setup_upstream(struct cx25821_dev *dev, | |||
72 | 72 | ||
73 | /* write CDT */ | 73 | /* write CDT */ |
74 | for (i = 0; i < lines; i++) { | 74 | for (i = 0; i < lines; i++) { |
75 | cx_write(cdt + 16*i, ch->fifo_start + bpl*i); | 75 | cx_write(cdt + 16*i, ch->fifo_start + bpl*i); |
76 | cx_write(cdt + 16*i + 4, 0); | 76 | cx_write(cdt + 16*i + 4, 0); |
77 | cx_write(cdt + 16*i + 8, 0); | 77 | cx_write(cdt + 16*i + 8, 0); |
78 | cx_write(cdt + 16*i + 12, 0); | 78 | cx_write(cdt + 16*i + 12, 0); |
79 | } | 79 | } |
80 | 80 | ||
81 | /* write CMDS */ | 81 | /* write CMDS */ |
@@ -85,12 +85,12 @@ int cx25821_sram_channel_setup_upstream(struct cx25821_dev *dev, | |||
85 | cx_write(ch->cmds_start + 8, cdt); | 85 | cx_write(ch->cmds_start + 8, cdt); |
86 | cx_write(ch->cmds_start + 12, (lines*16) >> 3); | 86 | cx_write(ch->cmds_start + 12, (lines*16) >> 3); |
87 | cx_write(ch->cmds_start + 16, ch->ctrl_start); | 87 | cx_write(ch->cmds_start + 16, ch->ctrl_start); |
88 | 88 | ||
89 | 89 | ||
90 | cx_write(ch->cmds_start + 20, VID_IQ_SIZE_DW); | 90 | cx_write(ch->cmds_start + 20, VID_IQ_SIZE_DW); |
91 | 91 | ||
92 | for (i = 24; i < 80; i += 4) | 92 | for (i = 24; i < 80; i += 4) |
93 | cx_write(ch->cmds_start + i, 0); | 93 | cx_write(ch->cmds_start + i, 0); |
94 | 94 | ||
95 | /* fill registers */ | 95 | /* fill registers */ |
96 | cx_write(ch->ptr1_reg, ch->fifo_start); | 96 | cx_write(ch->ptr1_reg, ch->fifo_start); |
@@ -102,8 +102,8 @@ int cx25821_sram_channel_setup_upstream(struct cx25821_dev *dev, | |||
102 | } | 102 | } |
103 | 103 | ||
104 | static __le32 *cx25821_update_riscprogram( struct cx25821_dev *dev, | 104 | static __le32 *cx25821_update_riscprogram( struct cx25821_dev *dev, |
105 | __le32 *rp, unsigned int offset, unsigned int bpl, | 105 | __le32 *rp, unsigned int offset, unsigned int bpl, |
106 | u32 sync_line, unsigned int lines, int fifo_enable, int field_type) | 106 | u32 sync_line, unsigned int lines, int fifo_enable, int field_type) |
107 | { | 107 | { |
108 | unsigned int line, i; | 108 | unsigned int line, i; |
109 | int dist_betwn_starts = bpl * 2; | 109 | int dist_betwn_starts = bpl * 2; |
@@ -114,85 +114,85 @@ static __le32 *cx25821_update_riscprogram( struct cx25821_dev *dev, | |||
114 | 114 | ||
115 | if( USE_RISC_NOOP_VIDEO ) | 115 | if( USE_RISC_NOOP_VIDEO ) |
116 | { | 116 | { |
117 | for( i = 0; i < NUM_NO_OPS; i++ ) | 117 | for( i = 0; i < NUM_NO_OPS; i++ ) |
118 | { | 118 | { |
119 | *(rp++) = cpu_to_le32(RISC_NOOP); | 119 | *(rp++) = cpu_to_le32(RISC_NOOP); |
120 | } | 120 | } |
121 | } | 121 | } |
122 | 122 | ||
123 | /* scan lines */ | 123 | /* scan lines */ |
124 | for (line = 0; line < lines; line++) | 124 | for (line = 0; line < lines; line++) |
125 | { | 125 | { |
126 | *(rp++) = cpu_to_le32(RISC_READ|RISC_SOL|RISC_EOL|bpl); | 126 | *(rp++) = cpu_to_le32(RISC_READ|RISC_SOL|RISC_EOL|bpl); |
127 | *(rp++) = cpu_to_le32(dev->_data_buf_phys_addr+offset); | 127 | *(rp++) = cpu_to_le32(dev->_data_buf_phys_addr+offset); |
128 | *(rp++) = cpu_to_le32(0); /* bits 63-32 */ | 128 | *(rp++) = cpu_to_le32(0); /* bits 63-32 */ |
129 | 129 | ||
130 | if ( (lines <= NTSC_FIELD_HEIGHT) || (line < (NTSC_FIELD_HEIGHT-1)) || !(dev->_isNTSC) ) | 130 | if ( (lines <= NTSC_FIELD_HEIGHT) || (line < (NTSC_FIELD_HEIGHT-1)) || !(dev->_isNTSC) ) |
131 | { | 131 | { |
132 | offset += dist_betwn_starts; | 132 | offset += dist_betwn_starts; |
133 | } | 133 | } |
134 | } | 134 | } |
135 | 135 | ||
136 | return rp; | 136 | return rp; |
137 | } | 137 | } |
138 | 138 | ||
139 | static __le32 *cx25821_risc_field_upstream( struct cx25821_dev *dev, __le32 *rp, | 139 | static __le32 *cx25821_risc_field_upstream( struct cx25821_dev *dev, __le32 *rp, |
140 | dma_addr_t databuf_phys_addr, | 140 | dma_addr_t databuf_phys_addr, |
141 | unsigned int offset, u32 sync_line, | 141 | unsigned int offset, u32 sync_line, |
142 | unsigned int bpl, unsigned int lines, int fifo_enable, int field_type) | 142 | unsigned int bpl, unsigned int lines, int fifo_enable, int field_type) |
143 | { | 143 | { |
144 | unsigned int line, i; | 144 | unsigned int line, i; |
145 | struct sram_channel *sram_ch = &dev->sram_channels[dev->_channel_upstream_select]; | 145 | struct sram_channel *sram_ch = &dev->sram_channels[dev->_channel_upstream_select]; |
146 | int dist_betwn_starts = bpl * 2; | 146 | int dist_betwn_starts = bpl * 2; |
147 | 147 | ||
148 | 148 | ||
149 | /* sync instruction */ | 149 | /* sync instruction */ |
150 | if (sync_line != NO_SYNC_LINE) | 150 | if (sync_line != NO_SYNC_LINE) |
151 | { | 151 | { |
152 | *(rp++) = cpu_to_le32(RISC_RESYNC | sync_line); | 152 | *(rp++) = cpu_to_le32(RISC_RESYNC | sync_line); |
153 | } | 153 | } |
154 | 154 | ||
155 | 155 | ||
156 | if( USE_RISC_NOOP_VIDEO ) | 156 | if( USE_RISC_NOOP_VIDEO ) |
157 | { | 157 | { |
158 | for( i = 0; i < NUM_NO_OPS; i++ ) | 158 | for( i = 0; i < NUM_NO_OPS; i++ ) |
159 | { | 159 | { |
160 | *(rp++) = cpu_to_le32(RISC_NOOP); | 160 | *(rp++) = cpu_to_le32(RISC_NOOP); |
161 | } | 161 | } |
162 | } | 162 | } |
163 | 163 | ||
164 | /* scan lines */ | 164 | /* scan lines */ |
165 | for (line = 0; line < lines; line++) | 165 | for (line = 0; line < lines; line++) |
166 | { | 166 | { |
167 | *(rp++) = cpu_to_le32(RISC_READ|RISC_SOL|RISC_EOL|bpl); | 167 | *(rp++) = cpu_to_le32(RISC_READ|RISC_SOL|RISC_EOL|bpl); |
168 | *(rp++) = cpu_to_le32(databuf_phys_addr+offset); | 168 | *(rp++) = cpu_to_le32(databuf_phys_addr+offset); |
169 | *(rp++) = cpu_to_le32(0); /* bits 63-32 */ | 169 | *(rp++) = cpu_to_le32(0); /* bits 63-32 */ |
170 | 170 | ||
171 | 171 | ||
172 | if ( (lines <= NTSC_FIELD_HEIGHT) || (line < (NTSC_FIELD_HEIGHT-1)) || !(dev->_isNTSC) ) | 172 | if ( (lines <= NTSC_FIELD_HEIGHT) || (line < (NTSC_FIELD_HEIGHT-1)) || !(dev->_isNTSC) ) |
173 | { | 173 | { |
174 | offset += dist_betwn_starts; //to skip the other field line | 174 | offset += dist_betwn_starts; //to skip the other field line |
175 | } | 175 | } |
176 | 176 | ||
177 | 177 | ||
178 | // check if we need to enable the FIFO after the first 4 lines | 178 | // check if we need to enable the FIFO after the first 4 lines |
179 | // For the upstream video channel, the risc engine will enable the FIFO. | 179 | // For the upstream video channel, the risc engine will enable the FIFO. |
180 | if ( fifo_enable && line == 3 ) | 180 | if ( fifo_enable && line == 3 ) |
181 | { | 181 | { |
182 | *(rp++) = RISC_WRITECR; | 182 | *(rp++) = RISC_WRITECR; |
183 | *(rp++) = sram_ch->dma_ctl; | 183 | *(rp++) = sram_ch->dma_ctl; |
184 | *(rp++) = FLD_VID_FIFO_EN; | 184 | *(rp++) = FLD_VID_FIFO_EN; |
185 | *(rp++) = 0x00000001; | 185 | *(rp++) = 0x00000001; |
186 | } | 186 | } |
187 | } | 187 | } |
188 | 188 | ||
189 | return rp; | 189 | return rp; |
190 | } | 190 | } |
191 | 191 | ||
192 | int cx25821_risc_buffer_upstream( struct cx25821_dev *dev, | 192 | int cx25821_risc_buffer_upstream( struct cx25821_dev *dev, |
193 | struct pci_dev *pci, | 193 | struct pci_dev *pci, |
194 | unsigned int top_offset, | 194 | unsigned int top_offset, |
195 | unsigned int bpl, unsigned int lines) | 195 | unsigned int bpl, unsigned int lines) |
196 | { | 196 | { |
197 | __le32 *rp; | 197 | __le32 *rp; |
198 | int fifo_enable = 0; | 198 | int fifo_enable = 0; |
@@ -205,57 +205,57 @@ int cx25821_risc_buffer_upstream( struct cx25821_dev *dev, | |||
205 | int risc_flag = RISC_CNT_RESET; | 205 | int risc_flag = RISC_CNT_RESET; |
206 | unsigned int bottom_offset = bpl; | 206 | unsigned int bottom_offset = bpl; |
207 | dma_addr_t risc_phys_jump_addr; | 207 | dma_addr_t risc_phys_jump_addr; |
208 | 208 | ||
209 | if( dev->_isNTSC ) | 209 | if( dev->_isNTSC ) |
210 | { | 210 | { |
211 | odd_num_lines = singlefield_lines + 1; | 211 | odd_num_lines = singlefield_lines + 1; |
212 | risc_program_size = FRAME1_VID_PROG_SIZE; | 212 | risc_program_size = FRAME1_VID_PROG_SIZE; |
213 | frame_size = (bpl == Y411_LINE_SZ) ? FRAME_SIZE_NTSC_Y411 : FRAME_SIZE_NTSC_Y422; | 213 | frame_size = (bpl == Y411_LINE_SZ) ? FRAME_SIZE_NTSC_Y411 : FRAME_SIZE_NTSC_Y422; |
214 | } | 214 | } |
215 | else | 215 | else |
216 | { | 216 | { |
217 | risc_program_size = PAL_VID_PROG_SIZE; | 217 | risc_program_size = PAL_VID_PROG_SIZE; |
218 | frame_size = (bpl == Y411_LINE_SZ) ? FRAME_SIZE_PAL_Y411 : FRAME_SIZE_PAL_Y422; | 218 | frame_size = (bpl == Y411_LINE_SZ) ? FRAME_SIZE_PAL_Y411 : FRAME_SIZE_PAL_Y422; |
219 | } | 219 | } |
220 | 220 | ||
221 | 221 | ||
222 | /* Virtual address of Risc buffer program */ | 222 | /* Virtual address of Risc buffer program */ |
223 | rp = dev->_dma_virt_addr; | 223 | rp = dev->_dma_virt_addr; |
224 | 224 | ||
225 | for( frame = 0; frame < NUM_FRAMES; frame++ ) | 225 | for( frame = 0; frame < NUM_FRAMES; frame++ ) |
226 | { | 226 | { |
227 | databuf_offset = frame_size * frame; | 227 | databuf_offset = frame_size * frame; |
228 | 228 | ||
229 | if (UNSET != top_offset) | 229 | if (UNSET != top_offset) |
230 | { | 230 | { |
231 | fifo_enable = (frame == 0) ? FIFO_ENABLE : FIFO_DISABLE; | 231 | fifo_enable = (frame == 0) ? FIFO_ENABLE : FIFO_DISABLE; |
232 | rp = cx25821_risc_field_upstream(dev, rp, dev->_data_buf_phys_addr+databuf_offset, top_offset, 0, bpl, odd_num_lines, fifo_enable, ODD_FIELD); | 232 | rp = cx25821_risc_field_upstream(dev, rp, dev->_data_buf_phys_addr+databuf_offset, top_offset, 0, bpl, odd_num_lines, fifo_enable, ODD_FIELD); |
233 | } | 233 | } |
234 | 234 | ||
235 | 235 | ||
236 | fifo_enable = FIFO_DISABLE; | 236 | fifo_enable = FIFO_DISABLE; |
237 | 237 | ||
238 | 238 | ||
239 | //Even Field | 239 | //Even Field |
240 | rp = cx25821_risc_field_upstream(dev, rp, dev->_data_buf_phys_addr+databuf_offset, bottom_offset, 0x200, bpl, singlefield_lines, fifo_enable, EVEN_FIELD); | 240 | rp = cx25821_risc_field_upstream(dev, rp, dev->_data_buf_phys_addr+databuf_offset, bottom_offset, 0x200, bpl, singlefield_lines, fifo_enable, EVEN_FIELD); |
241 | 241 | ||
242 | 242 | ||
243 | if( frame == 0 ) | 243 | if( frame == 0 ) |
244 | { | 244 | { |
245 | risc_flag = RISC_CNT_RESET; | 245 | risc_flag = RISC_CNT_RESET; |
246 | risc_phys_jump_addr = dev->_dma_phys_start_addr + risc_program_size; | 246 | risc_phys_jump_addr = dev->_dma_phys_start_addr + risc_program_size; |
247 | } | 247 | } |
248 | else | 248 | else |
249 | { | 249 | { |
250 | risc_phys_jump_addr = dev->_dma_phys_start_addr; | 250 | risc_phys_jump_addr = dev->_dma_phys_start_addr; |
251 | risc_flag = RISC_CNT_INC; | 251 | risc_flag = RISC_CNT_INC; |
252 | } | 252 | } |
253 | 253 | ||
254 | 254 | ||
255 | // Loop to 2ndFrameRISC or to Start of Risc program & generate IRQ | 255 | // Loop to 2ndFrameRISC or to Start of Risc program & generate IRQ |
256 | *(rp++) = cpu_to_le32(RISC_JUMP|RISC_IRQ1|risc_flag); | 256 | *(rp++) = cpu_to_le32(RISC_JUMP|RISC_IRQ1|risc_flag); |
257 | *(rp++) = cpu_to_le32(risc_phys_jump_addr); | 257 | *(rp++) = cpu_to_le32(risc_phys_jump_addr); |
258 | *(rp++) = cpu_to_le32(0); | 258 | *(rp++) = cpu_to_le32(0); |
259 | } | 259 | } |
260 | 260 | ||
261 | return 0; | 261 | return 0; |
@@ -269,10 +269,10 @@ void cx25821_stop_upstream_video_ch1(struct cx25821_dev *dev) | |||
269 | 269 | ||
270 | if( !dev->_is_running ) | 270 | if( !dev->_is_running ) |
271 | { | 271 | { |
272 | printk("cx25821: No video file is currently running so return!\n"); | 272 | printk("cx25821: No video file is currently running so return!\n"); |
273 | return; | 273 | return; |
274 | } | 274 | } |
275 | 275 | ||
276 | //Disable RISC interrupts | 276 | //Disable RISC interrupts |
277 | tmp = cx_read( sram_ch->int_msk ); | 277 | tmp = cx_read( sram_ch->int_msk ); |
278 | cx_write( sram_ch->int_msk, tmp & ~_intr_msk); | 278 | cx_write( sram_ch->int_msk, tmp & ~_intr_msk); |
@@ -283,8 +283,8 @@ void cx25821_stop_upstream_video_ch1(struct cx25821_dev *dev) | |||
283 | 283 | ||
284 | //Clear data buffer memory | 284 | //Clear data buffer memory |
285 | if( dev->_data_buf_virt_addr ) | 285 | if( dev->_data_buf_virt_addr ) |
286 | memset( dev->_data_buf_virt_addr, 0, dev->_data_buf_size ); | 286 | memset( dev->_data_buf_virt_addr, 0, dev->_data_buf_size ); |
287 | 287 | ||
288 | dev->_is_running = 0; | 288 | dev->_is_running = 0; |
289 | dev->_is_first_frame = 0; | 289 | dev->_is_first_frame = 0; |
290 | dev->_frame_count = 0; | 290 | dev->_frame_count = 0; |
@@ -292,12 +292,12 @@ void cx25821_stop_upstream_video_ch1(struct cx25821_dev *dev) | |||
292 | 292 | ||
293 | if( dev->_irq_queues ) | 293 | if( dev->_irq_queues ) |
294 | { | 294 | { |
295 | kfree(dev->_irq_queues); | 295 | kfree(dev->_irq_queues); |
296 | dev->_irq_queues = NULL; | 296 | dev->_irq_queues = NULL; |
297 | } | 297 | } |
298 | 298 | ||
299 | if( dev->_filename != NULL ) | 299 | if( dev->_filename != NULL ) |
300 | kfree(dev->_filename); | 300 | kfree(dev->_filename); |
301 | 301 | ||
302 | tmp = cx_read( VID_CH_MODE_SEL ); | 302 | tmp = cx_read( VID_CH_MODE_SEL ); |
303 | cx_write( VID_CH_MODE_SEL, tmp & 0xFFFFFE00); | 303 | cx_write( VID_CH_MODE_SEL, tmp & 0xFFFFFE00); |
@@ -307,19 +307,19 @@ void cx25821_free_mem_upstream_ch1(struct cx25821_dev *dev) | |||
307 | { | 307 | { |
308 | if( dev->_is_running ) | 308 | if( dev->_is_running ) |
309 | { | 309 | { |
310 | cx25821_stop_upstream_video_ch1(dev); | 310 | cx25821_stop_upstream_video_ch1(dev); |
311 | } | 311 | } |
312 | 312 | ||
313 | if (dev->_dma_virt_addr) | 313 | if (dev->_dma_virt_addr) |
314 | { | 314 | { |
315 | pci_free_consistent(dev->pci, dev->_risc_size, dev->_dma_virt_addr, dev->_dma_phys_addr); | 315 | pci_free_consistent(dev->pci, dev->_risc_size, dev->_dma_virt_addr, dev->_dma_phys_addr); |
316 | dev->_dma_virt_addr = NULL; | 316 | dev->_dma_virt_addr = NULL; |
317 | } | 317 | } |
318 | 318 | ||
319 | if (dev->_data_buf_virt_addr) | 319 | if (dev->_data_buf_virt_addr) |
320 | { | 320 | { |
321 | pci_free_consistent(dev->pci, dev->_data_buf_size, dev->_data_buf_virt_addr, dev->_data_buf_phys_addr); | 321 | pci_free_consistent(dev->pci, dev->_data_buf_size, dev->_data_buf_virt_addr, dev->_data_buf_phys_addr); |
322 | dev->_data_buf_virt_addr = NULL; | 322 | dev->_data_buf_virt_addr = NULL; |
323 | } | 323 | } |
324 | } | 324 | } |
325 | 325 | ||
@@ -337,84 +337,84 @@ int cx25821_get_frame(struct cx25821_dev *dev, struct sram_channel *sram_ch ) | |||
337 | loff_t file_offset; | 337 | loff_t file_offset; |
338 | loff_t pos; | 338 | loff_t pos; |
339 | mm_segment_t old_fs; | 339 | mm_segment_t old_fs; |
340 | 340 | ||
341 | 341 | ||
342 | if( dev->_file_status == END_OF_FILE ) | 342 | if( dev->_file_status == END_OF_FILE ) |
343 | return 0; | 343 | return 0; |
344 | 344 | ||
345 | if( dev->_isNTSC ) | 345 | if( dev->_isNTSC ) |
346 | { | 346 | { |
347 | frame_size = (line_size == Y411_LINE_SZ) ? FRAME_SIZE_NTSC_Y411 : FRAME_SIZE_NTSC_Y422; | 347 | frame_size = (line_size == Y411_LINE_SZ) ? FRAME_SIZE_NTSC_Y411 : FRAME_SIZE_NTSC_Y422; |
348 | } | 348 | } |
349 | else | 349 | else |
350 | { | 350 | { |
351 | frame_size = (line_size == Y411_LINE_SZ) ? FRAME_SIZE_PAL_Y411 : FRAME_SIZE_PAL_Y422; | 351 | frame_size = (line_size == Y411_LINE_SZ) ? FRAME_SIZE_PAL_Y411 : FRAME_SIZE_PAL_Y422; |
352 | } | 352 | } |
353 | 353 | ||
354 | frame_offset = (frame_index_temp > 0) ? frame_size : 0; | 354 | frame_offset = (frame_index_temp > 0) ? frame_size : 0; |
355 | file_offset = dev->_frame_count * frame_size; | 355 | file_offset = dev->_frame_count * frame_size; |
356 | 356 | ||
357 | 357 | ||
358 | myfile = filp_open( dev->_filename, O_RDONLY | O_LARGEFILE, 0 ); | 358 | myfile = filp_open( dev->_filename, O_RDONLY | O_LARGEFILE, 0 ); |
359 | 359 | ||
360 | 360 | ||
361 | if (IS_ERR(myfile)) | 361 | if (IS_ERR(myfile)) |
362 | { | 362 | { |
363 | const int open_errno = -PTR_ERR(myfile); | 363 | const int open_errno = -PTR_ERR(myfile); |
364 | printk("%s(): ERROR opening file(%s) with errno = %d! \n", __func__, dev->_filename, open_errno); | 364 | printk("%s(): ERROR opening file(%s) with errno = %d! \n", __func__, dev->_filename, open_errno); |
365 | return PTR_ERR(myfile); | 365 | return PTR_ERR(myfile); |
366 | } | 366 | } |
367 | else | 367 | else |
368 | { | 368 | { |
369 | if( !(myfile->f_op) ) | 369 | if( !(myfile->f_op) ) |
370 | { | 370 | { |
371 | printk("%s: File has no file operations registered!", __func__); | 371 | printk("%s: File has no file operations registered!", __func__); |
372 | filp_close(myfile, NULL); | 372 | filp_close(myfile, NULL); |
373 | return -EIO; | 373 | return -EIO; |
374 | } | 374 | } |
375 | 375 | ||
376 | 376 | ||
377 | if( !myfile->f_op->read ) | 377 | if( !myfile->f_op->read ) |
378 | { | 378 | { |
379 | printk("%s: File has no READ operations registered!", __func__); | 379 | printk("%s: File has no READ operations registered!", __func__); |
380 | filp_close(myfile, NULL); | 380 | filp_close(myfile, NULL); |
381 | return -EIO; | 381 | return -EIO; |
382 | } | 382 | } |
383 | 383 | ||
384 | pos = myfile->f_pos; | 384 | pos = myfile->f_pos; |
385 | old_fs = get_fs(); | 385 | old_fs = get_fs(); |
386 | set_fs(KERNEL_DS); | 386 | set_fs(KERNEL_DS); |
387 | 387 | ||
388 | 388 | ||
389 | for( i = 0; i < dev->_lines_count; i++ ) | 389 | for( i = 0; i < dev->_lines_count; i++ ) |
390 | { | 390 | { |
391 | pos = file_offset; | 391 | pos = file_offset; |
392 | 392 | ||
393 | vfs_read_retval = vfs_read(myfile, mybuf, line_size, &pos); | 393 | vfs_read_retval = vfs_read(myfile, mybuf, line_size, &pos); |
394 | 394 | ||
395 | if( vfs_read_retval > 0 && vfs_read_retval == line_size && dev->_data_buf_virt_addr != NULL ) | 395 | if( vfs_read_retval > 0 && vfs_read_retval == line_size && dev->_data_buf_virt_addr != NULL ) |
396 | { | 396 | { |
397 | memcpy( (void*)(dev->_data_buf_virt_addr+frame_offset/4), mybuf, vfs_read_retval); | 397 | memcpy( (void*)(dev->_data_buf_virt_addr+frame_offset/4), mybuf, vfs_read_retval); |
398 | } | 398 | } |
399 | 399 | ||
400 | file_offset += vfs_read_retval; | 400 | file_offset += vfs_read_retval; |
401 | frame_offset += vfs_read_retval; | 401 | frame_offset += vfs_read_retval; |
402 | 402 | ||
403 | if( vfs_read_retval < line_size ) | 403 | if( vfs_read_retval < line_size ) |
404 | { | 404 | { |
405 | printk(KERN_INFO "Done: exit %s() since no more bytes to read from Video file.\n", __func__ ); | 405 | printk(KERN_INFO "Done: exit %s() since no more bytes to read from Video file.\n", __func__ ); |
406 | break; | 406 | break; |
407 | } | 407 | } |
408 | } | 408 | } |
409 | 409 | ||
410 | if( i > 0 ) | 410 | if( i > 0 ) |
411 | dev->_frame_count++; | 411 | dev->_frame_count++; |
412 | 412 | ||
413 | dev->_file_status = (vfs_read_retval == line_size) ? IN_PROGRESS : END_OF_FILE; | 413 | dev->_file_status = (vfs_read_retval == line_size) ? IN_PROGRESS : END_OF_FILE; |
414 | 414 | ||
415 | 415 | ||
416 | set_fs(old_fs); | 416 | set_fs(old_fs); |
417 | filp_close(myfile, NULL); | 417 | filp_close(myfile, NULL); |
418 | } | 418 | } |
419 | 419 | ||
420 | return 0; | 420 | return 0; |
@@ -426,8 +426,8 @@ static void cx25821_vidups_handler(struct work_struct *work) | |||
426 | 426 | ||
427 | if( !dev ) | 427 | if( !dev ) |
428 | { | 428 | { |
429 | printk("ERROR %s(): since container_of(work_struct) FAILED! \n", __func__ ); | 429 | printk("ERROR %s(): since container_of(work_struct) FAILED! \n", __func__ ); |
430 | return; | 430 | return; |
431 | } | 431 | } |
432 | 432 | ||
433 | cx25821_get_frame( dev, &dev->sram_channels[dev->_channel_upstream_select] ); | 433 | cx25821_get_frame( dev, &dev->sram_channels[dev->_channel_upstream_select] ); |
@@ -444,77 +444,77 @@ int cx25821_openfile(struct cx25821_dev *dev, struct sram_channel *sram_ch) | |||
444 | loff_t pos; | 444 | loff_t pos; |
445 | loff_t offset = (unsigned long)0; | 445 | loff_t offset = (unsigned long)0; |
446 | mm_segment_t old_fs; | 446 | mm_segment_t old_fs; |
447 | 447 | ||
448 | 448 | ||
449 | myfile = filp_open( dev->_filename, O_RDONLY | O_LARGEFILE, 0 ); | 449 | myfile = filp_open( dev->_filename, O_RDONLY | O_LARGEFILE, 0 ); |
450 | 450 | ||
451 | 451 | ||
452 | if (IS_ERR(myfile)) | 452 | if (IS_ERR(myfile)) |
453 | { | 453 | { |
454 | const int open_errno = -PTR_ERR(myfile); | 454 | const int open_errno = -PTR_ERR(myfile); |
455 | printk("%s(): ERROR opening file(%s) with errno = %d! \n", __func__, dev->_filename, open_errno); | 455 | printk("%s(): ERROR opening file(%s) with errno = %d! \n", __func__, dev->_filename, open_errno); |
456 | return PTR_ERR(myfile); | 456 | return PTR_ERR(myfile); |
457 | } | 457 | } |
458 | else | 458 | else |
459 | { | 459 | { |
460 | if( !(myfile->f_op) ) | 460 | if( !(myfile->f_op) ) |
461 | { | 461 | { |
462 | printk("%s: File has no file operations registered!", __func__); | 462 | printk("%s: File has no file operations registered!", __func__); |
463 | filp_close(myfile, NULL); | 463 | filp_close(myfile, NULL); |
464 | return -EIO; | 464 | return -EIO; |
465 | } | 465 | } |
466 | 466 | ||
467 | 467 | ||
468 | if( !myfile->f_op->read ) | 468 | if( !myfile->f_op->read ) |
469 | { | 469 | { |
470 | printk("%s: File has no READ operations registered! Returning.", __func__); | 470 | printk("%s: File has no READ operations registered! Returning.", __func__); |
471 | filp_close(myfile, NULL); | 471 | filp_close(myfile, NULL); |
472 | return -EIO; | 472 | return -EIO; |
473 | } | 473 | } |
474 | 474 | ||
475 | pos = myfile->f_pos; | 475 | pos = myfile->f_pos; |
476 | old_fs = get_fs(); | 476 | old_fs = get_fs(); |
477 | set_fs(KERNEL_DS); | 477 | set_fs(KERNEL_DS); |
478 | 478 | ||
479 | 479 | ||
480 | for( j = 0; j < NUM_FRAMES; j++ ) | 480 | for( j = 0; j < NUM_FRAMES; j++ ) |
481 | { | 481 | { |
482 | for( i = 0; i < dev->_lines_count; i++ ) | 482 | for( i = 0; i < dev->_lines_count; i++ ) |
483 | { | 483 | { |
484 | pos = offset; | 484 | pos = offset; |
485 | 485 | ||
486 | vfs_read_retval = vfs_read(myfile, mybuf, line_size, &pos); | 486 | vfs_read_retval = vfs_read(myfile, mybuf, line_size, &pos); |
487 | 487 | ||
488 | if( vfs_read_retval > 0 && vfs_read_retval == line_size && dev->_data_buf_virt_addr != NULL ) | 488 | if( vfs_read_retval > 0 && vfs_read_retval == line_size && dev->_data_buf_virt_addr != NULL ) |
489 | { | 489 | { |
490 | memcpy( (void*)(dev->_data_buf_virt_addr+offset/4), mybuf, vfs_read_retval); | 490 | memcpy( (void*)(dev->_data_buf_virt_addr+offset/4), mybuf, vfs_read_retval); |
491 | } | 491 | } |
492 | 492 | ||
493 | 493 | ||
494 | offset += vfs_read_retval; | 494 | offset += vfs_read_retval; |
495 | 495 | ||
496 | if( vfs_read_retval < line_size ) | 496 | if( vfs_read_retval < line_size ) |
497 | { | 497 | { |
498 | printk(KERN_INFO "Done: exit %s() since no more bytes to read from Video file.\n", __func__ ); | 498 | printk(KERN_INFO "Done: exit %s() since no more bytes to read from Video file.\n", __func__ ); |
499 | break; | 499 | break; |
500 | } | 500 | } |
501 | } | 501 | } |
502 | 502 | ||
503 | if( i > 0 ) | 503 | if( i > 0 ) |
504 | dev->_frame_count++; | 504 | dev->_frame_count++; |
505 | 505 | ||
506 | if( vfs_read_retval < line_size ) | 506 | if( vfs_read_retval < line_size ) |
507 | { | 507 | { |
508 | break; | 508 | break; |
509 | } | 509 | } |
510 | } | 510 | } |
511 | 511 | ||
512 | 512 | ||
513 | dev->_file_status = (vfs_read_retval == line_size) ? IN_PROGRESS : END_OF_FILE; | 513 | dev->_file_status = (vfs_read_retval == line_size) ? IN_PROGRESS : END_OF_FILE; |
514 | 514 | ||
515 | set_fs(old_fs); | 515 | set_fs(old_fs); |
516 | myfile->f_pos = 0; | 516 | myfile->f_pos = 0; |
517 | filp_close(myfile, NULL); | 517 | filp_close(myfile, NULL); |
518 | } | 518 | } |
519 | 519 | ||
520 | return 0; | 520 | return 0; |
@@ -522,8 +522,8 @@ int cx25821_openfile(struct cx25821_dev *dev, struct sram_channel *sram_ch) | |||
522 | 522 | ||
523 | 523 | ||
524 | int cx25821_upstream_buffer_prepare(struct cx25821_dev *dev, | 524 | int cx25821_upstream_buffer_prepare(struct cx25821_dev *dev, |
525 | struct sram_channel *sram_ch, | 525 | struct sram_channel *sram_ch, |
526 | int bpl) | 526 | int bpl) |
527 | { | 527 | { |
528 | int ret = 0; | 528 | int ret = 0; |
529 | dma_addr_t dma_addr; | 529 | dma_addr_t dma_addr; |
@@ -531,7 +531,7 @@ int cx25821_upstream_buffer_prepare(struct cx25821_dev *dev, | |||
531 | 531 | ||
532 | if( dev->_dma_virt_addr != NULL ) | 532 | if( dev->_dma_virt_addr != NULL ) |
533 | { | 533 | { |
534 | pci_free_consistent(dev->pci, dev->upstream_riscbuf_size, dev->_dma_virt_addr, dev->_dma_phys_addr); | 534 | pci_free_consistent(dev->pci, dev->upstream_riscbuf_size, dev->_dma_virt_addr, dev->_dma_phys_addr); |
535 | } | 535 | } |
536 | 536 | ||
537 | 537 | ||
@@ -544,8 +544,8 @@ int cx25821_upstream_buffer_prepare(struct cx25821_dev *dev, | |||
544 | 544 | ||
545 | if (!dev->_dma_virt_addr) | 545 | if (!dev->_dma_virt_addr) |
546 | { | 546 | { |
547 | printk("cx25821: FAILED to allocate memory for Risc buffer! Returning.\n"); | 547 | printk("cx25821: FAILED to allocate memory for Risc buffer! Returning.\n"); |
548 | return -ENOMEM; | 548 | return -ENOMEM; |
549 | } | 549 | } |
550 | 550 | ||
551 | 551 | ||
@@ -555,7 +555,7 @@ int cx25821_upstream_buffer_prepare(struct cx25821_dev *dev, | |||
555 | 555 | ||
556 | if( dev->_data_buf_virt_addr != NULL ) | 556 | if( dev->_data_buf_virt_addr != NULL ) |
557 | { | 557 | { |
558 | pci_free_consistent(dev->pci, dev->upstream_databuf_size, dev->_data_buf_virt_addr, dev->_data_buf_phys_addr); | 558 | pci_free_consistent(dev->pci, dev->upstream_databuf_size, dev->_data_buf_virt_addr, dev->_data_buf_phys_addr); |
559 | } | 559 | } |
560 | 560 | ||
561 | //For Video Data buffer allocation | 561 | //For Video Data buffer allocation |
@@ -565,8 +565,8 @@ int cx25821_upstream_buffer_prepare(struct cx25821_dev *dev, | |||
565 | 565 | ||
566 | if (!dev->_data_buf_virt_addr) | 566 | if (!dev->_data_buf_virt_addr) |
567 | { | 567 | { |
568 | printk("cx25821: FAILED to allocate memory for data buffer! Returning.\n"); | 568 | printk("cx25821: FAILED to allocate memory for data buffer! Returning.\n"); |
569 | return -ENOMEM; | 569 | return -ENOMEM; |
570 | } | 570 | } |
571 | 571 | ||
572 | 572 | ||
@@ -576,15 +576,15 @@ int cx25821_upstream_buffer_prepare(struct cx25821_dev *dev, | |||
576 | 576 | ||
577 | ret = cx25821_openfile(dev, sram_ch); | 577 | ret = cx25821_openfile(dev, sram_ch); |
578 | if( ret < 0 ) | 578 | if( ret < 0 ) |
579 | return ret; | 579 | return ret; |
580 | 580 | ||
581 | 581 | ||
582 | //Create RISC programs | 582 | //Create RISC programs |
583 | ret = cx25821_risc_buffer_upstream(dev, dev->pci, 0, bpl, dev->_lines_count ); | 583 | ret = cx25821_risc_buffer_upstream(dev, dev->pci, 0, bpl, dev->_lines_count ); |
584 | if (ret < 0) | 584 | if (ret < 0) |
585 | { | 585 | { |
586 | printk(KERN_INFO "cx25821: Failed creating Video Upstream Risc programs! \n"); | 586 | printk(KERN_INFO "cx25821: Failed creating Video Upstream Risc programs! \n"); |
587 | goto error; | 587 | goto error; |
588 | } | 588 | } |
589 | 589 | ||
590 | return 0; | 590 | return 0; |
@@ -607,70 +607,70 @@ int cx25821_video_upstream_irq(struct cx25821_dev *dev, int chan_num, u32 status | |||
607 | 607 | ||
608 | if (status & FLD_VID_SRC_RISC1) | 608 | if (status & FLD_VID_SRC_RISC1) |
609 | { | 609 | { |
610 | // We should only process one program per call | 610 | // We should only process one program per call |
611 | u32 prog_cnt = cx_read( channel->gpcnt ); | 611 | u32 prog_cnt = cx_read( channel->gpcnt ); |
612 | 612 | ||
613 | //Since we've identified our IRQ, clear our bits from the interrupt mask and interrupt status registers | 613 | //Since we've identified our IRQ, clear our bits from the interrupt mask and interrupt status registers |
614 | int_msk_tmp = cx_read(channel->int_msk); | 614 | int_msk_tmp = cx_read(channel->int_msk); |
615 | cx_write(channel->int_msk, int_msk_tmp & ~_intr_msk); | 615 | cx_write(channel->int_msk, int_msk_tmp & ~_intr_msk); |
616 | cx_write( channel->int_stat, _intr_msk ); | 616 | cx_write( channel->int_stat, _intr_msk ); |
617 | 617 | ||
618 | spin_lock(&dev->slock); | 618 | spin_lock(&dev->slock); |
619 | 619 | ||
620 | dev->_frame_index = prog_cnt; | 620 | dev->_frame_index = prog_cnt; |
621 | 621 | ||
622 | queue_work(dev->_irq_queues, &dev->_irq_work_entry); | 622 | queue_work(dev->_irq_queues, &dev->_irq_work_entry); |
623 | 623 | ||
624 | 624 | ||
625 | if ( dev->_is_first_frame ) | 625 | if ( dev->_is_first_frame ) |
626 | { | 626 | { |
627 | dev->_is_first_frame = 0; | 627 | dev->_is_first_frame = 0; |
628 | 628 | ||
629 | if( dev->_isNTSC ) | 629 | if( dev->_isNTSC ) |
630 | { | 630 | { |
631 | singlefield_lines += 1; | 631 | singlefield_lines += 1; |
632 | odd_risc_prog_size = ODD_FLD_NTSC_PROG_SIZE; | 632 | odd_risc_prog_size = ODD_FLD_NTSC_PROG_SIZE; |
633 | } | 633 | } |
634 | else | 634 | else |
635 | { | 635 | { |
636 | singlefield_lines = PAL_FIELD_HEIGHT; | 636 | singlefield_lines = PAL_FIELD_HEIGHT; |
637 | odd_risc_prog_size = ODD_FLD_PAL_PROG_SIZE; | 637 | odd_risc_prog_size = ODD_FLD_PAL_PROG_SIZE; |
638 | } | 638 | } |
639 | 639 | ||
640 | 640 | ||
641 | if( dev->_dma_virt_start_addr != NULL ) | 641 | if( dev->_dma_virt_start_addr != NULL ) |
642 | { | 642 | { |
643 | line_size_in_bytes = (dev->_pixel_format == PIXEL_FRMT_411) ? Y411_LINE_SZ : Y422_LINE_SZ; | 643 | line_size_in_bytes = (dev->_pixel_format == PIXEL_FRMT_411) ? Y411_LINE_SZ : Y422_LINE_SZ; |
644 | risc_phys_jump_addr = dev->_dma_phys_start_addr + odd_risc_prog_size; | 644 | risc_phys_jump_addr = dev->_dma_phys_start_addr + odd_risc_prog_size; |
645 | 645 | ||
646 | rp = cx25821_update_riscprogram(dev, dev->_dma_virt_start_addr, TOP_OFFSET, line_size_in_bytes, 0x0, singlefield_lines, FIFO_DISABLE, ODD_FIELD); | 646 | rp = cx25821_update_riscprogram(dev, dev->_dma_virt_start_addr, TOP_OFFSET, line_size_in_bytes, 0x0, singlefield_lines, FIFO_DISABLE, ODD_FIELD); |
647 | 647 | ||
648 | // Jump to Even Risc program of 1st Frame | 648 | // Jump to Even Risc program of 1st Frame |
649 | *(rp++) = cpu_to_le32(RISC_JUMP); | 649 | *(rp++) = cpu_to_le32(RISC_JUMP); |
650 | *(rp++) = cpu_to_le32(risc_phys_jump_addr); | 650 | *(rp++) = cpu_to_le32(risc_phys_jump_addr); |
651 | *(rp++) = cpu_to_le32(0); | 651 | *(rp++) = cpu_to_le32(0); |
652 | } | 652 | } |
653 | } | 653 | } |
654 | 654 | ||
655 | spin_unlock(&dev->slock); | 655 | spin_unlock(&dev->slock); |
656 | } | 656 | } |
657 | else | 657 | else |
658 | { | 658 | { |
659 | if(status & FLD_VID_SRC_UF) | 659 | if(status & FLD_VID_SRC_UF) |
660 | printk("%s: Video Received Underflow Error Interrupt!\n", __func__); | 660 | printk("%s: Video Received Underflow Error Interrupt!\n", __func__); |
661 | 661 | ||
662 | if(status & FLD_VID_SRC_SYNC) | 662 | if(status & FLD_VID_SRC_SYNC) |
663 | printk("%s: Video Received Sync Error Interrupt!\n", __func__); | 663 | printk("%s: Video Received Sync Error Interrupt!\n", __func__); |
664 | 664 | ||
665 | if(status & FLD_VID_SRC_OPC_ERR) | 665 | if(status & FLD_VID_SRC_OPC_ERR) |
666 | printk("%s: Video Received OpCode Error Interrupt!\n", __func__); | 666 | printk("%s: Video Received OpCode Error Interrupt!\n", __func__); |
667 | } | 667 | } |
668 | 668 | ||
669 | 669 | ||
670 | if( dev->_file_status == END_OF_FILE ) | 670 | if( dev->_file_status == END_OF_FILE ) |
671 | { | 671 | { |
672 | printk("cx25821: EOF Channel 1 Framecount = %d\n", dev->_frame_count ); | 672 | printk("cx25821: EOF Channel 1 Framecount = %d\n", dev->_frame_count ); |
673 | return -1; | 673 | return -1; |
674 | } | 674 | } |
675 | 675 | ||
676 | //ElSE, set the interrupt mask register, re-enable irq. | 676 | //ElSE, set the interrupt mask register, re-enable irq. |
@@ -690,8 +690,8 @@ static irqreturn_t cx25821_upstream_irq(int irq, void *dev_id) | |||
690 | 690 | ||
691 | 691 | ||
692 | if( !dev ) | 692 | if( !dev ) |
693 | return -1; | 693 | return -1; |
694 | 694 | ||
695 | channel_num = VID_UPSTREAM_SRAM_CHANNEL_I; | 695 | channel_num = VID_UPSTREAM_SRAM_CHANNEL_I; |
696 | 696 | ||
697 | sram_ch = &dev->sram_channels[channel_num]; | 697 | sram_ch = &dev->sram_channels[channel_num]; |
@@ -702,16 +702,16 @@ static irqreturn_t cx25821_upstream_irq(int irq, void *dev_id) | |||
702 | // Only deal with our interrupt | 702 | // Only deal with our interrupt |
703 | if(vid_status) | 703 | if(vid_status) |
704 | { | 704 | { |
705 | handled = cx25821_video_upstream_irq(dev, channel_num, vid_status); | 705 | handled = cx25821_video_upstream_irq(dev, channel_num, vid_status); |
706 | } | 706 | } |
707 | 707 | ||
708 | if( handled < 0 ) | 708 | if( handled < 0 ) |
709 | { | 709 | { |
710 | cx25821_stop_upstream_video_ch1(dev); | 710 | cx25821_stop_upstream_video_ch1(dev); |
711 | } | 711 | } |
712 | else | 712 | else |
713 | { | 713 | { |
714 | handled += handled; | 714 | handled += handled; |
715 | } | 715 | } |
716 | 716 | ||
717 | return IRQ_RETVAL(handled); | 717 | return IRQ_RETVAL(handled); |
@@ -725,7 +725,7 @@ void cx25821_set_pixelengine(struct cx25821_dev *dev, struct sram_channel *ch, i | |||
725 | int num_lines, odd_num_lines; | 725 | int num_lines, odd_num_lines; |
726 | u32 value; | 726 | u32 value; |
727 | int vip_mode = OUTPUT_FRMT_656; | 727 | int vip_mode = OUTPUT_FRMT_656; |
728 | 728 | ||
729 | 729 | ||
730 | value = ( (pix_format & 0x3) << 12 ) | ( vip_mode & 0x7 ); | 730 | value = ( (pix_format & 0x3) << 12 ) | ( vip_mode & 0x7 ); |
731 | value &= 0xFFFFFFEF; | 731 | value &= 0xFFFFFFEF; |
@@ -741,7 +741,7 @@ void cx25821_set_pixelengine(struct cx25821_dev *dev, struct sram_channel *ch, i | |||
741 | 741 | ||
742 | if(dev->_isNTSC) | 742 | if(dev->_isNTSC) |
743 | { | 743 | { |
744 | odd_num_lines += 1; | 744 | odd_num_lines += 1; |
745 | } | 745 | } |
746 | 746 | ||
747 | value = (num_lines << 16) | odd_num_lines; | 747 | value = (num_lines << 16) | odd_num_lines; |
@@ -754,7 +754,7 @@ void cx25821_set_pixelengine(struct cx25821_dev *dev, struct sram_channel *ch, i | |||
754 | 754 | ||
755 | 755 | ||
756 | int cx25821_start_video_dma_upstream(struct cx25821_dev *dev, | 756 | int cx25821_start_video_dma_upstream(struct cx25821_dev *dev, |
757 | struct sram_channel *sram_ch) | 757 | struct sram_channel *sram_ch) |
758 | { | 758 | { |
759 | u32 tmp = 0; | 759 | u32 tmp = 0; |
760 | int err = 0; | 760 | int err = 0; |
@@ -785,8 +785,8 @@ int cx25821_start_video_dma_upstream(struct cx25821_dev *dev, | |||
785 | err = request_irq(dev->pci->irq, cx25821_upstream_irq, IRQF_SHARED | IRQF_DISABLED, dev->name, dev); | 785 | err = request_irq(dev->pci->irq, cx25821_upstream_irq, IRQF_SHARED | IRQF_DISABLED, dev->name, dev); |
786 | if (err < 0) | 786 | if (err < 0) |
787 | { | 787 | { |
788 | printk(KERN_ERR "%s: can't get upstream IRQ %d\n", dev->name, dev->pci->irq); | 788 | printk(KERN_ERR "%s: can't get upstream IRQ %d\n", dev->name, dev->pci->irq); |
789 | goto fail_irq; | 789 | goto fail_irq; |
790 | } | 790 | } |
791 | 791 | ||
792 | 792 | ||
@@ -818,8 +818,8 @@ int cx25821_vidupstream_init_ch1(struct cx25821_dev *dev, int channel_select, in | |||
818 | 818 | ||
819 | if( dev->_is_running ) | 819 | if( dev->_is_running ) |
820 | { | 820 | { |
821 | printk("Video Channel is still running so return!\n"); | 821 | printk("Video Channel is still running so return!\n"); |
822 | return 0; | 822 | return 0; |
823 | } | 823 | } |
824 | 824 | ||
825 | 825 | ||
@@ -832,15 +832,15 @@ int cx25821_vidupstream_init_ch1(struct cx25821_dev *dev, int channel_select, in | |||
832 | 832 | ||
833 | if(!dev->_irq_queues) | 833 | if(!dev->_irq_queues) |
834 | { | 834 | { |
835 | printk("cx25821: create_singlethread_workqueue() for Video FAILED!\n"); | 835 | printk("cx25821: create_singlethread_workqueue() for Video FAILED!\n"); |
836 | return -ENOMEM; | 836 | return -ENOMEM; |
837 | } | 837 | } |
838 | 838 | ||
839 | // 656/VIP SRC Upstream Channel I & J and 7 - Host Bus Interface for channel A-C | 839 | // 656/VIP SRC Upstream Channel I & J and 7 - Host Bus Interface for channel A-C |
840 | tmp = cx_read( VID_CH_MODE_SEL ); | 840 | tmp = cx_read( VID_CH_MODE_SEL ); |
841 | cx_write( VID_CH_MODE_SEL, tmp | 0x1B0001FF); | 841 | cx_write( VID_CH_MODE_SEL, tmp | 0x1B0001FF); |
842 | 842 | ||
843 | 843 | ||
844 | dev->_is_running = 0; | 844 | dev->_is_running = 0; |
845 | dev->_frame_count = 0; | 845 | dev->_frame_count = 0; |
846 | dev->_file_status = RESET_STATUS; | 846 | dev->_file_status = RESET_STATUS; |
@@ -850,40 +850,40 @@ int cx25821_vidupstream_init_ch1(struct cx25821_dev *dev, int channel_select, in | |||
850 | data_frame_size = dev->_isNTSC ? NTSC_DATA_BUF_SZ : PAL_DATA_BUF_SZ; | 850 | data_frame_size = dev->_isNTSC ? NTSC_DATA_BUF_SZ : PAL_DATA_BUF_SZ; |
851 | risc_buffer_size = dev->_isNTSC ? NTSC_RISC_BUF_SIZE : PAL_RISC_BUF_SIZE; | 851 | risc_buffer_size = dev->_isNTSC ? NTSC_RISC_BUF_SIZE : PAL_RISC_BUF_SIZE; |
852 | 852 | ||
853 | 853 | ||
854 | if( dev->input_filename ) | 854 | if( dev->input_filename ) |
855 | { | 855 | { |
856 | str_length = strlen(dev->input_filename); | 856 | str_length = strlen(dev->input_filename); |
857 | dev->_filename = (char *) kmalloc(str_length + 1, GFP_KERNEL); | 857 | dev->_filename = (char *) kmalloc(str_length + 1, GFP_KERNEL); |
858 | 858 | ||
859 | if( !dev->_filename ) | 859 | if( !dev->_filename ) |
860 | goto error; | 860 | goto error; |
861 | 861 | ||
862 | memcpy(dev->_filename, dev->input_filename, str_length + 1); | 862 | memcpy(dev->_filename, dev->input_filename, str_length + 1); |
863 | } | 863 | } |
864 | else | 864 | else |
865 | { | 865 | { |
866 | str_length = strlen(dev->_defaultname); | 866 | str_length = strlen(dev->_defaultname); |
867 | dev->_filename = (char *) kmalloc(str_length + 1, GFP_KERNEL); | 867 | dev->_filename = (char *) kmalloc(str_length + 1, GFP_KERNEL); |
868 | 868 | ||
869 | if( !dev->_filename ) | 869 | if( !dev->_filename ) |
870 | goto error; | 870 | goto error; |
871 | 871 | ||
872 | memcpy(dev->_filename, dev->_defaultname, str_length + 1); | 872 | memcpy(dev->_filename, dev->_defaultname, str_length + 1); |
873 | } | 873 | } |
874 | 874 | ||
875 | 875 | ||
876 | //Default if filename is empty string | 876 | //Default if filename is empty string |
877 | if( strcmp(dev->input_filename,"") == 0) | 877 | if( strcmp(dev->input_filename,"") == 0) |
878 | { | 878 | { |
879 | if( dev->_isNTSC ) | 879 | if( dev->_isNTSC ) |
880 | { | 880 | { |
881 | dev->_filename = (dev->_pixel_format == PIXEL_FRMT_411) ? "/root/vid411.yuv" : "/root/vidtest.yuv"; | 881 | dev->_filename = (dev->_pixel_format == PIXEL_FRMT_411) ? "/root/vid411.yuv" : "/root/vidtest.yuv"; |
882 | } | 882 | } |
883 | else | 883 | else |
884 | { | 884 | { |
885 | dev->_filename = (dev->_pixel_format == PIXEL_FRMT_411) ? "/root/pal411.yuv" : "/root/pal422.yuv"; | 885 | dev->_filename = (dev->_pixel_format == PIXEL_FRMT_411) ? "/root/pal411.yuv" : "/root/pal422.yuv"; |
886 | } | 886 | } |
887 | } | 887 | } |
888 | 888 | ||
889 | dev->_is_running = 0; | 889 | dev->_is_running = 0; |
@@ -906,8 +906,8 @@ int cx25821_vidupstream_init_ch1(struct cx25821_dev *dev, int channel_select, in | |||
906 | retval = cx25821_upstream_buffer_prepare(dev, sram_ch, dev->_line_size); | 906 | retval = cx25821_upstream_buffer_prepare(dev, sram_ch, dev->_line_size); |
907 | if (retval < 0) | 907 | if (retval < 0) |
908 | { | 908 | { |
909 | printk(KERN_ERR "%s: Failed to set up Video upstream buffers!\n", dev->name); | 909 | printk(KERN_ERR "%s: Failed to set up Video upstream buffers!\n", dev->name); |
910 | goto error; | 910 | goto error; |
911 | } | 911 | } |
912 | 912 | ||
913 | 913 | ||
diff --git a/drivers/staging/cx25821/cx25821-video-upstream.h b/drivers/staging/cx25821/cx25821-video-upstream.h index 632ccc65bc7..c134a1956ee 100644 --- a/drivers/staging/cx25821/cx25821-video-upstream.h +++ b/drivers/staging/cx25821/cx25821-video-upstream.h | |||
@@ -70,38 +70,38 @@ | |||
70 | 70 | ||
71 | #ifdef USE_RISC_NOOP_VIDEO | 71 | #ifdef USE_RISC_NOOP_VIDEO |
72 | #define PAL_US_VID_PROG_SIZE ((PAL_FIELD_HEIGHT) * 3 * DWORD_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + \ | 72 | #define PAL_US_VID_PROG_SIZE ((PAL_FIELD_HEIGHT) * 3 * DWORD_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + \ |
73 | RISC_SYNC_INSTRUCTION_SIZE + NUM_NO_OPS*DWORD_SIZE) | 73 | RISC_SYNC_INSTRUCTION_SIZE + NUM_NO_OPS*DWORD_SIZE) |
74 | 74 | ||
75 | #define PAL_RISC_BUF_SIZE (2 * PAL_US_VID_PROG_SIZE) | 75 | #define PAL_RISC_BUF_SIZE (2 * PAL_US_VID_PROG_SIZE) |
76 | 76 | ||
77 | #define PAL_VID_PROG_SIZE ((PAL_FIELD_HEIGHT*2) * 3 * DWORD_SIZE + 2*RISC_SYNC_INSTRUCTION_SIZE + \ | 77 | #define PAL_VID_PROG_SIZE ((PAL_FIELD_HEIGHT*2) * 3 * DWORD_SIZE + 2*RISC_SYNC_INSTRUCTION_SIZE + \ |
78 | RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE + 2*NUM_NO_OPS*DWORD_SIZE) | 78 | RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE + 2*NUM_NO_OPS*DWORD_SIZE) |
79 | 79 | ||
80 | #define ODD_FLD_PAL_PROG_SIZE ((PAL_FIELD_HEIGHT) * 3 * DWORD_SIZE + RISC_SYNC_INSTRUCTION_SIZE + \ | 80 | #define ODD_FLD_PAL_PROG_SIZE ((PAL_FIELD_HEIGHT) * 3 * DWORD_SIZE + RISC_SYNC_INSTRUCTION_SIZE + \ |
81 | RISC_WRITECR_INSTRUCTION_SIZE + NUM_NO_OPS*DWORD_SIZE) | 81 | RISC_WRITECR_INSTRUCTION_SIZE + NUM_NO_OPS*DWORD_SIZE) |
82 | 82 | ||
83 | #define ODD_FLD_NTSC_PROG_SIZE ((NTSC_ODD_FLD_LINES) * 3 * DWORD_SIZE + RISC_SYNC_INSTRUCTION_SIZE + \ | 83 | #define ODD_FLD_NTSC_PROG_SIZE ((NTSC_ODD_FLD_LINES) * 3 * DWORD_SIZE + RISC_SYNC_INSTRUCTION_SIZE + \ |
84 | RISC_WRITECR_INSTRUCTION_SIZE + NUM_NO_OPS*DWORD_SIZE) | 84 | RISC_WRITECR_INSTRUCTION_SIZE + NUM_NO_OPS*DWORD_SIZE) |
85 | 85 | ||
86 | #define NTSC_US_VID_PROG_SIZE ((NTSC_ODD_FLD_LINES + 1) * 3 * DWORD_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + \ | 86 | #define NTSC_US_VID_PROG_SIZE ((NTSC_ODD_FLD_LINES + 1) * 3 * DWORD_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + \ |
87 | JUMP_INSTRUCTION_SIZE + NUM_NO_OPS*DWORD_SIZE) | 87 | JUMP_INSTRUCTION_SIZE + NUM_NO_OPS*DWORD_SIZE) |
88 | 88 | ||
89 | #define NTSC_RISC_BUF_SIZE (2 * (RISC_SYNC_INSTRUCTION_SIZE + NTSC_US_VID_PROG_SIZE)) | 89 | #define NTSC_RISC_BUF_SIZE (2 * (RISC_SYNC_INSTRUCTION_SIZE + NTSC_US_VID_PROG_SIZE)) |
90 | 90 | ||
91 | #define FRAME1_VID_PROG_SIZE ((NTSC_ODD_FLD_LINES + NTSC_FIELD_HEIGHT) * 3 * DWORD_SIZE + 2*RISC_SYNC_INSTRUCTION_SIZE + \ | 91 | #define FRAME1_VID_PROG_SIZE ((NTSC_ODD_FLD_LINES + NTSC_FIELD_HEIGHT) * 3 * DWORD_SIZE + 2*RISC_SYNC_INSTRUCTION_SIZE + \ |
92 | RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE + 2*NUM_NO_OPS*DWORD_SIZE) | 92 | RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE + 2*NUM_NO_OPS*DWORD_SIZE) |
93 | 93 | ||
94 | #endif | 94 | #endif |
95 | 95 | ||
96 | 96 | ||
97 | #ifndef USE_RISC_NOOP_VIDEO | 97 | #ifndef USE_RISC_NOOP_VIDEO |
98 | #define PAL_US_VID_PROG_SIZE ((PAL_FIELD_HEIGHT) * 3 * DWORD_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + \ | 98 | #define PAL_US_VID_PROG_SIZE ((PAL_FIELD_HEIGHT) * 3 * DWORD_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + \ |
99 | RISC_SYNC_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE) | 99 | RISC_SYNC_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE) |
100 | 100 | ||
101 | #define PAL_RISC_BUF_SIZE (2 * PAL_US_VID_PROG_SIZE) | 101 | #define PAL_RISC_BUF_SIZE (2 * PAL_US_VID_PROG_SIZE) |
102 | 102 | ||
103 | #define PAL_VID_PROG_SIZE ((PAL_FIELD_HEIGHT*2) * 3 * DWORD_SIZE + 2*RISC_SYNC_INSTRUCTION_SIZE + \ | 103 | #define PAL_VID_PROG_SIZE ((PAL_FIELD_HEIGHT*2) * 3 * DWORD_SIZE + 2*RISC_SYNC_INSTRUCTION_SIZE + \ |
104 | RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE ) | 104 | RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE ) |
105 | 105 | ||
106 | #define ODD_FLD_PAL_PROG_SIZE ((PAL_FIELD_HEIGHT) * 3 * DWORD_SIZE + RISC_SYNC_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE ) | 106 | #define ODD_FLD_PAL_PROG_SIZE ((PAL_FIELD_HEIGHT) * 3 * DWORD_SIZE + RISC_SYNC_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE ) |
107 | #define ODD_FLD_NTSC_PROG_SIZE ((NTSC_ODD_FLD_LINES) * 3 * DWORD_SIZE + RISC_SYNC_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE ) | 107 | #define ODD_FLD_NTSC_PROG_SIZE ((NTSC_ODD_FLD_LINES) * 3 * DWORD_SIZE + RISC_SYNC_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE ) |
@@ -109,5 +109,5 @@ | |||
109 | #define NTSC_US_VID_PROG_SIZE ((NTSC_ODD_FLD_LINES + 1) * 3 * DWORD_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE) | 109 | #define NTSC_US_VID_PROG_SIZE ((NTSC_ODD_FLD_LINES + 1) * 3 * DWORD_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE) |
110 | #define NTSC_RISC_BUF_SIZE ( 2 * (RISC_SYNC_INSTRUCTION_SIZE + NTSC_US_VID_PROG_SIZE) ) | 110 | #define NTSC_RISC_BUF_SIZE ( 2 * (RISC_SYNC_INSTRUCTION_SIZE + NTSC_US_VID_PROG_SIZE) ) |
111 | #define FRAME1_VID_PROG_SIZE ((NTSC_ODD_FLD_LINES + NTSC_FIELD_HEIGHT) * 3 * DWORD_SIZE + 2*RISC_SYNC_INSTRUCTION_SIZE + \ | 111 | #define FRAME1_VID_PROG_SIZE ((NTSC_ODD_FLD_LINES + NTSC_FIELD_HEIGHT) * 3 * DWORD_SIZE + 2*RISC_SYNC_INSTRUCTION_SIZE + \ |
112 | RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE ) | 112 | RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE ) |
113 | #endif | 113 | #endif |
diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c index 512cbe3bae8..ba8115b6e0a 100644 --- a/drivers/staging/cx25821/cx25821-video.c +++ b/drivers/staging/cx25821/cx25821-video.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the Conexant CX25821 PCIe bridge | 2 | * Driver for the Conexant CX25821 PCIe bridge |
3 | * | 3 | * |
4 | * Copyright (C) 2009 Conexant Systems Inc. | 4 | * Copyright (C) 2009 Conexant Systems Inc. |
5 | * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com> | 5 | * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com> |
6 | * Based on Steven Toth <stoth@linuxtv.org> cx23885 driver | 6 | * Based on Steven Toth <stoth@linuxtv.org> cx23885 driver |
7 | * | 7 | * |
@@ -54,30 +54,30 @@ static void init_controls(struct cx25821_dev *dev, int chan_num); | |||
54 | 54 | ||
55 | struct cx25821_fmt formats[] = { | 55 | struct cx25821_fmt formats[] = { |
56 | { | 56 | { |
57 | .name = "8 bpp, gray", | 57 | .name = "8 bpp, gray", |
58 | .fourcc = V4L2_PIX_FMT_GREY, | 58 | .fourcc = V4L2_PIX_FMT_GREY, |
59 | .depth = 8, | 59 | .depth = 8, |
60 | .flags = FORMAT_FLAGS_PACKED, | 60 | .flags = FORMAT_FLAGS_PACKED, |
61 | }, { | 61 | }, { |
62 | .name = "4:1:1, packed, Y41P", | 62 | .name = "4:1:1, packed, Y41P", |
63 | .fourcc = V4L2_PIX_FMT_Y41P, | 63 | .fourcc = V4L2_PIX_FMT_Y41P, |
64 | .depth = 12, | 64 | .depth = 12, |
65 | .flags = FORMAT_FLAGS_PACKED, | 65 | .flags = FORMAT_FLAGS_PACKED, |
66 | }, { | 66 | }, { |
67 | .name = "4:2:2, packed, YUYV", | 67 | .name = "4:2:2, packed, YUYV", |
68 | .fourcc = V4L2_PIX_FMT_YUYV, | 68 | .fourcc = V4L2_PIX_FMT_YUYV, |
69 | .depth = 16, | 69 | .depth = 16, |
70 | .flags = FORMAT_FLAGS_PACKED, | 70 | .flags = FORMAT_FLAGS_PACKED, |
71 | }, { | 71 | }, { |
72 | .name = "4:2:2, packed, UYVY", | 72 | .name = "4:2:2, packed, UYVY", |
73 | .fourcc = V4L2_PIX_FMT_UYVY, | 73 | .fourcc = V4L2_PIX_FMT_UYVY, |
74 | .depth = 16, | 74 | .depth = 16, |
75 | .flags = FORMAT_FLAGS_PACKED, | 75 | .flags = FORMAT_FLAGS_PACKED, |
76 | },{ | 76 | },{ |
77 | .name = "4:2:0, YUV", | 77 | .name = "4:2:0, YUV", |
78 | .fourcc = V4L2_PIX_FMT_YUV420, | 78 | .fourcc = V4L2_PIX_FMT_YUV420, |
79 | .depth = 12, | 79 | .depth = 12, |
80 | .flags = FORMAT_FLAGS_PACKED, | 80 | .flags = FORMAT_FLAGS_PACKED, |
81 | }, | 81 | }, |
82 | }; | 82 | }; |
83 | 83 | ||
@@ -94,12 +94,12 @@ struct cx25821_fmt *format_by_fourcc(unsigned int fourcc) | |||
94 | 94 | ||
95 | if( fourcc == V4L2_PIX_FMT_Y41P || fourcc == V4L2_PIX_FMT_YUV411P ) | 95 | if( fourcc == V4L2_PIX_FMT_Y41P || fourcc == V4L2_PIX_FMT_YUV411P ) |
96 | { | 96 | { |
97 | return formats+1; | 97 | return formats+1; |
98 | } | 98 | } |
99 | 99 | ||
100 | for (i = 0; i < ARRAY_SIZE(formats); i++) | 100 | for (i = 0; i < ARRAY_SIZE(formats); i++) |
101 | if (formats[i].fourcc == fourcc) | 101 | if (formats[i].fourcc == fourcc) |
102 | return formats+i; | 102 | return formats+i; |
103 | 103 | ||
104 | printk(KERN_ERR "%s(0x%08x) NOT FOUND\n", __func__, fourcc); | 104 | printk(KERN_ERR "%s(0x%08x) NOT FOUND\n", __func__, fourcc); |
105 | return NULL; | 105 | return NULL; |
@@ -112,14 +112,14 @@ void dump_video_queue(struct cx25821_dev *dev, struct cx25821_dmaqueue *q) | |||
112 | dprintk(1, "%s()\n", __func__); | 112 | dprintk(1, "%s()\n", __func__); |
113 | 113 | ||
114 | if (!list_empty(&q->active)) { | 114 | if (!list_empty(&q->active)) { |
115 | list_for_each(item, &q->active) | 115 | list_for_each(item, &q->active) |
116 | buf = list_entry(item, struct cx25821_buffer, vb.queue); | 116 | buf = list_entry(item, struct cx25821_buffer, vb.queue); |
117 | } | 117 | } |
118 | 118 | ||
119 | if (!list_empty(&q->queued)) | 119 | if (!list_empty(&q->queued)) |
120 | { | 120 | { |
121 | list_for_each(item, &q->queued) | 121 | list_for_each(item, &q->queued) |
122 | buf = list_entry(item, struct cx25821_buffer, vb.queue); | 122 | buf = list_entry(item, struct cx25821_buffer, vb.queue); |
123 | } | 123 | } |
124 | 124 | ||
125 | } | 125 | } |
@@ -131,63 +131,63 @@ void cx25821_video_wakeup(struct cx25821_dev *dev, struct cx25821_dmaqueue *q, u | |||
131 | int bc; | 131 | int bc; |
132 | 132 | ||
133 | for (bc = 0;; bc++) { | 133 | for (bc = 0;; bc++) { |
134 | if (list_empty(&q->active)) | 134 | if (list_empty(&q->active)) |
135 | { | 135 | { |
136 | dprintk(1, "bc=%d (=0: active empty)\n", bc); | 136 | dprintk(1, "bc=%d (=0: active empty)\n", bc); |
137 | break; | 137 | break; |
138 | } | 138 | } |
139 | 139 | ||
140 | buf = list_entry(q->active.next, struct cx25821_buffer, vb.queue); | 140 | buf = list_entry(q->active.next, struct cx25821_buffer, vb.queue); |
141 | 141 | ||
142 | /* count comes from the hw and it is 16bit wide -- | 142 | /* count comes from the hw and it is 16bit wide -- |
143 | * this trick handles wrap-arounds correctly for | 143 | * this trick handles wrap-arounds correctly for |
144 | * up to 32767 buffers in flight... */ | 144 | * up to 32767 buffers in flight... */ |
145 | if ((s16) (count - buf->count) < 0) | 145 | if ((s16) (count - buf->count) < 0) |
146 | { | 146 | { |
147 | break; | 147 | break; |
148 | } | 148 | } |
149 | 149 | ||
150 | do_gettimeofday(&buf->vb.ts); | 150 | do_gettimeofday(&buf->vb.ts); |
151 | buf->vb.state = VIDEOBUF_DONE; | 151 | buf->vb.state = VIDEOBUF_DONE; |
152 | list_del(&buf->vb.queue); | 152 | list_del(&buf->vb.queue); |
153 | wake_up(&buf->vb.done); | 153 | wake_up(&buf->vb.done); |
154 | } | 154 | } |
155 | 155 | ||
156 | if (list_empty(&q->active)) | 156 | if (list_empty(&q->active)) |
157 | del_timer(&q->timeout); | 157 | del_timer(&q->timeout); |
158 | else | 158 | else |
159 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); | 159 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); |
160 | if (bc != 1) | 160 | if (bc != 1) |
161 | printk(KERN_ERR "%s: %d buffers handled (should be 1)\n", __func__, bc); | 161 | printk(KERN_ERR "%s: %d buffers handled (should be 1)\n", __func__, bc); |
162 | } | 162 | } |
163 | 163 | ||
164 | #ifdef TUNER_FLAG | 164 | #ifdef TUNER_FLAG |
165 | int cx25821_set_tvnorm(struct cx25821_dev *dev, v4l2_std_id norm) | 165 | int cx25821_set_tvnorm(struct cx25821_dev *dev, v4l2_std_id norm) |
166 | { | 166 | { |
167 | dprintk(1, "%s(norm = 0x%08x) name: [%s]\n", __func__, | 167 | dprintk(1, "%s(norm = 0x%08x) name: [%s]\n", __func__, |
168 | (unsigned int)norm, | 168 | (unsigned int)norm, |
169 | v4l2_norm_to_name(norm)); | 169 | v4l2_norm_to_name(norm)); |
170 | 170 | ||
171 | dev->tvnorm = norm; | 171 | dev->tvnorm = norm; |
172 | 172 | ||
173 | /* Tell the internal A/V decoder */ | 173 | /* Tell the internal A/V decoder */ |
174 | cx25821_call_all(dev, core, s_std, norm); | 174 | cx25821_call_all(dev, core, s_std, norm); |
175 | 175 | ||
176 | return 0; | 176 | return 0; |
177 | } | 177 | } |
178 | #endif | 178 | #endif |
179 | 179 | ||
180 | struct video_device *cx25821_vdev_init(struct cx25821_dev *dev, | 180 | struct video_device *cx25821_vdev_init(struct cx25821_dev *dev, |
181 | struct pci_dev *pci, | 181 | struct pci_dev *pci, |
182 | struct video_device *template, | 182 | struct video_device *template, |
183 | char *type) | 183 | char *type) |
184 | { | 184 | { |
185 | struct video_device *vfd; | 185 | struct video_device *vfd; |
186 | dprintk(1, "%s()\n", __func__); | 186 | dprintk(1, "%s()\n", __func__); |
187 | 187 | ||
188 | vfd = video_device_alloc(); | 188 | vfd = video_device_alloc(); |
189 | if (NULL == vfd) | 189 | if (NULL == vfd) |
190 | return NULL; | 190 | return NULL; |
191 | *vfd = *template; | 191 | *vfd = *template; |
192 | vfd->minor = -1; | 192 | vfd->minor = -1; |
193 | vfd->v4l2_dev = &dev->v4l2_dev; | 193 | vfd->v4l2_dev = &dev->v4l2_dev; |
@@ -202,13 +202,13 @@ static int cx25821_ctrl_query(struct v4l2_queryctrl *qctrl) | |||
202 | int i; | 202 | int i; |
203 | 203 | ||
204 | if (qctrl->id < V4L2_CID_BASE || qctrl->id >= V4L2_CID_LASTP1) | 204 | if (qctrl->id < V4L2_CID_BASE || qctrl->id >= V4L2_CID_LASTP1) |
205 | return -EINVAL; | 205 | return -EINVAL; |
206 | for (i = 0; i < CX25821_CTLS; i++) | 206 | for (i = 0; i < CX25821_CTLS; i++) |
207 | if (cx25821_ctls[i].v.id == qctrl->id) | 207 | if (cx25821_ctls[i].v.id == qctrl->id) |
208 | break; | 208 | break; |
209 | if (i == CX25821_CTLS) { | 209 | if (i == CX25821_CTLS) { |
210 | *qctrl = no_ctl; | 210 | *qctrl = no_ctl; |
211 | return 0; | 211 | return 0; |
212 | } | 212 | } |
213 | *qctrl = cx25821_ctls[i].v; | 213 | *qctrl = cx25821_ctls[i].v; |
214 | return 0; | 214 | return 0; |
@@ -220,15 +220,15 @@ int res_get(struct cx25821_dev *dev, struct cx25821_fh *fh, unsigned int bit) | |||
220 | { | 220 | { |
221 | dprintk(1, "%s()\n", __func__); | 221 | dprintk(1, "%s()\n", __func__); |
222 | if (fh->resources & bit) | 222 | if (fh->resources & bit) |
223 | /* have it already allocated */ | 223 | /* have it already allocated */ |
224 | return 1; | 224 | return 1; |
225 | 225 | ||
226 | /* is it free? */ | 226 | /* is it free? */ |
227 | mutex_lock(&dev->lock); | 227 | mutex_lock(&dev->lock); |
228 | if (dev->resources & bit) { | 228 | if (dev->resources & bit) { |
229 | /* no, someone else uses it */ | 229 | /* no, someone else uses it */ |
230 | mutex_unlock(&dev->lock); | 230 | mutex_unlock(&dev->lock); |
231 | return 0; | 231 | return 0; |
232 | } | 232 | } |
233 | /* it's free, grab it */ | 233 | /* it's free, grab it */ |
234 | fh->resources |= bit; | 234 | fh->resources |= bit; |
@@ -266,23 +266,23 @@ int cx25821_video_mux(struct cx25821_dev *dev, unsigned int input) | |||
266 | memset(&route, 0, sizeof(route)); | 266 | memset(&route, 0, sizeof(route)); |
267 | 267 | ||
268 | dprintk(1, "%s() video_mux: %d [vmux=%d, gpio=0x%x,0x%x,0x%x,0x%x]\n", __func__, | 268 | dprintk(1, "%s() video_mux: %d [vmux=%d, gpio=0x%x,0x%x,0x%x,0x%x]\n", __func__, |
269 | input, INPUT(input)->vmux, | 269 | input, INPUT(input)->vmux, |
270 | INPUT(input)->gpio0, INPUT(input)->gpio1, | 270 | INPUT(input)->gpio0, INPUT(input)->gpio1, |
271 | INPUT(input)->gpio2, INPUT(input)->gpio3); | 271 | INPUT(input)->gpio2, INPUT(input)->gpio3); |
272 | dev->input = input; | 272 | dev->input = input; |
273 | 273 | ||
274 | route.input = INPUT(input)->vmux; | 274 | route.input = INPUT(input)->vmux; |
275 | 275 | ||
276 | /* Tell the internal A/V decoder */ | 276 | /* Tell the internal A/V decoder */ |
277 | cx25821_call_all(dev, video, s_routing, INPUT(input)->vmux, 0, 0); | 277 | cx25821_call_all(dev, video, s_routing, INPUT(input)->vmux, 0, 0); |
278 | 278 | ||
279 | return 0; | 279 | return 0; |
280 | } | 280 | } |
281 | 281 | ||
282 | int cx25821_start_video_dma(struct cx25821_dev *dev, | 282 | int cx25821_start_video_dma(struct cx25821_dev *dev, |
283 | struct cx25821_dmaqueue *q, | 283 | struct cx25821_dmaqueue *q, |
284 | struct cx25821_buffer *buf, | 284 | struct cx25821_buffer *buf, |
285 | struct sram_channel *channel) | 285 | struct sram_channel *channel) |
286 | { | 286 | { |
287 | int tmp = 0; | 287 | int tmp = 0; |
288 | 288 | ||
@@ -302,7 +302,7 @@ int cx25821_start_video_dma(struct cx25821_dev *dev, | |||
302 | 302 | ||
303 | /* make sure upstream setting if any is reversed */ | 303 | /* make sure upstream setting if any is reversed */ |
304 | tmp = cx_read( VID_CH_MODE_SEL ); | 304 | tmp = cx_read( VID_CH_MODE_SEL ); |
305 | cx_write( VID_CH_MODE_SEL, tmp & 0xFFFFFE00); | 305 | cx_write( VID_CH_MODE_SEL, tmp & 0xFFFFFE00); |
306 | 306 | ||
307 | return 0; | 307 | return 0; |
308 | } | 308 | } |
@@ -314,44 +314,44 @@ int cx25821_restart_video_queue(struct cx25821_dev *dev, struct cx25821_dmaqueue | |||
314 | struct list_head *item; | 314 | struct list_head *item; |
315 | 315 | ||
316 | if (!list_empty(&q->active)) { | 316 | if (!list_empty(&q->active)) { |
317 | buf = list_entry(q->active.next, struct cx25821_buffer, vb.queue); | 317 | buf = list_entry(q->active.next, struct cx25821_buffer, vb.queue); |
318 | 318 | ||
319 | cx25821_start_video_dma(dev, q, buf, channel); | 319 | cx25821_start_video_dma(dev, q, buf, channel); |
320 | 320 | ||
321 | list_for_each(item, &q->active) { | 321 | list_for_each(item, &q->active) { |
322 | buf = list_entry(item, struct cx25821_buffer, vb.queue); | 322 | buf = list_entry(item, struct cx25821_buffer, vb.queue); |
323 | buf->count = q->count++; | 323 | buf->count = q->count++; |
324 | } | 324 | } |
325 | 325 | ||
326 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); | 326 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); |
327 | return 0; | 327 | return 0; |
328 | } | 328 | } |
329 | 329 | ||
330 | prev = NULL; | 330 | prev = NULL; |
331 | for (;;) { | 331 | for (;;) { |
332 | if (list_empty(&q->queued)) | 332 | if (list_empty(&q->queued)) |
333 | return 0; | 333 | return 0; |
334 | 334 | ||
335 | buf = list_entry(q->queued.next, struct cx25821_buffer, vb.queue); | 335 | buf = list_entry(q->queued.next, struct cx25821_buffer, vb.queue); |
336 | 336 | ||
337 | if (NULL == prev) { | 337 | if (NULL == prev) { |
338 | list_move_tail(&buf->vb.queue, &q->active); | 338 | list_move_tail(&buf->vb.queue, &q->active); |
339 | cx25821_start_video_dma(dev, q, buf, channel); | 339 | cx25821_start_video_dma(dev, q, buf, channel); |
340 | buf->vb.state = VIDEOBUF_ACTIVE; | 340 | buf->vb.state = VIDEOBUF_ACTIVE; |
341 | buf->count = q->count++; | 341 | buf->count = q->count++; |
342 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); | 342 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); |
343 | } else if (prev->vb.width == buf->vb.width && | 343 | } else if (prev->vb.width == buf->vb.width && |
344 | prev->vb.height == buf->vb.height && | 344 | prev->vb.height == buf->vb.height && |
345 | prev->fmt == buf->fmt) { | 345 | prev->fmt == buf->fmt) { |
346 | list_move_tail(&buf->vb.queue, &q->active); | 346 | list_move_tail(&buf->vb.queue, &q->active); |
347 | buf->vb.state = VIDEOBUF_ACTIVE; | 347 | buf->vb.state = VIDEOBUF_ACTIVE; |
348 | buf->count = q->count++; | 348 | buf->count = q->count++; |
349 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); | 349 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); |
350 | prev->risc.jmp[2] = cpu_to_le32(0); /* Bits 63 - 32 */ | 350 | prev->risc.jmp[2] = cpu_to_le32(0); /* Bits 63 - 32 */ |
351 | } else { | 351 | } else { |
352 | return 0; | 352 | return 0; |
353 | } | 353 | } |
354 | prev = buf; | 354 | prev = buf; |
355 | } | 355 | } |
356 | } | 356 | } |
357 | 357 | ||
@@ -369,11 +369,11 @@ void cx25821_vid_timeout(unsigned long data) | |||
369 | 369 | ||
370 | spin_lock_irqsave(&dev->slock, flags); | 370 | spin_lock_irqsave(&dev->slock, flags); |
371 | while (!list_empty(&q->active)) { | 371 | while (!list_empty(&q->active)) { |
372 | buf = list_entry(q->active.next, struct cx25821_buffer, vb.queue); | 372 | buf = list_entry(q->active.next, struct cx25821_buffer, vb.queue); |
373 | list_del(&buf->vb.queue); | 373 | list_del(&buf->vb.queue); |
374 | 374 | ||
375 | buf->vb.state = VIDEOBUF_ERROR; | 375 | buf->vb.state = VIDEOBUF_ERROR; |
376 | wake_up(&buf->vb.done); | 376 | wake_up(&buf->vb.done); |
377 | } | 377 | } |
378 | 378 | ||
379 | cx25821_restart_video_queue(dev, q, channel); | 379 | cx25821_restart_video_queue(dev, q, channel); |
@@ -389,33 +389,33 @@ int cx25821_video_irq(struct cx25821_dev *dev, int chan_num, u32 status) | |||
389 | 389 | ||
390 | mask = cx_read(channel->int_msk); | 390 | mask = cx_read(channel->int_msk); |
391 | if (0 == (status & mask)) | 391 | if (0 == (status & mask)) |
392 | return handled; | 392 | return handled; |
393 | 393 | ||
394 | cx_write(channel->int_stat, status); | 394 | cx_write(channel->int_stat, status); |
395 | 395 | ||
396 | /* risc op code error */ | 396 | /* risc op code error */ |
397 | if (status & (1 << 16)) { | 397 | if (status & (1 << 16)) { |
398 | printk(KERN_WARNING "%s, %s: video risc op code error\n", dev->name, channel->name); | 398 | printk(KERN_WARNING "%s, %s: video risc op code error\n", dev->name, channel->name); |
399 | cx_clear(channel->dma_ctl, 0x11); | 399 | cx_clear(channel->dma_ctl, 0x11); |
400 | cx25821_sram_channel_dump(dev, channel); | 400 | cx25821_sram_channel_dump(dev, channel); |
401 | } | 401 | } |
402 | 402 | ||
403 | /* risc1 y */ | 403 | /* risc1 y */ |
404 | if (status & FLD_VID_DST_RISC1) { | 404 | if (status & FLD_VID_DST_RISC1) { |
405 | spin_lock(&dev->slock); | 405 | spin_lock(&dev->slock); |
406 | count = cx_read(channel->gpcnt); | 406 | count = cx_read(channel->gpcnt); |
407 | cx25821_video_wakeup(dev, &dev->vidq[channel->i], count); | 407 | cx25821_video_wakeup(dev, &dev->vidq[channel->i], count); |
408 | spin_unlock(&dev->slock); | 408 | spin_unlock(&dev->slock); |
409 | handled++; | 409 | handled++; |
410 | } | 410 | } |
411 | 411 | ||
412 | /* risc2 y */ | 412 | /* risc2 y */ |
413 | if (status & 0x10) { | 413 | if (status & 0x10) { |
414 | dprintk(2, "stopper video\n"); | 414 | dprintk(2, "stopper video\n"); |
415 | spin_lock(&dev->slock); | 415 | spin_lock(&dev->slock); |
416 | cx25821_restart_video_queue(dev, &dev->vidq[channel->i], channel); | 416 | cx25821_restart_video_queue(dev, &dev->vidq[channel->i], channel); |
417 | spin_unlock(&dev->slock); | 417 | spin_unlock(&dev->slock); |
418 | handled++; | 418 | handled++; |
419 | } | 419 | } |
420 | return handled; | 420 | return handled; |
421 | } | 421 | } |
@@ -424,30 +424,30 @@ void cx25821_videoioctl_unregister(struct cx25821_dev *dev) | |||
424 | { | 424 | { |
425 | if( dev->ioctl_dev ) | 425 | if( dev->ioctl_dev ) |
426 | { | 426 | { |
427 | if (dev->ioctl_dev->minor != -1) | 427 | if (dev->ioctl_dev->minor != -1) |
428 | video_unregister_device(dev->ioctl_dev); | 428 | video_unregister_device(dev->ioctl_dev); |
429 | else | 429 | else |
430 | video_device_release(dev->ioctl_dev); | 430 | video_device_release(dev->ioctl_dev); |
431 | 431 | ||
432 | dev->ioctl_dev = NULL; | 432 | dev->ioctl_dev = NULL; |
433 | } | 433 | } |
434 | } | 434 | } |
435 | 435 | ||
436 | void cx25821_video_unregister(struct cx25821_dev *dev, int chan_num) | 436 | void cx25821_video_unregister(struct cx25821_dev *dev, int chan_num) |
437 | { | 437 | { |
438 | cx_clear(PCI_INT_MSK, 1); | 438 | cx_clear(PCI_INT_MSK, 1); |
439 | 439 | ||
440 | if (dev->video_dev[chan_num]) { | 440 | if (dev->video_dev[chan_num]) { |
441 | if (-1 != dev->video_dev[chan_num]->minor) | 441 | if (-1 != dev->video_dev[chan_num]->minor) |
442 | video_unregister_device(dev->video_dev[chan_num]); | 442 | video_unregister_device(dev->video_dev[chan_num]); |
443 | else | 443 | else |
444 | video_device_release(dev->video_dev[chan_num]); | 444 | video_device_release(dev->video_dev[chan_num]); |
445 | 445 | ||
446 | dev->video_dev[chan_num] = NULL; | 446 | dev->video_dev[chan_num] = NULL; |
447 | 447 | ||
448 | btcx_riscmem_free(dev->pci, &dev->vidq[chan_num].stopper); | 448 | btcx_riscmem_free(dev->pci, &dev->vidq[chan_num].stopper); |
449 | 449 | ||
450 | printk(KERN_WARNING "device %d released!\n", chan_num); | 450 | printk(KERN_WARNING "device %d released!\n", chan_num); |
451 | } | 451 | } |
452 | 452 | ||
453 | } | 453 | } |
@@ -475,13 +475,13 @@ int cx25821_video_register(struct cx25821_dev *dev, int chan_num, struct video_d | |||
475 | init_timer(&dev->vidq[chan_num].timeout); | 475 | init_timer(&dev->vidq[chan_num].timeout); |
476 | cx25821_risc_stopper(dev->pci, &dev->vidq[chan_num].stopper, dev->sram_channels[chan_num].dma_ctl, 0x11, 0); | 476 | cx25821_risc_stopper(dev->pci, &dev->vidq[chan_num].stopper, dev->sram_channels[chan_num].dma_ctl, 0x11, 0); |
477 | 477 | ||
478 | 478 | ||
479 | /* register v4l devices */ | 479 | /* register v4l devices */ |
480 | dev->video_dev[chan_num] = cx25821_vdev_init(dev, dev->pci, video_template, "video"); | 480 | dev->video_dev[chan_num] = cx25821_vdev_init(dev, dev->pci, video_template, "video"); |
481 | err = video_register_device(dev->video_dev[chan_num], VFL_TYPE_GRABBER, video_nr[dev->nr]); | 481 | err = video_register_device(dev->video_dev[chan_num], VFL_TYPE_GRABBER, video_nr[dev->nr]); |
482 | 482 | ||
483 | if (err < 0) { | 483 | if (err < 0) { |
484 | goto fail_unreg; | 484 | goto fail_unreg; |
485 | } | 485 | } |
486 | 486 | ||
487 | //set PCI interrupt | 487 | //set PCI interrupt |
@@ -512,10 +512,10 @@ int buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *si | |||
512 | 512 | ||
513 | 513 | ||
514 | if (0 == *count) | 514 | if (0 == *count) |
515 | *count = 32; | 515 | *count = 32; |
516 | 516 | ||
517 | while (*size * *count > vid_limit * 1024 * 1024) | 517 | while (*size * *count > vid_limit * 1024 * 1024) |
518 | (*count)--; | 518 | (*count)--; |
519 | 519 | ||
520 | return 0; | 520 | return 0; |
521 | } | 521 | } |
@@ -534,114 +534,114 @@ int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb, enum v4 | |||
534 | 534 | ||
535 | BUG_ON(NULL == fh->fmt); | 535 | BUG_ON(NULL == fh->fmt); |
536 | if (fh->width < 48 || fh->width > 720 || | 536 | if (fh->width < 48 || fh->width > 720 || |
537 | fh->height < 32 || fh->height > 576) | 537 | fh->height < 32 || fh->height > 576) |
538 | return -EINVAL; | 538 | return -EINVAL; |
539 | 539 | ||
540 | buf->vb.size = (fh->width * fh->height * fh->fmt->depth) >> 3; | 540 | buf->vb.size = (fh->width * fh->height * fh->fmt->depth) >> 3; |
541 | 541 | ||
542 | if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size) | 542 | if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size) |
543 | return -EINVAL; | 543 | return -EINVAL; |
544 | 544 | ||
545 | 545 | ||
546 | if (buf->fmt != fh->fmt || | 546 | if (buf->fmt != fh->fmt || |
547 | buf->vb.width != fh->width || | 547 | buf->vb.width != fh->width || |
548 | buf->vb.height != fh->height || | 548 | buf->vb.height != fh->height || |
549 | buf->vb.field != field) { | 549 | buf->vb.field != field) { |
550 | buf->fmt = fh->fmt; | 550 | buf->fmt = fh->fmt; |
551 | buf->vb.width = fh->width; | 551 | buf->vb.width = fh->width; |
552 | buf->vb.height = fh->height; | 552 | buf->vb.height = fh->height; |
553 | buf->vb.field = field; | 553 | buf->vb.field = field; |
554 | init_buffer = 1; | 554 | init_buffer = 1; |
555 | } | 555 | } |
556 | 556 | ||
557 | if (VIDEOBUF_NEEDS_INIT == buf->vb.state) { | 557 | if (VIDEOBUF_NEEDS_INIT == buf->vb.state) { |
558 | init_buffer = 1; | 558 | init_buffer = 1; |
559 | rc = videobuf_iolock(q, &buf->vb, NULL); | 559 | rc = videobuf_iolock(q, &buf->vb, NULL); |
560 | if (0 != rc) | 560 | if (0 != rc) |
561 | { | 561 | { |
562 | printk(KERN_DEBUG "videobuf_iolock failed!\n"); | 562 | printk(KERN_DEBUG "videobuf_iolock failed!\n"); |
563 | goto fail; | 563 | goto fail; |
564 | } | 564 | } |
565 | } | 565 | } |
566 | 566 | ||
567 | dprintk(1, "init_buffer=%d\n", init_buffer); | 567 | dprintk(1, "init_buffer=%d\n", init_buffer); |
568 | 568 | ||
569 | if (init_buffer) { | 569 | if (init_buffer) { |
570 | 570 | ||
571 | channel_opened = dev->channel_opened; | 571 | channel_opened = dev->channel_opened; |
572 | channel_opened = (channel_opened < 0 || channel_opened > 7) ? 7 : channel_opened; | 572 | channel_opened = (channel_opened < 0 || channel_opened > 7) ? 7 : channel_opened; |
573 | 573 | ||
574 | if( dev->pixel_formats[channel_opened] == PIXEL_FRMT_411 ) | 574 | if( dev->pixel_formats[channel_opened] == PIXEL_FRMT_411 ) |
575 | buf->bpl = (buf->fmt->depth * buf->vb.width) >> 3; | 575 | buf->bpl = (buf->fmt->depth * buf->vb.width) >> 3; |
576 | else | 576 | else |
577 | buf->bpl = (buf->fmt->depth >> 3) * (buf->vb.width); | 577 | buf->bpl = (buf->fmt->depth >> 3) * (buf->vb.width); |
578 | 578 | ||
579 | 579 | ||
580 | if( dev->pixel_formats[channel_opened] == PIXEL_FRMT_411 ) | 580 | if( dev->pixel_formats[channel_opened] == PIXEL_FRMT_411 ) |
581 | { | 581 | { |
582 | bpl_local = buf->bpl; | 582 | bpl_local = buf->bpl; |
583 | } | 583 | } |
584 | else | 584 | else |
585 | { | 585 | { |
586 | bpl_local = buf->bpl; //Default | 586 | bpl_local = buf->bpl; //Default |
587 | 587 | ||
588 | if( channel_opened >= 0 && channel_opened <= 7 ) | 588 | if( channel_opened >= 0 && channel_opened <= 7 ) |
589 | { | 589 | { |
590 | if( dev->use_cif_resolution[channel_opened] ) | 590 | if( dev->use_cif_resolution[channel_opened] ) |
591 | { | 591 | { |
592 | if( dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK ) | 592 | if( dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK ) |
593 | bpl_local = 352 << 1; | 593 | bpl_local = 352 << 1; |
594 | else | 594 | else |
595 | bpl_local = dev->cif_width[channel_opened] << 1; | 595 | bpl_local = dev->cif_width[channel_opened] << 1; |
596 | } | 596 | } |
597 | } | 597 | } |
598 | } | 598 | } |
599 | 599 | ||
600 | 600 | ||
601 | switch (buf->vb.field) { | 601 | switch (buf->vb.field) { |
602 | case V4L2_FIELD_TOP: | 602 | case V4L2_FIELD_TOP: |
603 | cx25821_risc_buffer(dev->pci, &buf->risc, | 603 | cx25821_risc_buffer(dev->pci, &buf->risc, |
604 | dma->sglist, 0, UNSET, | 604 | dma->sglist, 0, UNSET, |
605 | buf->bpl, 0, buf->vb.height); | 605 | buf->bpl, 0, buf->vb.height); |
606 | break; | 606 | break; |
607 | case V4L2_FIELD_BOTTOM: | 607 | case V4L2_FIELD_BOTTOM: |
608 | cx25821_risc_buffer(dev->pci, &buf->risc, | 608 | cx25821_risc_buffer(dev->pci, &buf->risc, |
609 | dma->sglist, UNSET, 0, | 609 | dma->sglist, UNSET, 0, |
610 | buf->bpl, 0, buf->vb.height); | 610 | buf->bpl, 0, buf->vb.height); |
611 | break; | 611 | break; |
612 | case V4L2_FIELD_INTERLACED: | 612 | case V4L2_FIELD_INTERLACED: |
613 | /* All other formats are top field first */ | 613 | /* All other formats are top field first */ |
614 | line0_offset = 0; | 614 | line0_offset = 0; |
615 | line1_offset = buf->bpl; | 615 | line1_offset = buf->bpl; |
616 | dprintk(1, "top field first\n"); | 616 | dprintk(1, "top field first\n"); |
617 | 617 | ||
618 | cx25821_risc_buffer(dev->pci, &buf->risc, | 618 | cx25821_risc_buffer(dev->pci, &buf->risc, |
619 | dma->sglist, line0_offset, | 619 | dma->sglist, line0_offset, |
620 | bpl_local, bpl_local, bpl_local, | 620 | bpl_local, bpl_local, bpl_local, |
621 | buf->vb.height >> 1); | 621 | buf->vb.height >> 1); |
622 | break; | 622 | break; |
623 | case V4L2_FIELD_SEQ_TB: | 623 | case V4L2_FIELD_SEQ_TB: |
624 | cx25821_risc_buffer(dev->pci, &buf->risc, | 624 | cx25821_risc_buffer(dev->pci, &buf->risc, |
625 | dma->sglist, | 625 | dma->sglist, |
626 | 0, buf->bpl * (buf->vb.height >> 1), | 626 | 0, buf->bpl * (buf->vb.height >> 1), |
627 | buf->bpl, 0, | 627 | buf->bpl, 0, |
628 | buf->vb.height >> 1); | 628 | buf->vb.height >> 1); |
629 | break; | 629 | break; |
630 | case V4L2_FIELD_SEQ_BT: | 630 | case V4L2_FIELD_SEQ_BT: |
631 | cx25821_risc_buffer(dev->pci, &buf->risc, | 631 | cx25821_risc_buffer(dev->pci, &buf->risc, |
632 | dma->sglist, | 632 | dma->sglist, |
633 | buf->bpl * (buf->vb.height >> 1), 0, | 633 | buf->bpl * (buf->vb.height >> 1), 0, |
634 | buf->bpl, 0, | 634 | buf->bpl, 0, |
635 | buf->vb.height >> 1); | 635 | buf->vb.height >> 1); |
636 | break; | 636 | break; |
637 | default: | 637 | default: |
638 | BUG(); | 638 | BUG(); |
639 | } | 639 | } |
640 | } | 640 | } |
641 | 641 | ||
642 | dprintk(2, "[%p/%d] buffer_prep - %dx%d %dbpp \"%s\" - dma=0x%08lx\n", | 642 | dprintk(2, "[%p/%d] buffer_prep - %dx%d %dbpp \"%s\" - dma=0x%08lx\n", |
643 | buf, buf->vb.i, fh->width, fh->height, fh->fmt->depth, fh->fmt->name, | 643 | buf, buf->vb.i, fh->width, fh->height, fh->fmt->depth, fh->fmt->name, |
644 | (unsigned long)buf->risc.dma); | 644 | (unsigned long)buf->risc.dma); |
645 | 645 | ||
646 | buf->vb.state = VIDEOBUF_PREPARED; | 646 | buf->vb.state = VIDEOBUF_PREPARED; |
647 | 647 | ||
@@ -665,10 +665,10 @@ struct videobuf_queue *get_queue(struct cx25821_fh *fh) | |||
665 | { | 665 | { |
666 | switch (fh->type) { | 666 | switch (fh->type) { |
667 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 667 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
668 | return &fh->vidq; | 668 | return &fh->vidq; |
669 | default: | 669 | default: |
670 | BUG(); | 670 | BUG(); |
671 | return NULL; | 671 | return NULL; |
672 | } | 672 | } |
673 | } | 673 | } |
674 | 674 | ||
@@ -676,10 +676,10 @@ int get_resource(struct cx25821_fh *fh, int resource) | |||
676 | { | 676 | { |
677 | switch (fh->type) { | 677 | switch (fh->type) { |
678 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 678 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
679 | return resource; | 679 | return resource; |
680 | default: | 680 | default: |
681 | BUG(); | 681 | BUG(); |
682 | return 0; | 682 | return 0; |
683 | } | 683 | } |
684 | } | 684 | } |
685 | 685 | ||
@@ -714,38 +714,38 @@ int vidioc_try_fmt_vid_cap(struct file *file, void *priv, struct v4l2_format *f) | |||
714 | 714 | ||
715 | fmt = format_by_fourcc(f->fmt.pix.pixelformat); | 715 | fmt = format_by_fourcc(f->fmt.pix.pixelformat); |
716 | if (NULL == fmt) | 716 | if (NULL == fmt) |
717 | return -EINVAL; | 717 | return -EINVAL; |
718 | 718 | ||
719 | field = f->fmt.pix.field; | 719 | field = f->fmt.pix.field; |
720 | maxw = 720; | 720 | maxw = 720; |
721 | maxh = 576; | 721 | maxh = 576; |
722 | 722 | ||
723 | if (V4L2_FIELD_ANY == field) { | 723 | if (V4L2_FIELD_ANY == field) { |
724 | field = (f->fmt.pix.height > maxh/2) | 724 | field = (f->fmt.pix.height > maxh/2) |
725 | ? V4L2_FIELD_INTERLACED | 725 | ? V4L2_FIELD_INTERLACED |
726 | : V4L2_FIELD_TOP; | 726 | : V4L2_FIELD_TOP; |
727 | } | 727 | } |
728 | 728 | ||
729 | switch (field) { | 729 | switch (field) { |
730 | case V4L2_FIELD_TOP: | 730 | case V4L2_FIELD_TOP: |
731 | case V4L2_FIELD_BOTTOM: | 731 | case V4L2_FIELD_BOTTOM: |
732 | maxh = maxh / 2; | 732 | maxh = maxh / 2; |
733 | break; | 733 | break; |
734 | case V4L2_FIELD_INTERLACED: | 734 | case V4L2_FIELD_INTERLACED: |
735 | break; | 735 | break; |
736 | default: | 736 | default: |
737 | return -EINVAL; | 737 | return -EINVAL; |
738 | } | 738 | } |
739 | 739 | ||
740 | f->fmt.pix.field = field; | 740 | f->fmt.pix.field = field; |
741 | if (f->fmt.pix.height < 32) | 741 | if (f->fmt.pix.height < 32) |
742 | f->fmt.pix.height = 32; | 742 | f->fmt.pix.height = 32; |
743 | if (f->fmt.pix.height > maxh) | 743 | if (f->fmt.pix.height > maxh) |
744 | f->fmt.pix.height = maxh; | 744 | f->fmt.pix.height = maxh; |
745 | if (f->fmt.pix.width < 48) | 745 | if (f->fmt.pix.width < 48) |
746 | f->fmt.pix.width = 48; | 746 | f->fmt.pix.width = 48; |
747 | if (f->fmt.pix.width > maxw) | 747 | if (f->fmt.pix.width > maxw) |
748 | f->fmt.pix.width = maxw; | 748 | f->fmt.pix.width = maxw; |
749 | f->fmt.pix.width &= ~0x03; | 749 | f->fmt.pix.width &= ~0x03; |
750 | f->fmt.pix.bytesperline = (f->fmt.pix.width * fmt->depth) >> 3; | 750 | f->fmt.pix.bytesperline = (f->fmt.pix.width * fmt->depth) >> 3; |
751 | f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline; | 751 | f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline; |
@@ -764,18 +764,18 @@ int vidioc_querycap(struct file *file, void *priv, struct v4l2_capability *cap) | |||
764 | sprintf(cap->bus_info, "PCIe:%s", pci_name(dev->pci)); | 764 | sprintf(cap->bus_info, "PCIe:%s", pci_name(dev->pci)); |
765 | cap->version = CX25821_VERSION_CODE; | 765 | cap->version = CX25821_VERSION_CODE; |
766 | cap->capabilities = | 766 | cap->capabilities = |
767 | V4L2_CAP_VIDEO_CAPTURE | | 767 | V4L2_CAP_VIDEO_CAPTURE | |
768 | V4L2_CAP_READWRITE | | 768 | V4L2_CAP_READWRITE | |
769 | V4L2_CAP_STREAMING; | 769 | V4L2_CAP_STREAMING; |
770 | if (UNSET != dev->tuner_type) | 770 | if (UNSET != dev->tuner_type) |
771 | cap->capabilities |= V4L2_CAP_TUNER; | 771 | cap->capabilities |= V4L2_CAP_TUNER; |
772 | return 0; | 772 | return 0; |
773 | } | 773 | } |
774 | 774 | ||
775 | int vidioc_enum_fmt_vid_cap(struct file *file, void *priv, struct v4l2_fmtdesc *f) | 775 | int vidioc_enum_fmt_vid_cap(struct file *file, void *priv, struct v4l2_fmtdesc *f) |
776 | { | 776 | { |
777 | if (unlikely(f->index >= ARRAY_SIZE(formats))) | 777 | if (unlikely(f->index >= ARRAY_SIZE(formats))) |
778 | return -EINVAL; | 778 | return -EINVAL; |
779 | 779 | ||
780 | strlcpy(f->description, formats[f->index].name, sizeof(f->description)); | 780 | strlcpy(f->description, formats[f->index].name, sizeof(f->description)); |
781 | f->pixelformat = formats[f->index].fourcc; | 781 | f->pixelformat = formats[f->index].fourcc; |
@@ -799,13 +799,13 @@ int vidiocgmbuf(struct file *file, void *priv, struct video_mbuf *mbuf) | |||
799 | req.memory = V4L2_MEMORY_MMAP; | 799 | req.memory = V4L2_MEMORY_MMAP; |
800 | err = videobuf_reqbufs(q, &req); | 800 | err = videobuf_reqbufs(q, &req); |
801 | if (err < 0) | 801 | if (err < 0) |
802 | return err; | 802 | return err; |
803 | 803 | ||
804 | mbuf->frames = req.count; | 804 | mbuf->frames = req.count; |
805 | mbuf->size = 0; | 805 | mbuf->size = 0; |
806 | for (i = 0; i < mbuf->frames; i++) { | 806 | for (i = 0; i < mbuf->frames; i++) { |
807 | mbuf->offsets[i] = q->bufs[i]->boff; | 807 | mbuf->offsets[i] = q->bufs[i]->boff; |
808 | mbuf->size += q->bufs[i]->bsize; | 808 | mbuf->size += q->bufs[i]->bsize; |
809 | } | 809 | } |
810 | return 0; | 810 | return 0; |
811 | } | 811 | } |
@@ -856,17 +856,17 @@ int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *tvnorms) | |||
856 | int err; | 856 | int err; |
857 | 857 | ||
858 | dprintk(1, "%s()\n", __func__); | 858 | dprintk(1, "%s()\n", __func__); |
859 | 859 | ||
860 | if (fh) | 860 | if (fh) |
861 | { | 861 | { |
862 | err = v4l2_prio_check(&dev->prio, &fh->prio); | 862 | err = v4l2_prio_check(&dev->prio, &fh->prio); |
863 | if (0 != err) | 863 | if (0 != err) |
864 | return err; | 864 | return err; |
865 | } | 865 | } |
866 | 866 | ||
867 | if( dev->tvnorm == *tvnorms ) | 867 | if( dev->tvnorm == *tvnorms ) |
868 | { | 868 | { |
869 | return 0; | 869 | return 0; |
870 | } | 870 | } |
871 | 871 | ||
872 | mutex_lock(&dev->lock); | 872 | mutex_lock(&dev->lock); |
@@ -882,19 +882,19 @@ int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *tvnorms) | |||
882 | int cx25821_enum_input(struct cx25821_dev *dev, struct v4l2_input *i) | 882 | int cx25821_enum_input(struct cx25821_dev *dev, struct v4l2_input *i) |
883 | { | 883 | { |
884 | static const char *iname[] = { | 884 | static const char *iname[] = { |
885 | [CX25821_VMUX_COMPOSITE] = "Composite", | 885 | [CX25821_VMUX_COMPOSITE] = "Composite", |
886 | [CX25821_VMUX_SVIDEO] = "S-Video", | 886 | [CX25821_VMUX_SVIDEO] = "S-Video", |
887 | [CX25821_VMUX_DEBUG] = "for debug only", | 887 | [CX25821_VMUX_DEBUG] = "for debug only", |
888 | }; | 888 | }; |
889 | unsigned int n; | 889 | unsigned int n; |
890 | dprintk(1, "%s()\n", __func__); | 890 | dprintk(1, "%s()\n", __func__); |
891 | 891 | ||
892 | n = i->index; | 892 | n = i->index; |
893 | if (n > 2) | 893 | if (n > 2) |
894 | return -EINVAL; | 894 | return -EINVAL; |
895 | 895 | ||
896 | if (0 == INPUT(n)->type) | 896 | if (0 == INPUT(n)->type) |
897 | return -EINVAL; | 897 | return -EINVAL; |
898 | 898 | ||
899 | memset(i, 0, sizeof(*i)); | 899 | memset(i, 0, sizeof(*i)); |
900 | i->index = n; | 900 | i->index = n; |
@@ -913,9 +913,9 @@ int vidioc_enum_input(struct file *file, void *priv, struct v4l2_input *i) | |||
913 | } | 913 | } |
914 | 914 | ||
915 | int vidioc_g_input(struct file *file, void *priv, unsigned int *i) | 915 | int vidioc_g_input(struct file *file, void *priv, unsigned int *i) |
916 | { | 916 | { |
917 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 917 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
918 | 918 | ||
919 | *i = dev->input; | 919 | *i = dev->input; |
920 | dprintk(1, "%s() returns %d\n", __func__, *i); | 920 | dprintk(1, "%s() returns %d\n", __func__, *i); |
921 | return 0; | 921 | return 0; |
@@ -930,16 +930,16 @@ int vidioc_s_input(struct file *file, void *priv, unsigned int i) | |||
930 | 930 | ||
931 | dprintk(1, "%s(%d)\n", __func__, i); | 931 | dprintk(1, "%s(%d)\n", __func__, i); |
932 | 932 | ||
933 | if (fh) | 933 | if (fh) |
934 | { | 934 | { |
935 | err = v4l2_prio_check(&dev->prio, &fh->prio); | 935 | err = v4l2_prio_check(&dev->prio, &fh->prio); |
936 | if (0 != err) | 936 | if (0 != err) |
937 | return err; | 937 | return err; |
938 | } | 938 | } |
939 | 939 | ||
940 | if (i > 2) { | 940 | if (i > 2) { |
941 | dprintk(1, "%s() -EINVAL\n", __func__); | 941 | dprintk(1, "%s() -EINVAL\n", __func__); |
942 | return -EINVAL; | 942 | return -EINVAL; |
943 | } | 943 | } |
944 | 944 | ||
945 | mutex_lock(&dev->lock); | 945 | mutex_lock(&dev->lock); |
@@ -982,11 +982,11 @@ int vidioc_s_frequency(struct file *file, void *priv, struct v4l2_frequency *f) | |||
982 | struct cx25821_dev *dev = fh->dev; | 982 | struct cx25821_dev *dev = fh->dev; |
983 | int err; | 983 | int err; |
984 | 984 | ||
985 | if (fh) | 985 | if (fh) |
986 | { | 986 | { |
987 | err = v4l2_prio_check(&dev->prio, &fh->prio); | 987 | err = v4l2_prio_check(&dev->prio, &fh->prio); |
988 | if (0 != err) | 988 | if (0 != err) |
989 | return err; | 989 | return err; |
990 | } | 990 | } |
991 | 991 | ||
992 | return cx25821_set_freq(dev, f); | 992 | return cx25821_set_freq(dev, f); |
@@ -995,12 +995,12 @@ int vidioc_s_frequency(struct file *file, void *priv, struct v4l2_frequency *f) | |||
995 | 995 | ||
996 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 996 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
997 | int vidioc_g_register(struct file *file, void *fh, | 997 | int vidioc_g_register(struct file *file, void *fh, |
998 | struct v4l2_dbg_register *reg) | 998 | struct v4l2_dbg_register *reg) |
999 | { | 999 | { |
1000 | struct cx25821_dev *dev = ((struct cx25821_fh *)fh)->dev; | 1000 | struct cx25821_dev *dev = ((struct cx25821_fh *)fh)->dev; |
1001 | 1001 | ||
1002 | if (!v4l2_chip_match_host(®->match)) | 1002 | if (!v4l2_chip_match_host(®->match)) |
1003 | return -EINVAL; | 1003 | return -EINVAL; |
1004 | 1004 | ||
1005 | cx25821_call_all(dev, core, g_register, reg); | 1005 | cx25821_call_all(dev, core, g_register, reg); |
1006 | 1006 | ||
@@ -1008,12 +1008,12 @@ int vidioc_g_register(struct file *file, void *fh, | |||
1008 | } | 1008 | } |
1009 | 1009 | ||
1010 | int vidioc_s_register(struct file *file, void *fh, | 1010 | int vidioc_s_register(struct file *file, void *fh, |
1011 | struct v4l2_dbg_register *reg) | 1011 | struct v4l2_dbg_register *reg) |
1012 | { | 1012 | { |
1013 | struct cx25821_dev *dev = ((struct cx25821_fh *)fh)->dev; | 1013 | struct cx25821_dev *dev = ((struct cx25821_fh *)fh)->dev; |
1014 | 1014 | ||
1015 | if (!v4l2_chip_match_host(®->match)) | 1015 | if (!v4l2_chip_match_host(®->match)) |
1016 | return -EINVAL; | 1016 | return -EINVAL; |
1017 | 1017 | ||
1018 | cx25821_call_all(dev, core, s_register, reg); | 1018 | cx25821_call_all(dev, core, s_register, reg); |
1019 | 1019 | ||
@@ -1029,9 +1029,9 @@ int vidioc_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t) | |||
1029 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 1029 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
1030 | 1030 | ||
1031 | if (unlikely(UNSET == dev->tuner_type)) | 1031 | if (unlikely(UNSET == dev->tuner_type)) |
1032 | return -EINVAL; | 1032 | return -EINVAL; |
1033 | if (0 != t->index) | 1033 | if (0 != t->index) |
1034 | return -EINVAL; | 1034 | return -EINVAL; |
1035 | 1035 | ||
1036 | strcpy(t->name, "Television"); | 1036 | strcpy(t->name, "Television"); |
1037 | t->type = V4L2_TUNER_ANALOG_TV; | 1037 | t->type = V4L2_TUNER_ANALOG_TV; |
@@ -1043,24 +1043,24 @@ int vidioc_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t) | |||
1043 | } | 1043 | } |
1044 | 1044 | ||
1045 | int vidioc_s_tuner(struct file *file, void *priv, | 1045 | int vidioc_s_tuner(struct file *file, void *priv, |
1046 | struct v4l2_tuner *t) | 1046 | struct v4l2_tuner *t) |
1047 | { | 1047 | { |
1048 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 1048 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
1049 | struct cx25821_fh *fh = priv; | 1049 | struct cx25821_fh *fh = priv; |
1050 | int err; | 1050 | int err; |
1051 | 1051 | ||
1052 | if (fh) | 1052 | if (fh) |
1053 | { | 1053 | { |
1054 | err = v4l2_prio_check(&dev->prio, &fh->prio); | 1054 | err = v4l2_prio_check(&dev->prio, &fh->prio); |
1055 | if (0 != err) | 1055 | if (0 != err) |
1056 | return err; | 1056 | return err; |
1057 | } | 1057 | } |
1058 | 1058 | ||
1059 | dprintk(1, "%s()\n", __func__); | 1059 | dprintk(1, "%s()\n", __func__); |
1060 | if (UNSET == dev->tuner_type) | 1060 | if (UNSET == dev->tuner_type) |
1061 | return -EINVAL; | 1061 | return -EINVAL; |
1062 | if (0 != t->index) | 1062 | if (0 != t->index) |
1063 | return -EINVAL; | 1063 | return -EINVAL; |
1064 | 1064 | ||
1065 | return 0; | 1065 | return 0; |
1066 | } | 1066 | } |
@@ -1130,7 +1130,7 @@ static int cx25821_ctrl_query(struct v4l2_queryctrl *qctrl) | |||
1130 | 1130 | ||
1131 | int vidioc_queryctrl(struct file *file, void *priv, | 1131 | int vidioc_queryctrl(struct file *file, void *priv, |
1132 | struct v4l2_queryctrl *qctrl) | 1132 | struct v4l2_queryctrl *qctrl) |
1133 | { | 1133 | { |
1134 | return cx25821_ctrl_query(qctrl); | 1134 | return cx25821_ctrl_query(qctrl); |
1135 | } | 1135 | } |
1136 | 1136 | ||
@@ -1147,20 +1147,20 @@ static const struct v4l2_queryctrl* ctrl_by_id(unsigned int id) | |||
1147 | return NULL; | 1147 | return NULL; |
1148 | } | 1148 | } |
1149 | 1149 | ||
1150 | int vidioc_g_ctrl(struct file *file, | 1150 | int vidioc_g_ctrl(struct file *file, |
1151 | void *priv, | 1151 | void *priv, |
1152 | struct v4l2_control *ctl) | 1152 | struct v4l2_control *ctl) |
1153 | { | 1153 | { |
1154 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 1154 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
1155 | 1155 | ||
1156 | const struct v4l2_queryctrl* ctrl; | 1156 | const struct v4l2_queryctrl* ctrl; |
1157 | 1157 | ||
1158 | ctrl = ctrl_by_id(ctl->id); | 1158 | ctrl = ctrl_by_id(ctl->id); |
1159 | 1159 | ||
1160 | if (NULL == ctrl) | 1160 | if (NULL == ctrl) |
1161 | return -EINVAL; | 1161 | return -EINVAL; |
1162 | switch (ctl->id) | 1162 | switch (ctl->id) |
1163 | { | 1163 | { |
1164 | case V4L2_CID_BRIGHTNESS: | 1164 | case V4L2_CID_BRIGHTNESS: |
1165 | ctl->value = dev->ctl_bright; | 1165 | ctl->value = dev->ctl_bright; |
1166 | break; | 1166 | break; |
@@ -1173,25 +1173,25 @@ int vidioc_g_ctrl(struct file *file, | |||
1173 | case V4L2_CID_SATURATION: | 1173 | case V4L2_CID_SATURATION: |
1174 | ctl->value = dev->ctl_saturation; | 1174 | ctl->value = dev->ctl_saturation; |
1175 | break; | 1175 | break; |
1176 | } | 1176 | } |
1177 | return 0; | 1177 | return 0; |
1178 | } | 1178 | } |
1179 | 1179 | ||
1180 | int cx25821_set_control(struct cx25821_dev *dev, | 1180 | int cx25821_set_control(struct cx25821_dev *dev, |
1181 | struct v4l2_control *ctl, int chan_num) | 1181 | struct v4l2_control *ctl, int chan_num) |
1182 | { | 1182 | { |
1183 | int err; | 1183 | int err; |
1184 | const struct v4l2_queryctrl* ctrl; | 1184 | const struct v4l2_queryctrl* ctrl; |
1185 | 1185 | ||
1186 | err = -EINVAL; | 1186 | err = -EINVAL; |
1187 | 1187 | ||
1188 | ctrl = ctrl_by_id(ctl->id); | 1188 | ctrl = ctrl_by_id(ctl->id); |
1189 | 1189 | ||
1190 | if (NULL == ctrl) | 1190 | if (NULL == ctrl) |
1191 | return err; | 1191 | return err; |
1192 | 1192 | ||
1193 | switch (ctrl->type) | 1193 | switch (ctrl->type) |
1194 | { | 1194 | { |
1195 | case V4L2_CTRL_TYPE_BOOLEAN: | 1195 | case V4L2_CTRL_TYPE_BOOLEAN: |
1196 | case V4L2_CTRL_TYPE_MENU: | 1196 | case V4L2_CTRL_TYPE_MENU: |
1197 | case V4L2_CTRL_TYPE_INTEGER: | 1197 | case V4L2_CTRL_TYPE_INTEGER: |
@@ -1204,8 +1204,8 @@ int cx25821_set_control(struct cx25821_dev *dev, | |||
1204 | /* nothing */; | 1204 | /* nothing */; |
1205 | }; | 1205 | }; |
1206 | 1206 | ||
1207 | switch (ctl->id) | 1207 | switch (ctl->id) |
1208 | { | 1208 | { |
1209 | case V4L2_CID_BRIGHTNESS: | 1209 | case V4L2_CID_BRIGHTNESS: |
1210 | dev->ctl_bright = ctl->value; | 1210 | dev->ctl_bright = ctl->value; |
1211 | medusa_set_brightness(dev, ctl->value, chan_num); | 1211 | medusa_set_brightness(dev, ctl->value, chan_num); |
@@ -1222,9 +1222,9 @@ int cx25821_set_control(struct cx25821_dev *dev, | |||
1222 | dev->ctl_saturation = ctl->value; | 1222 | dev->ctl_saturation = ctl->value; |
1223 | medusa_set_saturation(dev, ctl->value, chan_num); | 1223 | medusa_set_saturation(dev, ctl->value, chan_num); |
1224 | break; | 1224 | break; |
1225 | } | 1225 | } |
1226 | 1226 | ||
1227 | err = 0; | 1227 | err = 0; |
1228 | 1228 | ||
1229 | return err; | 1229 | return err; |
1230 | } | 1230 | } |
@@ -1241,12 +1241,12 @@ static void init_controls(struct cx25821_dev *dev, int chan_num) | |||
1241 | } | 1241 | } |
1242 | } | 1242 | } |
1243 | 1243 | ||
1244 | int vidioc_cropcap(struct file *file, | 1244 | int vidioc_cropcap(struct file *file, |
1245 | void *priv, | 1245 | void *priv, |
1246 | struct v4l2_cropcap *cropcap) | 1246 | struct v4l2_cropcap *cropcap) |
1247 | { | 1247 | { |
1248 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 1248 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
1249 | 1249 | ||
1250 | if (cropcap->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 1250 | if (cropcap->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
1251 | return -EINVAL; | 1251 | return -EINVAL; |
1252 | cropcap->bounds.top = cropcap->bounds.left = 0; | 1252 | cropcap->bounds.top = cropcap->bounds.left = 0; |
@@ -1258,34 +1258,34 @@ int vidioc_cropcap(struct file *file, | |||
1258 | return 0; | 1258 | return 0; |
1259 | } | 1259 | } |
1260 | 1260 | ||
1261 | int vidioc_s_crop(struct file *file, | 1261 | int vidioc_s_crop(struct file *file, |
1262 | void *priv, | 1262 | void *priv, |
1263 | struct v4l2_crop *crop) | 1263 | struct v4l2_crop *crop) |
1264 | { | 1264 | { |
1265 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 1265 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
1266 | struct cx25821_fh *fh = priv; | 1266 | struct cx25821_fh *fh = priv; |
1267 | int err; | 1267 | int err; |
1268 | 1268 | ||
1269 | if (fh) | 1269 | if (fh) |
1270 | { | 1270 | { |
1271 | err = v4l2_prio_check(&dev->prio, &fh->prio); | 1271 | err = v4l2_prio_check(&dev->prio, &fh->prio); |
1272 | if (0 != err) | 1272 | if (0 != err) |
1273 | return err; | 1273 | return err; |
1274 | } | 1274 | } |
1275 | // vidioc_s_crop not supported | 1275 | // vidioc_s_crop not supported |
1276 | return -EINVAL; | 1276 | return -EINVAL; |
1277 | } | 1277 | } |
1278 | 1278 | ||
1279 | int vidioc_g_crop(struct file *file, | 1279 | int vidioc_g_crop(struct file *file, |
1280 | void *priv, | 1280 | void *priv, |
1281 | struct v4l2_crop *crop) | 1281 | struct v4l2_crop *crop) |
1282 | { | 1282 | { |
1283 | // vidioc_g_crop not supported | 1283 | // vidioc_g_crop not supported |
1284 | return -EINVAL; | 1284 | return -EINVAL; |
1285 | } | 1285 | } |
1286 | 1286 | ||
1287 | int vidioc_querystd(struct file *file, | 1287 | int vidioc_querystd(struct file *file, |
1288 | void *priv, | 1288 | void *priv, |
1289 | v4l2_std_id *norm) | 1289 | v4l2_std_id *norm) |
1290 | { | 1290 | { |
1291 | // medusa does not support video standard sensing of current input | 1291 | // medusa does not support video standard sensing of current input |
@@ -1299,17 +1299,17 @@ int is_valid_width(u32 width, v4l2_std_id tvnorm) | |||
1299 | if(tvnorm == V4L2_STD_PAL_BG) | 1299 | if(tvnorm == V4L2_STD_PAL_BG) |
1300 | { | 1300 | { |
1301 | if (width == 352 || width == 720) | 1301 | if (width == 352 || width == 720) |
1302 | return 1; | 1302 | return 1; |
1303 | else | 1303 | else |
1304 | return 0; | 1304 | return 0; |
1305 | } | 1305 | } |
1306 | 1306 | ||
1307 | if(tvnorm == V4L2_STD_NTSC_M) | 1307 | if(tvnorm == V4L2_STD_NTSC_M) |
1308 | { | 1308 | { |
1309 | if (width == 320 || width == 352 || width == 720) | 1309 | if (width == 320 || width == 352 || width == 720) |
1310 | return 1; | 1310 | return 1; |
1311 | else | 1311 | else |
1312 | return 0; | 1312 | return 0; |
1313 | } | 1313 | } |
1314 | return 0; | 1314 | return 0; |
1315 | } | 1315 | } |
@@ -1317,19 +1317,19 @@ int is_valid_width(u32 width, v4l2_std_id tvnorm) | |||
1317 | int is_valid_height(u32 height, v4l2_std_id tvnorm) | 1317 | int is_valid_height(u32 height, v4l2_std_id tvnorm) |
1318 | { | 1318 | { |
1319 | if(tvnorm == V4L2_STD_PAL_BG) | 1319 | if(tvnorm == V4L2_STD_PAL_BG) |
1320 | { | 1320 | { |
1321 | if (height == 576 || height == 288) | 1321 | if (height == 576 || height == 288) |
1322 | return 1; | 1322 | return 1; |
1323 | else | 1323 | else |
1324 | return 0; | 1324 | return 0; |
1325 | } | 1325 | } |
1326 | 1326 | ||
1327 | if(tvnorm == V4L2_STD_NTSC_M) | 1327 | if(tvnorm == V4L2_STD_NTSC_M) |
1328 | { | 1328 | { |
1329 | if (height == 480 || height == 240) | 1329 | if (height == 480 || height == 240) |
1330 | return 1; | 1330 | return 1; |
1331 | else | 1331 | else |
1332 | return 0; | 1332 | return 0; |
1333 | } | 1333 | } |
1334 | 1334 | ||
1335 | return 0; | 1335 | return 0; |
diff --git a/drivers/staging/cx25821/cx25821-video.h b/drivers/staging/cx25821/cx25821-video.h index fa2ec788535..8b162014d8f 100644 --- a/drivers/staging/cx25821/cx25821-video.h +++ b/drivers/staging/cx25821/cx25821-video.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the Conexant CX25821 PCIe bridge | 2 | * Driver for the Conexant CX25821 PCIe bridge |
3 | * | 3 | * |
4 | * Copyright (C) 2009 Conexant Systems Inc. | 4 | * Copyright (C) 2009 Conexant Systems Inc. |
5 | * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com> | 5 | * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com> |
6 | * Based on Steven Toth <stoth@linuxtv.org> cx23885 driver | 6 | * Based on Steven Toth <stoth@linuxtv.org> cx23885 driver |
7 | * | 7 | * |
@@ -52,7 +52,7 @@ | |||
52 | 52 | ||
53 | #define dprintk(level, fmt, arg...)\ | 53 | #define dprintk(level, fmt, arg...)\ |
54 | do { if (VIDEO_DEBUG >= level)\ | 54 | do { if (VIDEO_DEBUG >= level)\ |
55 | printk(KERN_DEBUG "%s/0: " fmt, dev->name, ## arg);\ | 55 | printk(KERN_DEBUG "%s/0: " fmt, dev->name, ## arg);\ |
56 | } while (0) | 56 | } while (0) |
57 | 57 | ||
58 | 58 | ||
@@ -117,9 +117,9 @@ extern int res_locked(struct cx25821_dev *dev, unsigned int bit); | |||
117 | extern void res_free(struct cx25821_dev *dev, struct cx25821_fh *fh, unsigned int bits); | 117 | extern void res_free(struct cx25821_dev *dev, struct cx25821_fh *fh, unsigned int bits); |
118 | extern int cx25821_video_mux(struct cx25821_dev *dev, unsigned int input); | 118 | extern int cx25821_video_mux(struct cx25821_dev *dev, unsigned int input); |
119 | extern int cx25821_start_video_dma(struct cx25821_dev *dev, | 119 | extern int cx25821_start_video_dma(struct cx25821_dev *dev, |
120 | struct cx25821_dmaqueue *q, | 120 | struct cx25821_dmaqueue *q, |
121 | struct cx25821_buffer *buf, | 121 | struct cx25821_buffer *buf, |
122 | struct sram_channel *channel); | 122 | struct sram_channel *channel); |
123 | 123 | ||
124 | extern int cx25821_set_scale(struct cx25821_dev *dev, unsigned int width, unsigned int height, enum v4l2_field field); | 124 | extern int cx25821_set_scale(struct cx25821_dev *dev, unsigned int width, unsigned int height, enum v4l2_field field); |
125 | extern int cx25821_video_irq(struct cx25821_dev *dev, int chan_num, u32 status); | 125 | extern int cx25821_video_irq(struct cx25821_dev *dev, int chan_num, u32 status); |
diff --git a/drivers/staging/cx25821/cx25821-video0.c b/drivers/staging/cx25821/cx25821-video0.c index 9dbd740f1e2..92b5eb937d2 100644 --- a/drivers/staging/cx25821/cx25821-video0.c +++ b/drivers/staging/cx25821/cx25821-video0.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the Conexant CX25821 PCIe bridge | 2 | * Driver for the Conexant CX25821 PCIe bridge |
3 | * | 3 | * |
4 | * Copyright (C) 2009 Conexant Systems Inc. | 4 | * Copyright (C) 2009 Conexant Systems Inc. |
5 | * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com> | 5 | * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com> |
6 | * Based on Steven Toth <stoth@linuxtv.org> cx23885 driver | 6 | * Based on Steven Toth <stoth@linuxtv.org> cx23885 driver |
7 | * | 7 | * |
@@ -40,37 +40,37 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) | |||
40 | dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]); | 40 | dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]); |
41 | 41 | ||
42 | if (!list_empty(&q->queued)) { | 42 | if (!list_empty(&q->queued)) { |
43 | list_add_tail(&buf->vb.queue, &q->queued); | 43 | list_add_tail(&buf->vb.queue, &q->queued); |
44 | buf->vb.state = VIDEOBUF_QUEUED; | 44 | buf->vb.state = VIDEOBUF_QUEUED; |
45 | dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i); | 45 | dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i); |
46 | 46 | ||
47 | } else if (list_empty(&q->active)) { | 47 | } else if (list_empty(&q->active)) { |
48 | list_add_tail(&buf->vb.queue, &q->active); | 48 | list_add_tail(&buf->vb.queue, &q->active); |
49 | cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH00]); | 49 | cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH00]); |
50 | buf->vb.state = VIDEOBUF_ACTIVE; | 50 | buf->vb.state = VIDEOBUF_ACTIVE; |
51 | buf->count = q->count++; | 51 | buf->count = q->count++; |
52 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); | 52 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); |
53 | dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n", | 53 | dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n", |
54 | buf, buf->vb. i, buf->count, q->count); | 54 | buf, buf->vb. i, buf->count, q->count); |
55 | } else { | 55 | } else { |
56 | prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue); | 56 | prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue); |
57 | if (prev->vb.width == buf->vb.width && | 57 | if (prev->vb.width == buf->vb.width && |
58 | prev->vb.height == buf->vb.height && | 58 | prev->vb.height == buf->vb.height && |
59 | prev->fmt == buf->fmt) { | 59 | prev->fmt == buf->fmt) { |
60 | list_add_tail(&buf->vb.queue, &q->active); | 60 | list_add_tail(&buf->vb.queue, &q->active); |
61 | buf->vb.state = VIDEOBUF_ACTIVE; | 61 | buf->vb.state = VIDEOBUF_ACTIVE; |
62 | buf->count = q->count++; | 62 | buf->count = q->count++; |
63 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); | 63 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); |
64 | 64 | ||
65 | /* 64 bit bits 63-32 */ | 65 | /* 64 bit bits 63-32 */ |
66 | prev->risc.jmp[2] = cpu_to_le32(0); | 66 | prev->risc.jmp[2] = cpu_to_le32(0); |
67 | dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count); | 67 | dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count); |
68 | 68 | ||
69 | } else { | 69 | } else { |
70 | list_add_tail(&buf->vb.queue, &q->queued); | 70 | list_add_tail(&buf->vb.queue, &q->queued); |
71 | buf->vb.state = VIDEOBUF_QUEUED; | 71 | buf->vb.state = VIDEOBUF_QUEUED; |
72 | dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i); | 72 | dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i); |
73 | } | 73 | } |
74 | } | 74 | } |
75 | 75 | ||
76 | if (list_empty(&q->active)) | 76 | if (list_empty(&q->active)) |
@@ -100,18 +100,18 @@ static int video_open(struct file *file) | |||
100 | lock_kernel(); | 100 | lock_kernel(); |
101 | list_for_each(list, &cx25821_devlist) | 101 | list_for_each(list, &cx25821_devlist) |
102 | { | 102 | { |
103 | h = list_entry(list, struct cx25821_dev, devlist); | 103 | h = list_entry(list, struct cx25821_dev, devlist); |
104 | 104 | ||
105 | if (h->video_dev[SRAM_CH00] && h->video_dev[SRAM_CH00]->minor == minor) | 105 | if (h->video_dev[SRAM_CH00] && h->video_dev[SRAM_CH00]->minor == minor) |
106 | { | 106 | { |
107 | dev = h; | 107 | dev = h; |
108 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 108 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
109 | } | 109 | } |
110 | } | 110 | } |
111 | 111 | ||
112 | if (NULL == dev) { | 112 | if (NULL == dev) { |
113 | unlock_kernel(); | 113 | unlock_kernel(); |
114 | return -ENODEV; | 114 | return -ENODEV; |
115 | } | 115 | } |
116 | 116 | ||
117 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); | 117 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); |
@@ -119,8 +119,8 @@ static int video_open(struct file *file) | |||
119 | /* allocate + initialize per filehandle data */ | 119 | /* allocate + initialize per filehandle data */ |
120 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); | 120 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); |
121 | if (NULL == fh) { | 121 | if (NULL == fh) { |
122 | unlock_kernel(); | 122 | unlock_kernel(); |
123 | return -ENOMEM; | 123 | return -ENOMEM; |
124 | } | 124 | } |
125 | 125 | ||
126 | file->private_data = fh; | 126 | file->private_data = fh; |
@@ -129,22 +129,22 @@ static int video_open(struct file *file) | |||
129 | fh->width = 720; | 129 | fh->width = 720; |
130 | 130 | ||
131 | if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) | 131 | if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) |
132 | fh->height = 576; | 132 | fh->height = 576; |
133 | else | 133 | else |
134 | fh->height = 480; | 134 | fh->height = 480; |
135 | 135 | ||
136 | dev->channel_opened = SRAM_CH00; | 136 | dev->channel_opened = SRAM_CH00; |
137 | pix_format = (dev->pixel_formats[dev->channel_opened] == PIXEL_FRMT_411) ? V4L2_PIX_FMT_Y41P : V4L2_PIX_FMT_YUYV; | 137 | pix_format = (dev->pixel_formats[dev->channel_opened] == PIXEL_FRMT_411) ? V4L2_PIX_FMT_Y41P : V4L2_PIX_FMT_YUYV; |
138 | fh->fmt = format_by_fourcc(pix_format); | 138 | fh->fmt = format_by_fourcc(pix_format); |
139 | 139 | ||
140 | v4l2_prio_open(&dev->prio,&fh->prio); | 140 | v4l2_prio_open(&dev->prio,&fh->prio); |
141 | 141 | ||
142 | videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops, | 142 | videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops, |
143 | &dev->pci->dev, &dev->slock, | 143 | &dev->pci->dev, &dev->slock, |
144 | V4L2_BUF_TYPE_VIDEO_CAPTURE, | 144 | V4L2_BUF_TYPE_VIDEO_CAPTURE, |
145 | V4L2_FIELD_INTERLACED, | 145 | V4L2_FIELD_INTERLACED, |
146 | sizeof(struct cx25821_buffer), | 146 | sizeof(struct cx25821_buffer), |
147 | fh); | 147 | fh); |
148 | 148 | ||
149 | dprintk(1, "post videobuf_queue_init()\n"); | 149 | dprintk(1, "post videobuf_queue_init()\n"); |
150 | unlock_kernel(); | 150 | unlock_kernel(); |
@@ -158,15 +158,15 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo | |||
158 | 158 | ||
159 | switch (fh->type) | 159 | switch (fh->type) |
160 | { | 160 | { |
161 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 161 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
162 | if (res_locked(fh->dev, RESOURCE_VIDEO0)) | 162 | if (res_locked(fh->dev, RESOURCE_VIDEO0)) |
163 | return -EBUSY; | 163 | return -EBUSY; |
164 | 164 | ||
165 | return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK); | 165 | return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK); |
166 | 166 | ||
167 | default: | 167 | default: |
168 | BUG(); | 168 | BUG(); |
169 | return 0; | 169 | return 0; |
170 | } | 170 | } |
171 | } | 171 | } |
172 | 172 | ||
@@ -176,36 +176,36 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait | |||
176 | struct cx25821_buffer *buf; | 176 | struct cx25821_buffer *buf; |
177 | 177 | ||
178 | if (res_check(fh, RESOURCE_VIDEO0)) { | 178 | if (res_check(fh, RESOURCE_VIDEO0)) { |
179 | /* streaming capture */ | 179 | /* streaming capture */ |
180 | if (list_empty(&fh->vidq.stream)) | 180 | if (list_empty(&fh->vidq.stream)) |
181 | return POLLERR; | 181 | return POLLERR; |
182 | buf = list_entry(fh->vidq.stream.next, | 182 | buf = list_entry(fh->vidq.stream.next, |
183 | struct cx25821_buffer, vb.stream); | 183 | struct cx25821_buffer, vb.stream); |
184 | } else { | 184 | } else { |
185 | /* read() capture */ | 185 | /* read() capture */ |
186 | buf = (struct cx25821_buffer *)fh->vidq.read_buf; | 186 | buf = (struct cx25821_buffer *)fh->vidq.read_buf; |
187 | if (NULL == buf) | 187 | if (NULL == buf) |
188 | return POLLERR; | 188 | return POLLERR; |
189 | } | 189 | } |
190 | 190 | ||
191 | poll_wait(file, &buf->vb.done, wait); | 191 | poll_wait(file, &buf->vb.done, wait); |
192 | if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR) | 192 | if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR) |
193 | { | 193 | { |
194 | if( buf->vb.state == VIDEOBUF_DONE ) | 194 | if( buf->vb.state == VIDEOBUF_DONE ) |
195 | { | 195 | { |
196 | struct cx25821_dev *dev = fh->dev; | 196 | struct cx25821_dev *dev = fh->dev; |
197 | 197 | ||
198 | if( dev && dev->use_cif_resolution[SRAM_CH00] ) | 198 | if( dev && dev->use_cif_resolution[SRAM_CH00] ) |
199 | { | 199 | { |
200 | u8 cam_id = *((char*)buf->vb.baddr+3); | 200 | u8 cam_id = *((char*)buf->vb.baddr+3); |
201 | memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2)); | 201 | memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2)); |
202 | *((char*)buf->vb.baddr+3) = cam_id; | 202 | *((char*)buf->vb.baddr+3) = cam_id; |
203 | } | 203 | } |
204 | } | 204 | } |
205 | 205 | ||
206 | return POLLIN|POLLRDNORM; | 206 | return POLLIN|POLLRDNORM; |
207 | } | 207 | } |
208 | 208 | ||
209 | return 0; | 209 | return 0; |
210 | } | 210 | } |
211 | 211 | ||
@@ -220,13 +220,13 @@ static int video_release(struct file *file) | |||
220 | 220 | ||
221 | /* stop video capture */ | 221 | /* stop video capture */ |
222 | if (res_check(fh, RESOURCE_VIDEO0)) { | 222 | if (res_check(fh, RESOURCE_VIDEO0)) { |
223 | videobuf_queue_cancel(&fh->vidq); | 223 | videobuf_queue_cancel(&fh->vidq); |
224 | res_free(dev, fh, RESOURCE_VIDEO0); | 224 | res_free(dev, fh, RESOURCE_VIDEO0); |
225 | } | 225 | } |
226 | 226 | ||
227 | if (fh->vidq.read_buf) { | 227 | if (fh->vidq.read_buf) { |
228 | buffer_release(&fh->vidq, fh->vidq.read_buf); | 228 | buffer_release(&fh->vidq, fh->vidq.read_buf); |
229 | kfree(fh->vidq.read_buf); | 229 | kfree(fh->vidq.read_buf); |
230 | } | 230 | } |
231 | 231 | ||
232 | videobuf_mmap_free(&fh->vidq); | 232 | videobuf_mmap_free(&fh->vidq); |
@@ -246,17 +246,17 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) | |||
246 | 246 | ||
247 | if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) | 247 | if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) |
248 | { | 248 | { |
249 | return -EINVAL; | 249 | return -EINVAL; |
250 | } | 250 | } |
251 | 251 | ||
252 | if (unlikely(i != fh->type)) | 252 | if (unlikely(i != fh->type)) |
253 | { | 253 | { |
254 | return -EINVAL; | 254 | return -EINVAL; |
255 | } | 255 | } |
256 | 256 | ||
257 | if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO0)))) | 257 | if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO0)))) |
258 | { | 258 | { |
259 | return -EBUSY; | 259 | return -EBUSY; |
260 | } | 260 | } |
261 | 261 | ||
262 | return videobuf_streamon(get_queue(fh)); | 262 | return videobuf_streamon(get_queue(fh)); |
@@ -269,14 +269,14 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) | |||
269 | int err, res; | 269 | int err, res; |
270 | 270 | ||
271 | if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 271 | if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
272 | return -EINVAL; | 272 | return -EINVAL; |
273 | if (i != fh->type) | 273 | if (i != fh->type) |
274 | return -EINVAL; | 274 | return -EINVAL; |
275 | 275 | ||
276 | res = get_resource(fh, RESOURCE_VIDEO0); | 276 | res = get_resource(fh, RESOURCE_VIDEO0); |
277 | err = videobuf_streamoff(get_queue(fh)); | 277 | err = videobuf_streamoff(get_queue(fh)); |
278 | if (err < 0) | 278 | if (err < 0) |
279 | return err; | 279 | return err; |
280 | res_free(dev, fh, res); | 280 | res_free(dev, fh, res); |
281 | return 0; | 281 | return 0; |
282 | } | 282 | } |
@@ -286,21 +286,21 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma | |||
286 | { | 286 | { |
287 | struct cx25821_fh *fh = priv; | 287 | struct cx25821_fh *fh = priv; |
288 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 288 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
289 | int err; | 289 | int err; |
290 | int pix_format = PIXEL_FRMT_422; | 290 | int pix_format = PIXEL_FRMT_422; |
291 | 291 | ||
292 | if (fh) | 292 | if (fh) |
293 | { | 293 | { |
294 | err = v4l2_prio_check(&dev->prio, &fh->prio); | 294 | err = v4l2_prio_check(&dev->prio, &fh->prio); |
295 | if (0 != err) | 295 | if (0 != err) |
296 | return err; | 296 | return err; |
297 | } | 297 | } |
298 | 298 | ||
299 | dprintk(2, "%s()\n", __func__); | 299 | dprintk(2, "%s()\n", __func__); |
300 | err = vidioc_try_fmt_vid_cap(file, priv, f); | 300 | err = vidioc_try_fmt_vid_cap(file, priv, f); |
301 | 301 | ||
302 | if (0 != err) | 302 | if (0 != err) |
303 | return err; | 303 | return err; |
304 | 304 | ||
305 | fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); | 305 | fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); |
306 | fh->vidq.field = f->fmt.pix.field; | 306 | fh->vidq.field = f->fmt.pix.field; |
@@ -308,33 +308,33 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma | |||
308 | // check if width and height is valid based on set standard | 308 | // check if width and height is valid based on set standard |
309 | if (is_valid_width(f->fmt.pix.width, dev->tvnorm)) | 309 | if (is_valid_width(f->fmt.pix.width, dev->tvnorm)) |
310 | { | 310 | { |
311 | fh->width = f->fmt.pix.width; | 311 | fh->width = f->fmt.pix.width; |
312 | } | 312 | } |
313 | 313 | ||
314 | if (is_valid_height(f->fmt.pix.height, dev->tvnorm)) | 314 | if (is_valid_height(f->fmt.pix.height, dev->tvnorm)) |
315 | { | 315 | { |
316 | fh->height = f->fmt.pix.height; | 316 | fh->height = f->fmt.pix.height; |
317 | } | 317 | } |
318 | 318 | ||
319 | if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P) | 319 | if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P) |
320 | pix_format = PIXEL_FRMT_411; | 320 | pix_format = PIXEL_FRMT_411; |
321 | else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV) | 321 | else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV) |
322 | pix_format = PIXEL_FRMT_422; | 322 | pix_format = PIXEL_FRMT_422; |
323 | else | 323 | else |
324 | return -EINVAL; | 324 | return -EINVAL; |
325 | |||
326 | cx25821_set_pixel_format( dev, SRAM_CH00, pix_format ); | ||
325 | 327 | ||
326 | cx25821_set_pixel_format( dev, SRAM_CH00, pix_format ); | ||
327 | |||
328 | // check if cif resolution | 328 | // check if cif resolution |
329 | if (fh->width == 320 || fh->width == 352) | 329 | if (fh->width == 320 || fh->width == 352) |
330 | { | 330 | { |
331 | dev->use_cif_resolution[SRAM_CH00] = 1; | 331 | dev->use_cif_resolution[SRAM_CH00] = 1; |
332 | }else | 332 | }else |
333 | { | 333 | { |
334 | dev->use_cif_resolution[SRAM_CH00] = 0; | 334 | dev->use_cif_resolution[SRAM_CH00] = 0; |
335 | } | 335 | } |
336 | dev->cif_width[SRAM_CH00] = fh->width; | 336 | dev->cif_width[SRAM_CH00] = fh->width; |
337 | medusa_set_resolution( dev, fh->width, SRAM_CH00 ); | 337 | medusa_set_resolution( dev, fh->width, SRAM_CH00 ); |
338 | 338 | ||
339 | dprintk(2, "%s() width=%d height=%d field=%d\n", __func__, fh->width, fh->height, fh->vidq.field); | 339 | dprintk(2, "%s() width=%d height=%d field=%d\n", __func__, fh->width, fh->height, fh->vidq.field); |
340 | cx25821_call_all(dev, video, s_fmt, f); | 340 | cx25821_call_all(dev, video, s_fmt, f); |
@@ -348,7 +348,7 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p) | |||
348 | struct cx25821_fh *fh = priv; | 348 | struct cx25821_fh *fh = priv; |
349 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 349 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
350 | 350 | ||
351 | ret_val = videobuf_dqbuf(get_queue(fh), p, file->f_flags & O_NONBLOCK); | 351 | ret_val = videobuf_dqbuf(get_queue(fh), p, file->f_flags & O_NONBLOCK); |
352 | 352 | ||
353 | p->sequence = dev->vidq[SRAM_CH00].count; | 353 | p->sequence = dev->vidq[SRAM_CH00].count; |
354 | 354 | ||
@@ -360,7 +360,7 @@ static int vidioc_log_status (struct file *file, void *priv) | |||
360 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 360 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
361 | char name[32 + 2]; | 361 | char name[32 + 2]; |
362 | 362 | ||
363 | struct sram_channel *sram_ch = &dev->sram_channels[SRAM_CH00]; | 363 | struct sram_channel *sram_ch = &dev->sram_channels[SRAM_CH00]; |
364 | u32 tmp = 0; | 364 | u32 tmp = 0; |
365 | 365 | ||
366 | snprintf(name, sizeof(name), "%s/2", dev->name); | 366 | snprintf(name, sizeof(name), "%s/2", dev->name); |
@@ -378,10 +378,10 @@ static int vidioc_s_ctrl(struct file *file, void *priv, | |||
378 | struct v4l2_control *ctl) | 378 | struct v4l2_control *ctl) |
379 | { | 379 | { |
380 | struct cx25821_fh *fh = priv; | 380 | struct cx25821_fh *fh = priv; |
381 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 381 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
382 | int err; | 382 | int err; |
383 | 383 | ||
384 | if (fh) { | 384 | if (fh) { |
385 | err = v4l2_prio_check(&dev->prio, &fh->prio); | 385 | err = v4l2_prio_check(&dev->prio, &fh->prio); |
386 | if (0 != err) | 386 | if (0 != err) |
387 | return err; | 387 | return err; |
@@ -398,7 +398,7 @@ static const struct v4l2_file_operations video_fops = { | |||
398 | .read = video_read, | 398 | .read = video_read, |
399 | .poll = video_poll, | 399 | .poll = video_poll, |
400 | .mmap = video_mmap, | 400 | .mmap = video_mmap, |
401 | .ioctl = video_ioctl2, | 401 | .ioctl = video_ioctl2, |
402 | }; | 402 | }; |
403 | 403 | ||
404 | static const struct v4l2_ioctl_ops video_ioctl_ops = { | 404 | static const struct v4l2_ioctl_ops video_ioctl_ops = { |
diff --git a/drivers/staging/cx25821/cx25821-video1.c b/drivers/staging/cx25821/cx25821-video1.c index 44db11940ff..c36f664f635 100644 --- a/drivers/staging/cx25821/cx25821-video1.c +++ b/drivers/staging/cx25821/cx25821-video1.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the Conexant CX25821 PCIe bridge | 2 | * Driver for the Conexant CX25821 PCIe bridge |
3 | * | 3 | * |
4 | * Copyright (C) 2009 Conexant Systems Inc. | 4 | * Copyright (C) 2009 Conexant Systems Inc. |
5 | * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com> | 5 | * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com> |
6 | * Based on Steven Toth <stoth@linuxtv.org> cx23885 driver | 6 | * Based on Steven Toth <stoth@linuxtv.org> cx23885 driver |
7 | * | 7 | * |
@@ -41,37 +41,37 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) | |||
41 | dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]); | 41 | dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]); |
42 | 42 | ||
43 | if (!list_empty(&q->queued)) { | 43 | if (!list_empty(&q->queued)) { |
44 | list_add_tail(&buf->vb.queue, &q->queued); | 44 | list_add_tail(&buf->vb.queue, &q->queued); |
45 | buf->vb.state = VIDEOBUF_QUEUED; | 45 | buf->vb.state = VIDEOBUF_QUEUED; |
46 | dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i); | 46 | dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i); |
47 | 47 | ||
48 | } else if (list_empty(&q->active)) { | 48 | } else if (list_empty(&q->active)) { |
49 | list_add_tail(&buf->vb.queue, &q->active); | 49 | list_add_tail(&buf->vb.queue, &q->active); |
50 | cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH01]); | 50 | cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH01]); |
51 | buf->vb.state = VIDEOBUF_ACTIVE; | 51 | buf->vb.state = VIDEOBUF_ACTIVE; |
52 | buf->count = q->count++; | 52 | buf->count = q->count++; |
53 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); | 53 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); |
54 | dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n", | 54 | dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n", |
55 | buf, buf->vb. i, buf->count, q->count); | 55 | buf, buf->vb. i, buf->count, q->count); |
56 | } else { | 56 | } else { |
57 | prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue); | 57 | prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue); |
58 | if (prev->vb.width == buf->vb.width && | 58 | if (prev->vb.width == buf->vb.width && |
59 | prev->vb.height == buf->vb.height && | 59 | prev->vb.height == buf->vb.height && |
60 | prev->fmt == buf->fmt) { | 60 | prev->fmt == buf->fmt) { |
61 | list_add_tail(&buf->vb.queue, &q->active); | 61 | list_add_tail(&buf->vb.queue, &q->active); |
62 | buf->vb.state = VIDEOBUF_ACTIVE; | 62 | buf->vb.state = VIDEOBUF_ACTIVE; |
63 | buf->count = q->count++; | 63 | buf->count = q->count++; |
64 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); | 64 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); |
65 | 65 | ||
66 | /* 64 bit bits 63-32 */ | 66 | /* 64 bit bits 63-32 */ |
67 | prev->risc.jmp[2] = cpu_to_le32(0); | 67 | prev->risc.jmp[2] = cpu_to_le32(0); |
68 | dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count); | 68 | dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count); |
69 | 69 | ||
70 | } else { | 70 | } else { |
71 | list_add_tail(&buf->vb.queue, &q->queued); | 71 | list_add_tail(&buf->vb.queue, &q->queued); |
72 | buf->vb.state = VIDEOBUF_QUEUED; | 72 | buf->vb.state = VIDEOBUF_QUEUED; |
73 | dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i); | 73 | dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i); |
74 | } | 74 | } |
75 | } | 75 | } |
76 | 76 | ||
77 | if (list_empty(&q->active)) | 77 | if (list_empty(&q->active)) |
@@ -101,17 +101,17 @@ static int video_open(struct file *file) | |||
101 | lock_kernel(); | 101 | lock_kernel(); |
102 | list_for_each(list, &cx25821_devlist) | 102 | list_for_each(list, &cx25821_devlist) |
103 | { | 103 | { |
104 | h = list_entry(list, struct cx25821_dev, devlist); | 104 | h = list_entry(list, struct cx25821_dev, devlist); |
105 | 105 | ||
106 | if (h->video_dev[SRAM_CH01] && h->video_dev[SRAM_CH01]->minor == minor) { | 106 | if (h->video_dev[SRAM_CH01] && h->video_dev[SRAM_CH01]->minor == minor) { |
107 | dev = h; | 107 | dev = h; |
108 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 108 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
109 | } | 109 | } |
110 | } | 110 | } |
111 | 111 | ||
112 | if (NULL == dev) { | 112 | if (NULL == dev) { |
113 | unlock_kernel(); | 113 | unlock_kernel(); |
114 | return -ENODEV; | 114 | return -ENODEV; |
115 | } | 115 | } |
116 | 116 | ||
117 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); | 117 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); |
@@ -119,8 +119,8 @@ static int video_open(struct file *file) | |||
119 | /* allocate + initialize per filehandle data */ | 119 | /* allocate + initialize per filehandle data */ |
120 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); | 120 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); |
121 | if (NULL == fh) { | 121 | if (NULL == fh) { |
122 | unlock_kernel(); | 122 | unlock_kernel(); |
123 | return -ENOMEM; | 123 | return -ENOMEM; |
124 | } | 124 | } |
125 | 125 | ||
126 | file->private_data = fh; | 126 | file->private_data = fh; |
@@ -129,9 +129,9 @@ static int video_open(struct file *file) | |||
129 | fh->width = 720; | 129 | fh->width = 720; |
130 | 130 | ||
131 | if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) | 131 | if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) |
132 | fh->height = 576; | 132 | fh->height = 576; |
133 | else | 133 | else |
134 | fh->height = 480; | 134 | fh->height = 480; |
135 | 135 | ||
136 | dev->channel_opened = SRAM_CH01; | 136 | dev->channel_opened = SRAM_CH01; |
137 | pix_format = (dev->pixel_formats[dev->channel_opened] == PIXEL_FRMT_411) ? V4L2_PIX_FMT_Y41P : V4L2_PIX_FMT_YUYV; | 137 | pix_format = (dev->pixel_formats[dev->channel_opened] == PIXEL_FRMT_411) ? V4L2_PIX_FMT_Y41P : V4L2_PIX_FMT_YUYV; |
@@ -140,11 +140,11 @@ static int video_open(struct file *file) | |||
140 | v4l2_prio_open(&dev->prio,&fh->prio); | 140 | v4l2_prio_open(&dev->prio,&fh->prio); |
141 | 141 | ||
142 | videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops, | 142 | videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops, |
143 | &dev->pci->dev, &dev->slock, | 143 | &dev->pci->dev, &dev->slock, |
144 | V4L2_BUF_TYPE_VIDEO_CAPTURE, | 144 | V4L2_BUF_TYPE_VIDEO_CAPTURE, |
145 | V4L2_FIELD_INTERLACED, | 145 | V4L2_FIELD_INTERLACED, |
146 | sizeof(struct cx25821_buffer), | 146 | sizeof(struct cx25821_buffer), |
147 | fh); | 147 | fh); |
148 | 148 | ||
149 | dprintk(1, "post videobuf_queue_init()\n"); | 149 | dprintk(1, "post videobuf_queue_init()\n"); |
150 | unlock_kernel(); | 150 | unlock_kernel(); |
@@ -158,15 +158,15 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo | |||
158 | 158 | ||
159 | switch (fh->type) | 159 | switch (fh->type) |
160 | { | 160 | { |
161 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 161 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
162 | if (res_locked(fh->dev, RESOURCE_VIDEO1)) | 162 | if (res_locked(fh->dev, RESOURCE_VIDEO1)) |
163 | return -EBUSY; | 163 | return -EBUSY; |
164 | 164 | ||
165 | return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK); | 165 | return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK); |
166 | 166 | ||
167 | default: | 167 | default: |
168 | BUG(); | 168 | BUG(); |
169 | return 0; | 169 | return 0; |
170 | } | 170 | } |
171 | } | 171 | } |
172 | 172 | ||
@@ -176,36 +176,36 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait | |||
176 | struct cx25821_buffer *buf; | 176 | struct cx25821_buffer *buf; |
177 | 177 | ||
178 | if (res_check(fh, RESOURCE_VIDEO1)) { | 178 | if (res_check(fh, RESOURCE_VIDEO1)) { |
179 | /* streaming capture */ | 179 | /* streaming capture */ |
180 | if (list_empty(&fh->vidq.stream)) | 180 | if (list_empty(&fh->vidq.stream)) |
181 | return POLLERR; | 181 | return POLLERR; |
182 | buf = list_entry(fh->vidq.stream.next, | 182 | buf = list_entry(fh->vidq.stream.next, |
183 | struct cx25821_buffer, vb.stream); | 183 | struct cx25821_buffer, vb.stream); |
184 | } else { | 184 | } else { |
185 | /* read() capture */ | 185 | /* read() capture */ |
186 | buf = (struct cx25821_buffer *)fh->vidq.read_buf; | 186 | buf = (struct cx25821_buffer *)fh->vidq.read_buf; |
187 | if (NULL == buf) | 187 | if (NULL == buf) |
188 | return POLLERR; | 188 | return POLLERR; |
189 | } | 189 | } |
190 | 190 | ||
191 | poll_wait(file, &buf->vb.done, wait); | 191 | poll_wait(file, &buf->vb.done, wait); |
192 | if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR) | 192 | if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR) |
193 | { | 193 | { |
194 | if( buf->vb.state == VIDEOBUF_DONE ) | 194 | if( buf->vb.state == VIDEOBUF_DONE ) |
195 | { | 195 | { |
196 | struct cx25821_dev *dev = fh->dev; | 196 | struct cx25821_dev *dev = fh->dev; |
197 | 197 | ||
198 | if( dev && dev->use_cif_resolution[SRAM_CH01] ) | 198 | if( dev && dev->use_cif_resolution[SRAM_CH01] ) |
199 | { | 199 | { |
200 | u8 cam_id = *((char*)buf->vb.baddr+3); | 200 | u8 cam_id = *((char*)buf->vb.baddr+3); |
201 | memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2)); | 201 | memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2)); |
202 | *((char*)buf->vb.baddr+3) = cam_id; | 202 | *((char*)buf->vb.baddr+3) = cam_id; |
203 | } | 203 | } |
204 | } | 204 | } |
205 | 205 | ||
206 | return POLLIN|POLLRDNORM; | 206 | return POLLIN|POLLRDNORM; |
207 | } | 207 | } |
208 | 208 | ||
209 | return 0; | 209 | return 0; |
210 | } | 210 | } |
211 | 211 | ||
@@ -219,13 +219,13 @@ static int video_release(struct file *file) | |||
219 | 219 | ||
220 | /* stop video capture */ | 220 | /* stop video capture */ |
221 | if (res_check(fh, RESOURCE_VIDEO1)) { | 221 | if (res_check(fh, RESOURCE_VIDEO1)) { |
222 | videobuf_queue_cancel(&fh->vidq); | 222 | videobuf_queue_cancel(&fh->vidq); |
223 | res_free(dev, fh, RESOURCE_VIDEO1); | 223 | res_free(dev, fh, RESOURCE_VIDEO1); |
224 | } | 224 | } |
225 | 225 | ||
226 | if (fh->vidq.read_buf) { | 226 | if (fh->vidq.read_buf) { |
227 | buffer_release(&fh->vidq, fh->vidq.read_buf); | 227 | buffer_release(&fh->vidq, fh->vidq.read_buf); |
228 | kfree(fh->vidq.read_buf); | 228 | kfree(fh->vidq.read_buf); |
229 | } | 229 | } |
230 | 230 | ||
231 | videobuf_mmap_free(&fh->vidq); | 231 | videobuf_mmap_free(&fh->vidq); |
@@ -245,17 +245,17 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) | |||
245 | 245 | ||
246 | if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) | 246 | if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) |
247 | { | 247 | { |
248 | return -EINVAL; | 248 | return -EINVAL; |
249 | } | 249 | } |
250 | 250 | ||
251 | if (unlikely(i != fh->type)) | 251 | if (unlikely(i != fh->type)) |
252 | { | 252 | { |
253 | return -EINVAL; | 253 | return -EINVAL; |
254 | } | 254 | } |
255 | 255 | ||
256 | if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO1)))) | 256 | if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO1)))) |
257 | { | 257 | { |
258 | return -EBUSY; | 258 | return -EBUSY; |
259 | } | 259 | } |
260 | 260 | ||
261 | return videobuf_streamon(get_queue(fh)); | 261 | return videobuf_streamon(get_queue(fh)); |
@@ -268,14 +268,14 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) | |||
268 | int err, res; | 268 | int err, res; |
269 | 269 | ||
270 | if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 270 | if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
271 | return -EINVAL; | 271 | return -EINVAL; |
272 | if (i != fh->type) | 272 | if (i != fh->type) |
273 | return -EINVAL; | 273 | return -EINVAL; |
274 | 274 | ||
275 | res = get_resource(fh, RESOURCE_VIDEO1); | 275 | res = get_resource(fh, RESOURCE_VIDEO1); |
276 | err = videobuf_streamoff(get_queue(fh)); | 276 | err = videobuf_streamoff(get_queue(fh)); |
277 | if (err < 0) | 277 | if (err < 0) |
278 | return err; | 278 | return err; |
279 | res_free(dev, fh, res); | 279 | res_free(dev, fh, res); |
280 | return 0; | 280 | return 0; |
281 | } | 281 | } |
@@ -286,21 +286,21 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma | |||
286 | { | 286 | { |
287 | struct cx25821_fh *fh = priv; | 287 | struct cx25821_fh *fh = priv; |
288 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 288 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
289 | int err; | 289 | int err; |
290 | int pix_format = 0; | 290 | int pix_format = 0; |
291 | 291 | ||
292 | if (fh) | 292 | if (fh) |
293 | { | 293 | { |
294 | err = v4l2_prio_check(&dev->prio, &fh->prio); | 294 | err = v4l2_prio_check(&dev->prio, &fh->prio); |
295 | if (0 != err) | 295 | if (0 != err) |
296 | return err; | 296 | return err; |
297 | } | 297 | } |
298 | 298 | ||
299 | dprintk(2, "%s()\n", __func__); | 299 | dprintk(2, "%s()\n", __func__); |
300 | err = vidioc_try_fmt_vid_cap(file, priv, f); | 300 | err = vidioc_try_fmt_vid_cap(file, priv, f); |
301 | 301 | ||
302 | if (0 != err) | 302 | if (0 != err) |
303 | return err; | 303 | return err; |
304 | 304 | ||
305 | fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); | 305 | fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); |
306 | fh->vidq.field = f->fmt.pix.field; | 306 | fh->vidq.field = f->fmt.pix.field; |
@@ -308,33 +308,33 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma | |||
308 | // check if width and height is valid based on set standard | 308 | // check if width and height is valid based on set standard |
309 | if (is_valid_width(f->fmt.pix.width, dev->tvnorm)) | 309 | if (is_valid_width(f->fmt.pix.width, dev->tvnorm)) |
310 | { | 310 | { |
311 | fh->width = f->fmt.pix.width; | 311 | fh->width = f->fmt.pix.width; |
312 | } | 312 | } |
313 | 313 | ||
314 | if (is_valid_height(f->fmt.pix.height, dev->tvnorm)) | 314 | if (is_valid_height(f->fmt.pix.height, dev->tvnorm)) |
315 | { | 315 | { |
316 | fh->height = f->fmt.pix.height; | 316 | fh->height = f->fmt.pix.height; |
317 | } | 317 | } |
318 | 318 | ||
319 | if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P) | 319 | if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P) |
320 | pix_format = PIXEL_FRMT_411; | 320 | pix_format = PIXEL_FRMT_411; |
321 | else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV) | 321 | else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV) |
322 | pix_format = PIXEL_FRMT_422; | 322 | pix_format = PIXEL_FRMT_422; |
323 | else | 323 | else |
324 | return -EINVAL; | 324 | return -EINVAL; |
325 | |||
326 | cx25821_set_pixel_format( dev, SRAM_CH01, pix_format ); | ||
325 | 327 | ||
326 | cx25821_set_pixel_format( dev, SRAM_CH01, pix_format ); | ||
327 | |||
328 | // check if cif resolution | 328 | // check if cif resolution |
329 | if (fh->width == 320 || fh->width == 352) | 329 | if (fh->width == 320 || fh->width == 352) |
330 | { | 330 | { |
331 | dev->use_cif_resolution[SRAM_CH01] = 1; | 331 | dev->use_cif_resolution[SRAM_CH01] = 1; |
332 | }else | 332 | }else |
333 | { | 333 | { |
334 | dev->use_cif_resolution[SRAM_CH01] = 0; | 334 | dev->use_cif_resolution[SRAM_CH01] = 0; |
335 | } | 335 | } |
336 | dev->cif_width[SRAM_CH01] = fh->width; | 336 | dev->cif_width[SRAM_CH01] = fh->width; |
337 | medusa_set_resolution( dev, fh->width, SRAM_CH01 ); | 337 | medusa_set_resolution( dev, fh->width, SRAM_CH01 ); |
338 | 338 | ||
339 | dprintk(2, "%s() width=%d height=%d field=%d\n", __func__, fh->width, fh->height, fh->vidq.field); | 339 | dprintk(2, "%s() width=%d height=%d field=%d\n", __func__, fh->width, fh->height, fh->vidq.field); |
340 | cx25821_call_all(dev, video, s_fmt, f); | 340 | cx25821_call_all(dev, video, s_fmt, f); |
@@ -348,7 +348,7 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p) | |||
348 | struct cx25821_fh *fh = priv; | 348 | struct cx25821_fh *fh = priv; |
349 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 349 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
350 | 350 | ||
351 | ret_val = videobuf_dqbuf(get_queue(fh), p, file->f_flags & O_NONBLOCK); | 351 | ret_val = videobuf_dqbuf(get_queue(fh), p, file->f_flags & O_NONBLOCK); |
352 | 352 | ||
353 | p->sequence = dev->vidq[SRAM_CH01].count; | 353 | p->sequence = dev->vidq[SRAM_CH01].count; |
354 | 354 | ||
@@ -360,7 +360,7 @@ static int vidioc_log_status (struct file *file, void *priv) | |||
360 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 360 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
361 | char name[32 + 2]; | 361 | char name[32 + 2]; |
362 | 362 | ||
363 | struct sram_channel *sram_ch = &dev->sram_channels[SRAM_CH01]; | 363 | struct sram_channel *sram_ch = &dev->sram_channels[SRAM_CH01]; |
364 | u32 tmp = 0; | 364 | u32 tmp = 0; |
365 | 365 | ||
366 | snprintf(name, sizeof(name), "%s/2", dev->name); | 366 | snprintf(name, sizeof(name), "%s/2", dev->name); |
@@ -378,10 +378,10 @@ static int vidioc_s_ctrl(struct file *file, void *priv, | |||
378 | struct v4l2_control *ctl) | 378 | struct v4l2_control *ctl) |
379 | { | 379 | { |
380 | struct cx25821_fh *fh = priv; | 380 | struct cx25821_fh *fh = priv; |
381 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 381 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
382 | int err; | 382 | int err; |
383 | 383 | ||
384 | if (fh) { | 384 | if (fh) { |
385 | err = v4l2_prio_check(&dev->prio, &fh->prio); | 385 | err = v4l2_prio_check(&dev->prio, &fh->prio); |
386 | if (0 != err) | 386 | if (0 != err) |
387 | return err; | 387 | return err; |
@@ -397,7 +397,7 @@ static const struct v4l2_file_operations video_fops = { | |||
397 | .read = video_read, | 397 | .read = video_read, |
398 | .poll = video_poll, | 398 | .poll = video_poll, |
399 | .mmap = video_mmap, | 399 | .mmap = video_mmap, |
400 | .ioctl = video_ioctl2, | 400 | .ioctl = video_ioctl2, |
401 | }; | 401 | }; |
402 | 402 | ||
403 | static const struct v4l2_ioctl_ops video_ioctl_ops = { | 403 | static const struct v4l2_ioctl_ops video_ioctl_ops = { |
diff --git a/drivers/staging/cx25821/cx25821-video2.c b/drivers/staging/cx25821/cx25821-video2.c index 98db1488dcf..10df4f981f3 100644 --- a/drivers/staging/cx25821/cx25821-video2.c +++ b/drivers/staging/cx25821/cx25821-video2.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the Conexant CX25821 PCIe bridge | 2 | * Driver for the Conexant CX25821 PCIe bridge |
3 | * | 3 | * |
4 | * Copyright (C) 2009 Conexant Systems Inc. | 4 | * Copyright (C) 2009 Conexant Systems Inc. |
5 | * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com> | 5 | * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com> |
6 | * Based on Steven Toth <stoth@linuxtv.org> cx23885 driver | 6 | * Based on Steven Toth <stoth@linuxtv.org> cx23885 driver |
7 | * | 7 | * |
@@ -41,37 +41,37 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) | |||
41 | dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]); | 41 | dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]); |
42 | 42 | ||
43 | if (!list_empty(&q->queued)) { | 43 | if (!list_empty(&q->queued)) { |
44 | list_add_tail(&buf->vb.queue, &q->queued); | 44 | list_add_tail(&buf->vb.queue, &q->queued); |
45 | buf->vb.state = VIDEOBUF_QUEUED; | 45 | buf->vb.state = VIDEOBUF_QUEUED; |
46 | dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i); | 46 | dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i); |
47 | 47 | ||
48 | } else if (list_empty(&q->active)) { | 48 | } else if (list_empty(&q->active)) { |
49 | list_add_tail(&buf->vb.queue, &q->active); | 49 | list_add_tail(&buf->vb.queue, &q->active); |
50 | cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH02]); | 50 | cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH02]); |
51 | buf->vb.state = VIDEOBUF_ACTIVE; | 51 | buf->vb.state = VIDEOBUF_ACTIVE; |
52 | buf->count = q->count++; | 52 | buf->count = q->count++; |
53 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); | 53 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); |
54 | dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n", | 54 | dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n", |
55 | buf, buf->vb. i, buf->count, q->count); | 55 | buf, buf->vb. i, buf->count, q->count); |
56 | } else { | 56 | } else { |
57 | prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue); | 57 | prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue); |
58 | if (prev->vb.width == buf->vb.width && | 58 | if (prev->vb.width == buf->vb.width && |
59 | prev->vb.height == buf->vb.height && | 59 | prev->vb.height == buf->vb.height && |
60 | prev->fmt == buf->fmt) { | 60 | prev->fmt == buf->fmt) { |
61 | list_add_tail(&buf->vb.queue, &q->active); | 61 | list_add_tail(&buf->vb.queue, &q->active); |
62 | buf->vb.state = VIDEOBUF_ACTIVE; | 62 | buf->vb.state = VIDEOBUF_ACTIVE; |
63 | buf->count = q->count++; | 63 | buf->count = q->count++; |
64 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); | 64 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); |
65 | 65 | ||
66 | /* 64 bit bits 63-32 */ | 66 | /* 64 bit bits 63-32 */ |
67 | prev->risc.jmp[2] = cpu_to_le32(0); | 67 | prev->risc.jmp[2] = cpu_to_le32(0); |
68 | dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count); | 68 | dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count); |
69 | 69 | ||
70 | } else { | 70 | } else { |
71 | list_add_tail(&buf->vb.queue, &q->queued); | 71 | list_add_tail(&buf->vb.queue, &q->queued); |
72 | buf->vb.state = VIDEOBUF_QUEUED; | 72 | buf->vb.state = VIDEOBUF_QUEUED; |
73 | dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i); | 73 | dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i); |
74 | } | 74 | } |
75 | } | 75 | } |
76 | 76 | ||
77 | if (list_empty(&q->active)) | 77 | if (list_empty(&q->active)) |
@@ -101,17 +101,17 @@ static int video_open(struct file *file) | |||
101 | lock_kernel(); | 101 | lock_kernel(); |
102 | list_for_each(list, &cx25821_devlist) | 102 | list_for_each(list, &cx25821_devlist) |
103 | { | 103 | { |
104 | h = list_entry(list, struct cx25821_dev, devlist); | 104 | h = list_entry(list, struct cx25821_dev, devlist); |
105 | 105 | ||
106 | if (h->video_dev[SRAM_CH02] && h->video_dev[SRAM_CH02]->minor == minor) { | 106 | if (h->video_dev[SRAM_CH02] && h->video_dev[SRAM_CH02]->minor == minor) { |
107 | dev = h; | 107 | dev = h; |
108 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 108 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
109 | } | 109 | } |
110 | } | 110 | } |
111 | 111 | ||
112 | if (NULL == dev) { | 112 | if (NULL == dev) { |
113 | unlock_kernel(); | 113 | unlock_kernel(); |
114 | return -ENODEV; | 114 | return -ENODEV; |
115 | } | 115 | } |
116 | 116 | ||
117 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); | 117 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); |
@@ -119,8 +119,8 @@ static int video_open(struct file *file) | |||
119 | /* allocate + initialize per filehandle data */ | 119 | /* allocate + initialize per filehandle data */ |
120 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); | 120 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); |
121 | if (NULL == fh) { | 121 | if (NULL == fh) { |
122 | unlock_kernel(); | 122 | unlock_kernel(); |
123 | return -ENOMEM; | 123 | return -ENOMEM; |
124 | } | 124 | } |
125 | file->private_data = fh; | 125 | file->private_data = fh; |
126 | fh->dev = dev; | 126 | fh->dev = dev; |
@@ -128,9 +128,9 @@ static int video_open(struct file *file) | |||
128 | fh->width = 720; | 128 | fh->width = 720; |
129 | 129 | ||
130 | if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) | 130 | if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) |
131 | fh->height = 576; | 131 | fh->height = 576; |
132 | else | 132 | else |
133 | fh->height = 480; | 133 | fh->height = 480; |
134 | 134 | ||
135 | dev->channel_opened = SRAM_CH02; | 135 | dev->channel_opened = SRAM_CH02; |
136 | pix_format = (dev->pixel_formats[dev->channel_opened] == PIXEL_FRMT_411) ? V4L2_PIX_FMT_Y41P : V4L2_PIX_FMT_YUYV; | 136 | pix_format = (dev->pixel_formats[dev->channel_opened] == PIXEL_FRMT_411) ? V4L2_PIX_FMT_Y41P : V4L2_PIX_FMT_YUYV; |
@@ -139,11 +139,11 @@ static int video_open(struct file *file) | |||
139 | v4l2_prio_open(&dev->prio,&fh->prio); | 139 | v4l2_prio_open(&dev->prio,&fh->prio); |
140 | 140 | ||
141 | videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops, | 141 | videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops, |
142 | &dev->pci->dev, &dev->slock, | 142 | &dev->pci->dev, &dev->slock, |
143 | V4L2_BUF_TYPE_VIDEO_CAPTURE, | 143 | V4L2_BUF_TYPE_VIDEO_CAPTURE, |
144 | V4L2_FIELD_INTERLACED, | 144 | V4L2_FIELD_INTERLACED, |
145 | sizeof(struct cx25821_buffer), | 145 | sizeof(struct cx25821_buffer), |
146 | fh); | 146 | fh); |
147 | 147 | ||
148 | dprintk(1, "post videobuf_queue_init()\n"); | 148 | dprintk(1, "post videobuf_queue_init()\n"); |
149 | unlock_kernel(); | 149 | unlock_kernel(); |
@@ -157,15 +157,15 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo | |||
157 | 157 | ||
158 | switch (fh->type) | 158 | switch (fh->type) |
159 | { | 159 | { |
160 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 160 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
161 | if (res_locked(fh->dev, RESOURCE_VIDEO2)) | 161 | if (res_locked(fh->dev, RESOURCE_VIDEO2)) |
162 | return -EBUSY; | 162 | return -EBUSY; |
163 | 163 | ||
164 | return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK); | 164 | return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK); |
165 | 165 | ||
166 | default: | 166 | default: |
167 | BUG(); | 167 | BUG(); |
168 | return 0; | 168 | return 0; |
169 | } | 169 | } |
170 | } | 170 | } |
171 | 171 | ||
@@ -175,36 +175,36 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait | |||
175 | struct cx25821_buffer *buf; | 175 | struct cx25821_buffer *buf; |
176 | 176 | ||
177 | if (res_check(fh, RESOURCE_VIDEO2)) { | 177 | if (res_check(fh, RESOURCE_VIDEO2)) { |
178 | /* streaming capture */ | 178 | /* streaming capture */ |
179 | if (list_empty(&fh->vidq.stream)) | 179 | if (list_empty(&fh->vidq.stream)) |
180 | return POLLERR; | 180 | return POLLERR; |
181 | buf = list_entry(fh->vidq.stream.next, | 181 | buf = list_entry(fh->vidq.stream.next, |
182 | struct cx25821_buffer, vb.stream); | 182 | struct cx25821_buffer, vb.stream); |
183 | } else { | 183 | } else { |
184 | /* read() capture */ | 184 | /* read() capture */ |
185 | buf = (struct cx25821_buffer *)fh->vidq.read_buf; | 185 | buf = (struct cx25821_buffer *)fh->vidq.read_buf; |
186 | if (NULL == buf) | 186 | if (NULL == buf) |
187 | return POLLERR; | 187 | return POLLERR; |
188 | } | 188 | } |
189 | 189 | ||
190 | poll_wait(file, &buf->vb.done, wait); | 190 | poll_wait(file, &buf->vb.done, wait); |
191 | if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR) | 191 | if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR) |
192 | { | 192 | { |
193 | if( buf->vb.state == VIDEOBUF_DONE ) | 193 | if( buf->vb.state == VIDEOBUF_DONE ) |
194 | { | 194 | { |
195 | struct cx25821_dev *dev = fh->dev; | 195 | struct cx25821_dev *dev = fh->dev; |
196 | 196 | ||
197 | if( dev && dev->use_cif_resolution[SRAM_CH02] ) | 197 | if( dev && dev->use_cif_resolution[SRAM_CH02] ) |
198 | { | 198 | { |
199 | u8 cam_id = *((char*)buf->vb.baddr+3); | 199 | u8 cam_id = *((char*)buf->vb.baddr+3); |
200 | memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2)); | 200 | memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2)); |
201 | *((char*)buf->vb.baddr+3) = cam_id; | 201 | *((char*)buf->vb.baddr+3) = cam_id; |
202 | } | 202 | } |
203 | } | 203 | } |
204 | 204 | ||
205 | return POLLIN|POLLRDNORM; | 205 | return POLLIN|POLLRDNORM; |
206 | } | 206 | } |
207 | 207 | ||
208 | return 0; | 208 | return 0; |
209 | } | 209 | } |
210 | 210 | ||
@@ -219,13 +219,13 @@ static int video_release(struct file *file) | |||
219 | 219 | ||
220 | /* stop video capture */ | 220 | /* stop video capture */ |
221 | if (res_check(fh, RESOURCE_VIDEO2)) { | 221 | if (res_check(fh, RESOURCE_VIDEO2)) { |
222 | videobuf_queue_cancel(&fh->vidq); | 222 | videobuf_queue_cancel(&fh->vidq); |
223 | res_free(dev, fh, RESOURCE_VIDEO2); | 223 | res_free(dev, fh, RESOURCE_VIDEO2); |
224 | } | 224 | } |
225 | 225 | ||
226 | if (fh->vidq.read_buf) { | 226 | if (fh->vidq.read_buf) { |
227 | buffer_release(&fh->vidq, fh->vidq.read_buf); | 227 | buffer_release(&fh->vidq, fh->vidq.read_buf); |
228 | kfree(fh->vidq.read_buf); | 228 | kfree(fh->vidq.read_buf); |
229 | } | 229 | } |
230 | 230 | ||
231 | videobuf_mmap_free(&fh->vidq); | 231 | videobuf_mmap_free(&fh->vidq); |
@@ -245,17 +245,17 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) | |||
245 | 245 | ||
246 | if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) | 246 | if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) |
247 | { | 247 | { |
248 | return -EINVAL; | 248 | return -EINVAL; |
249 | } | 249 | } |
250 | 250 | ||
251 | if (unlikely(i != fh->type)) | 251 | if (unlikely(i != fh->type)) |
252 | { | 252 | { |
253 | return -EINVAL; | 253 | return -EINVAL; |
254 | } | 254 | } |
255 | 255 | ||
256 | if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO2)))) | 256 | if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO2)))) |
257 | { | 257 | { |
258 | return -EBUSY; | 258 | return -EBUSY; |
259 | } | 259 | } |
260 | 260 | ||
261 | return videobuf_streamon(get_queue(fh)); | 261 | return videobuf_streamon(get_queue(fh)); |
@@ -268,14 +268,14 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) | |||
268 | int err, res; | 268 | int err, res; |
269 | 269 | ||
270 | if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 270 | if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
271 | return -EINVAL; | 271 | return -EINVAL; |
272 | if (i != fh->type) | 272 | if (i != fh->type) |
273 | return -EINVAL; | 273 | return -EINVAL; |
274 | 274 | ||
275 | res = get_resource(fh, RESOURCE_VIDEO2); | 275 | res = get_resource(fh, RESOURCE_VIDEO2); |
276 | err = videobuf_streamoff(get_queue(fh)); | 276 | err = videobuf_streamoff(get_queue(fh)); |
277 | if (err < 0) | 277 | if (err < 0) |
278 | return err; | 278 | return err; |
279 | res_free(dev, fh, res); | 279 | res_free(dev, fh, res); |
280 | return 0; | 280 | return 0; |
281 | } | 281 | } |
@@ -286,21 +286,21 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma | |||
286 | { | 286 | { |
287 | struct cx25821_fh *fh = priv; | 287 | struct cx25821_fh *fh = priv; |
288 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 288 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
289 | int err; | 289 | int err; |
290 | int pix_format = 0; | 290 | int pix_format = 0; |
291 | 291 | ||
292 | if (fh) | 292 | if (fh) |
293 | { | 293 | { |
294 | err = v4l2_prio_check(&dev->prio, &fh->prio); | 294 | err = v4l2_prio_check(&dev->prio, &fh->prio); |
295 | if (0 != err) | 295 | if (0 != err) |
296 | return err; | 296 | return err; |
297 | } | 297 | } |
298 | 298 | ||
299 | dprintk(2, "%s()\n", __func__); | 299 | dprintk(2, "%s()\n", __func__); |
300 | err = vidioc_try_fmt_vid_cap(file, priv, f); | 300 | err = vidioc_try_fmt_vid_cap(file, priv, f); |
301 | 301 | ||
302 | if (0 != err) | 302 | if (0 != err) |
303 | return err; | 303 | return err; |
304 | 304 | ||
305 | fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); | 305 | fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); |
306 | fh->vidq.field = f->fmt.pix.field; | 306 | fh->vidq.field = f->fmt.pix.field; |
@@ -308,33 +308,33 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma | |||
308 | // check if width and height is valid based on set standard | 308 | // check if width and height is valid based on set standard |
309 | if (is_valid_width(f->fmt.pix.width, dev->tvnorm)) | 309 | if (is_valid_width(f->fmt.pix.width, dev->tvnorm)) |
310 | { | 310 | { |
311 | fh->width = f->fmt.pix.width; | 311 | fh->width = f->fmt.pix.width; |
312 | } | 312 | } |
313 | 313 | ||
314 | if (is_valid_height(f->fmt.pix.height, dev->tvnorm)) | 314 | if (is_valid_height(f->fmt.pix.height, dev->tvnorm)) |
315 | { | 315 | { |
316 | fh->height = f->fmt.pix.height; | 316 | fh->height = f->fmt.pix.height; |
317 | } | 317 | } |
318 | 318 | ||
319 | if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P) | 319 | if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P) |
320 | pix_format = PIXEL_FRMT_411; | 320 | pix_format = PIXEL_FRMT_411; |
321 | else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV) | 321 | else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV) |
322 | pix_format = PIXEL_FRMT_422; | 322 | pix_format = PIXEL_FRMT_422; |
323 | else | 323 | else |
324 | return -EINVAL; | 324 | return -EINVAL; |
325 | |||
326 | cx25821_set_pixel_format( dev, SRAM_CH02, pix_format ); | ||
325 | 327 | ||
326 | cx25821_set_pixel_format( dev, SRAM_CH02, pix_format ); | ||
327 | |||
328 | // check if cif resolution | 328 | // check if cif resolution |
329 | if (fh->width == 320 || fh->width == 352) | 329 | if (fh->width == 320 || fh->width == 352) |
330 | { | 330 | { |
331 | dev->use_cif_resolution[SRAM_CH02] = 1; | 331 | dev->use_cif_resolution[SRAM_CH02] = 1; |
332 | }else | 332 | }else |
333 | { | 333 | { |
334 | dev->use_cif_resolution[SRAM_CH02] = 0; | 334 | dev->use_cif_resolution[SRAM_CH02] = 0; |
335 | } | 335 | } |
336 | dev->cif_width[SRAM_CH02] = fh->width; | 336 | dev->cif_width[SRAM_CH02] = fh->width; |
337 | medusa_set_resolution( dev, fh->width, SRAM_CH02 ); | 337 | medusa_set_resolution( dev, fh->width, SRAM_CH02 ); |
338 | 338 | ||
339 | 339 | ||
340 | dprintk(2, "%s() width=%d height=%d field=%d\n", __func__, fh->width, fh->height, fh->vidq.field); | 340 | dprintk(2, "%s() width=%d height=%d field=%d\n", __func__, fh->width, fh->height, fh->vidq.field); |
@@ -349,7 +349,7 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p) | |||
349 | struct cx25821_fh *fh = priv; | 349 | struct cx25821_fh *fh = priv; |
350 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 350 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
351 | 351 | ||
352 | ret_val = videobuf_dqbuf(get_queue(fh), p, file->f_flags & O_NONBLOCK); | 352 | ret_val = videobuf_dqbuf(get_queue(fh), p, file->f_flags & O_NONBLOCK); |
353 | 353 | ||
354 | p->sequence = dev->vidq[SRAM_CH02].count; | 354 | p->sequence = dev->vidq[SRAM_CH02].count; |
355 | 355 | ||
@@ -361,15 +361,15 @@ static int vidioc_log_status (struct file *file, void *priv) | |||
361 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 361 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
362 | char name[32 + 2]; | 362 | char name[32 + 2]; |
363 | 363 | ||
364 | struct sram_channel *sram_ch = &dev->sram_channels[SRAM_CH02]; | 364 | struct sram_channel *sram_ch = &dev->sram_channels[SRAM_CH02]; |
365 | u32 tmp = 0; | 365 | u32 tmp = 0; |
366 | 366 | ||
367 | snprintf(name, sizeof(name), "%s/2", dev->name); | 367 | snprintf(name, sizeof(name), "%s/2", dev->name); |
368 | printk(KERN_INFO "%s/2: ============ START LOG STATUS ============\n", | 368 | printk(KERN_INFO "%s/2: ============ START LOG STATUS ============\n", |
369 | dev->name); | 369 | dev->name); |
370 | 370 | ||
371 | cx25821_call_all(dev, core, log_status); | 371 | cx25821_call_all(dev, core, log_status); |
372 | 372 | ||
373 | tmp = cx_read(sram_ch->dma_ctl); | 373 | tmp = cx_read(sram_ch->dma_ctl); |
374 | printk(KERN_INFO "Video input 2 is %s\n", (tmp & 0x11)?"streaming" : "stopped"); | 374 | printk(KERN_INFO "Video input 2 is %s\n", (tmp & 0x11)?"streaming" : "stopped"); |
375 | printk(KERN_INFO "%s/2: ============= END LOG STATUS =============\n", | 375 | printk(KERN_INFO "%s/2: ============= END LOG STATUS =============\n", |
@@ -381,10 +381,10 @@ static int vidioc_s_ctrl(struct file *file, void *priv, | |||
381 | struct v4l2_control *ctl) | 381 | struct v4l2_control *ctl) |
382 | { | 382 | { |
383 | struct cx25821_fh *fh = priv; | 383 | struct cx25821_fh *fh = priv; |
384 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 384 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
385 | int err; | 385 | int err; |
386 | 386 | ||
387 | if (fh) { | 387 | if (fh) { |
388 | err = v4l2_prio_check(&dev->prio, &fh->prio); | 388 | err = v4l2_prio_check(&dev->prio, &fh->prio); |
389 | if (0 != err) | 389 | if (0 != err) |
390 | return err; | 390 | return err; |
diff --git a/drivers/staging/cx25821/cx25821-video3.c b/drivers/staging/cx25821/cx25821-video3.c index 3dcecd26466..2191152d78c 100644 --- a/drivers/staging/cx25821/cx25821-video3.c +++ b/drivers/staging/cx25821/cx25821-video3.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the Conexant CX25821 PCIe bridge | 2 | * Driver for the Conexant CX25821 PCIe bridge |
3 | * | 3 | * |
4 | * Copyright (C) 2009 Conexant Systems Inc. | 4 | * Copyright (C) 2009 Conexant Systems Inc. |
5 | * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com> | 5 | * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com> |
6 | * Based on Steven Toth <stoth@linuxtv.org> cx23885 driver | 6 | * Based on Steven Toth <stoth@linuxtv.org> cx23885 driver |
7 | * | 7 | * |
@@ -41,37 +41,37 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) | |||
41 | dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]); | 41 | dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]); |
42 | 42 | ||
43 | if (!list_empty(&q->queued)) { | 43 | if (!list_empty(&q->queued)) { |
44 | list_add_tail(&buf->vb.queue, &q->queued); | 44 | list_add_tail(&buf->vb.queue, &q->queued); |
45 | buf->vb.state = VIDEOBUF_QUEUED; | 45 | buf->vb.state = VIDEOBUF_QUEUED; |
46 | dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i); | 46 | dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i); |
47 | 47 | ||
48 | } else if (list_empty(&q->active)) { | 48 | } else if (list_empty(&q->active)) { |
49 | list_add_tail(&buf->vb.queue, &q->active); | 49 | list_add_tail(&buf->vb.queue, &q->active); |
50 | cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH03]); | 50 | cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH03]); |
51 | buf->vb.state = VIDEOBUF_ACTIVE; | 51 | buf->vb.state = VIDEOBUF_ACTIVE; |
52 | buf->count = q->count++; | 52 | buf->count = q->count++; |
53 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); | 53 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); |
54 | dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n", | 54 | dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n", |
55 | buf, buf->vb. i, buf->count, q->count); | 55 | buf, buf->vb. i, buf->count, q->count); |
56 | } else { | 56 | } else { |
57 | prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue); | 57 | prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue); |
58 | if (prev->vb.width == buf->vb.width && | 58 | if (prev->vb.width == buf->vb.width && |
59 | prev->vb.height == buf->vb.height && | 59 | prev->vb.height == buf->vb.height && |
60 | prev->fmt == buf->fmt) { | 60 | prev->fmt == buf->fmt) { |
61 | list_add_tail(&buf->vb.queue, &q->active); | 61 | list_add_tail(&buf->vb.queue, &q->active); |
62 | buf->vb.state = VIDEOBUF_ACTIVE; | 62 | buf->vb.state = VIDEOBUF_ACTIVE; |
63 | buf->count = q->count++; | 63 | buf->count = q->count++; |
64 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); | 64 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); |
65 | 65 | ||
66 | /* 64 bit bits 63-32 */ | 66 | /* 64 bit bits 63-32 */ |
67 | prev->risc.jmp[2] = cpu_to_le32(0); | 67 | prev->risc.jmp[2] = cpu_to_le32(0); |
68 | dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count); | 68 | dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count); |
69 | 69 | ||
70 | } else { | 70 | } else { |
71 | list_add_tail(&buf->vb.queue, &q->queued); | 71 | list_add_tail(&buf->vb.queue, &q->queued); |
72 | buf->vb.state = VIDEOBUF_QUEUED; | 72 | buf->vb.state = VIDEOBUF_QUEUED; |
73 | dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i); | 73 | dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i); |
74 | } | 74 | } |
75 | } | 75 | } |
76 | 76 | ||
77 | if (list_empty(&q->active)) | 77 | if (list_empty(&q->active)) |
@@ -101,17 +101,17 @@ static int video_open(struct file *file) | |||
101 | lock_kernel(); | 101 | lock_kernel(); |
102 | list_for_each(list, &cx25821_devlist) | 102 | list_for_each(list, &cx25821_devlist) |
103 | { | 103 | { |
104 | h = list_entry(list, struct cx25821_dev, devlist); | 104 | h = list_entry(list, struct cx25821_dev, devlist); |
105 | 105 | ||
106 | if (h->video_dev[SRAM_CH03] && h->video_dev[SRAM_CH03]->minor == minor) { | 106 | if (h->video_dev[SRAM_CH03] && h->video_dev[SRAM_CH03]->minor == minor) { |
107 | dev = h; | 107 | dev = h; |
108 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 108 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
109 | } | 109 | } |
110 | } | 110 | } |
111 | 111 | ||
112 | if (NULL == dev) { | 112 | if (NULL == dev) { |
113 | unlock_kernel(); | 113 | unlock_kernel(); |
114 | return -ENODEV; | 114 | return -ENODEV; |
115 | } | 115 | } |
116 | 116 | ||
117 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); | 117 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); |
@@ -119,8 +119,8 @@ static int video_open(struct file *file) | |||
119 | /* allocate + initialize per filehandle data */ | 119 | /* allocate + initialize per filehandle data */ |
120 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); | 120 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); |
121 | if (NULL == fh) { | 121 | if (NULL == fh) { |
122 | unlock_kernel(); | 122 | unlock_kernel(); |
123 | return -ENOMEM; | 123 | return -ENOMEM; |
124 | } | 124 | } |
125 | file->private_data = fh; | 125 | file->private_data = fh; |
126 | fh->dev = dev; | 126 | fh->dev = dev; |
@@ -128,9 +128,9 @@ static int video_open(struct file *file) | |||
128 | fh->width = 720; | 128 | fh->width = 720; |
129 | 129 | ||
130 | if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) | 130 | if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) |
131 | fh->height = 576; | 131 | fh->height = 576; |
132 | else | 132 | else |
133 | fh->height = 480; | 133 | fh->height = 480; |
134 | 134 | ||
135 | dev->channel_opened = SRAM_CH03; | 135 | dev->channel_opened = SRAM_CH03; |
136 | pix_format = (dev->pixel_formats[dev->channel_opened] == PIXEL_FRMT_411) ? V4L2_PIX_FMT_Y41P : V4L2_PIX_FMT_YUYV; | 136 | pix_format = (dev->pixel_formats[dev->channel_opened] == PIXEL_FRMT_411) ? V4L2_PIX_FMT_Y41P : V4L2_PIX_FMT_YUYV; |
@@ -139,11 +139,11 @@ static int video_open(struct file *file) | |||
139 | v4l2_prio_open(&dev->prio,&fh->prio); | 139 | v4l2_prio_open(&dev->prio,&fh->prio); |
140 | 140 | ||
141 | videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops, | 141 | videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops, |
142 | &dev->pci->dev, &dev->slock, | 142 | &dev->pci->dev, &dev->slock, |
143 | V4L2_BUF_TYPE_VIDEO_CAPTURE, | 143 | V4L2_BUF_TYPE_VIDEO_CAPTURE, |
144 | V4L2_FIELD_INTERLACED, | 144 | V4L2_FIELD_INTERLACED, |
145 | sizeof(struct cx25821_buffer), | 145 | sizeof(struct cx25821_buffer), |
146 | fh); | 146 | fh); |
147 | 147 | ||
148 | dprintk(1, "post videobuf_queue_init()\n"); | 148 | dprintk(1, "post videobuf_queue_init()\n"); |
149 | unlock_kernel(); | 149 | unlock_kernel(); |
@@ -157,15 +157,15 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo | |||
157 | 157 | ||
158 | switch (fh->type) | 158 | switch (fh->type) |
159 | { | 159 | { |
160 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 160 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
161 | if (res_locked(fh->dev, RESOURCE_VIDEO3)) | 161 | if (res_locked(fh->dev, RESOURCE_VIDEO3)) |
162 | return -EBUSY; | 162 | return -EBUSY; |
163 | 163 | ||
164 | return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK); | 164 | return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK); |
165 | 165 | ||
166 | default: | 166 | default: |
167 | BUG(); | 167 | BUG(); |
168 | return 0; | 168 | return 0; |
169 | } | 169 | } |
170 | } | 170 | } |
171 | 171 | ||
@@ -175,36 +175,36 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait | |||
175 | struct cx25821_buffer *buf; | 175 | struct cx25821_buffer *buf; |
176 | 176 | ||
177 | if (res_check(fh, RESOURCE_VIDEO3)) { | 177 | if (res_check(fh, RESOURCE_VIDEO3)) { |
178 | /* streaming capture */ | 178 | /* streaming capture */ |
179 | if (list_empty(&fh->vidq.stream)) | 179 | if (list_empty(&fh->vidq.stream)) |
180 | return POLLERR; | 180 | return POLLERR; |
181 | buf = list_entry(fh->vidq.stream.next, | 181 | buf = list_entry(fh->vidq.stream.next, |
182 | struct cx25821_buffer, vb.stream); | 182 | struct cx25821_buffer, vb.stream); |
183 | } else { | 183 | } else { |
184 | /* read() capture */ | 184 | /* read() capture */ |
185 | buf = (struct cx25821_buffer *)fh->vidq.read_buf; | 185 | buf = (struct cx25821_buffer *)fh->vidq.read_buf; |
186 | if (NULL == buf) | 186 | if (NULL == buf) |
187 | return POLLERR; | 187 | return POLLERR; |
188 | } | 188 | } |
189 | 189 | ||
190 | poll_wait(file, &buf->vb.done, wait); | 190 | poll_wait(file, &buf->vb.done, wait); |
191 | if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR) | 191 | if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR) |
192 | { | 192 | { |
193 | if( buf->vb.state == VIDEOBUF_DONE ) | 193 | if( buf->vb.state == VIDEOBUF_DONE ) |
194 | { | 194 | { |
195 | struct cx25821_dev *dev = fh->dev; | 195 | struct cx25821_dev *dev = fh->dev; |
196 | 196 | ||
197 | if( dev && dev->use_cif_resolution[SRAM_CH03] ) | 197 | if( dev && dev->use_cif_resolution[SRAM_CH03] ) |
198 | { | 198 | { |
199 | u8 cam_id = *((char*)buf->vb.baddr+3); | 199 | u8 cam_id = *((char*)buf->vb.baddr+3); |
200 | memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2)); | 200 | memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2)); |
201 | *((char*)buf->vb.baddr+3) = cam_id; | 201 | *((char*)buf->vb.baddr+3) = cam_id; |
202 | } | 202 | } |
203 | } | 203 | } |
204 | 204 | ||
205 | return POLLIN|POLLRDNORM; | 205 | return POLLIN|POLLRDNORM; |
206 | } | 206 | } |
207 | 207 | ||
208 | return 0; | 208 | return 0; |
209 | } | 209 | } |
210 | 210 | ||
@@ -219,13 +219,13 @@ static int video_release(struct file *file) | |||
219 | 219 | ||
220 | /* stop video capture */ | 220 | /* stop video capture */ |
221 | if (res_check(fh, RESOURCE_VIDEO3)) { | 221 | if (res_check(fh, RESOURCE_VIDEO3)) { |
222 | videobuf_queue_cancel(&fh->vidq); | 222 | videobuf_queue_cancel(&fh->vidq); |
223 | res_free(dev, fh, RESOURCE_VIDEO3); | 223 | res_free(dev, fh, RESOURCE_VIDEO3); |
224 | } | 224 | } |
225 | 225 | ||
226 | if (fh->vidq.read_buf) { | 226 | if (fh->vidq.read_buf) { |
227 | buffer_release(&fh->vidq, fh->vidq.read_buf); | 227 | buffer_release(&fh->vidq, fh->vidq.read_buf); |
228 | kfree(fh->vidq.read_buf); | 228 | kfree(fh->vidq.read_buf); |
229 | } | 229 | } |
230 | 230 | ||
231 | videobuf_mmap_free(&fh->vidq); | 231 | videobuf_mmap_free(&fh->vidq); |
@@ -245,17 +245,17 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) | |||
245 | 245 | ||
246 | if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) | 246 | if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) |
247 | { | 247 | { |
248 | return -EINVAL; | 248 | return -EINVAL; |
249 | } | 249 | } |
250 | 250 | ||
251 | if (unlikely(i != fh->type)) | 251 | if (unlikely(i != fh->type)) |
252 | { | 252 | { |
253 | return -EINVAL; | 253 | return -EINVAL; |
254 | } | 254 | } |
255 | 255 | ||
256 | if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO3)))) | 256 | if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO3)))) |
257 | { | 257 | { |
258 | return -EBUSY; | 258 | return -EBUSY; |
259 | } | 259 | } |
260 | 260 | ||
261 | return videobuf_streamon(get_queue(fh)); | 261 | return videobuf_streamon(get_queue(fh)); |
@@ -268,14 +268,14 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) | |||
268 | int err, res; | 268 | int err, res; |
269 | 269 | ||
270 | if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 270 | if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
271 | return -EINVAL; | 271 | return -EINVAL; |
272 | if (i != fh->type) | 272 | if (i != fh->type) |
273 | return -EINVAL; | 273 | return -EINVAL; |
274 | 274 | ||
275 | res = get_resource(fh, RESOURCE_VIDEO3); | 275 | res = get_resource(fh, RESOURCE_VIDEO3); |
276 | err = videobuf_streamoff(get_queue(fh)); | 276 | err = videobuf_streamoff(get_queue(fh)); |
277 | if (err < 0) | 277 | if (err < 0) |
278 | return err; | 278 | return err; |
279 | res_free(dev, fh, res); | 279 | res_free(dev, fh, res); |
280 | return 0; | 280 | return 0; |
281 | } | 281 | } |
@@ -286,21 +286,21 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma | |||
286 | { | 286 | { |
287 | struct cx25821_fh *fh = priv; | 287 | struct cx25821_fh *fh = priv; |
288 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 288 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
289 | int err; | 289 | int err; |
290 | int pix_format = 0; | 290 | int pix_format = 0; |
291 | 291 | ||
292 | if (fh) | 292 | if (fh) |
293 | { | 293 | { |
294 | err = v4l2_prio_check(&dev->prio, &fh->prio); | 294 | err = v4l2_prio_check(&dev->prio, &fh->prio); |
295 | if (0 != err) | 295 | if (0 != err) |
296 | return err; | 296 | return err; |
297 | } | 297 | } |
298 | 298 | ||
299 | dprintk(2, "%s()\n", __func__); | 299 | dprintk(2, "%s()\n", __func__); |
300 | err = vidioc_try_fmt_vid_cap(file, priv, f); | 300 | err = vidioc_try_fmt_vid_cap(file, priv, f); |
301 | 301 | ||
302 | if (0 != err) | 302 | if (0 != err) |
303 | return err; | 303 | return err; |
304 | 304 | ||
305 | fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); | 305 | fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); |
306 | fh->vidq.field = f->fmt.pix.field; | 306 | fh->vidq.field = f->fmt.pix.field; |
@@ -308,33 +308,33 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma | |||
308 | // check if width and height is valid based on set standard | 308 | // check if width and height is valid based on set standard |
309 | if (is_valid_width(f->fmt.pix.width, dev->tvnorm)) | 309 | if (is_valid_width(f->fmt.pix.width, dev->tvnorm)) |
310 | { | 310 | { |
311 | fh->width = f->fmt.pix.width; | 311 | fh->width = f->fmt.pix.width; |
312 | } | 312 | } |
313 | 313 | ||
314 | if (is_valid_height(f->fmt.pix.height, dev->tvnorm)) | 314 | if (is_valid_height(f->fmt.pix.height, dev->tvnorm)) |
315 | { | 315 | { |
316 | fh->height = f->fmt.pix.height; | 316 | fh->height = f->fmt.pix.height; |
317 | } | 317 | } |
318 | 318 | ||
319 | if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P) | 319 | if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P) |
320 | pix_format = PIXEL_FRMT_411; | 320 | pix_format = PIXEL_FRMT_411; |
321 | else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV) | 321 | else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV) |
322 | pix_format = PIXEL_FRMT_422; | 322 | pix_format = PIXEL_FRMT_422; |
323 | else | 323 | else |
324 | return -EINVAL; | 324 | return -EINVAL; |
325 | |||
326 | cx25821_set_pixel_format( dev, SRAM_CH03, pix_format ); | ||
325 | 327 | ||
326 | cx25821_set_pixel_format( dev, SRAM_CH03, pix_format ); | ||
327 | |||
328 | // check if cif resolution | 328 | // check if cif resolution |
329 | if (fh->width == 320 || fh->width == 352) | 329 | if (fh->width == 320 || fh->width == 352) |
330 | { | 330 | { |
331 | dev->use_cif_resolution[SRAM_CH03] = 1; | 331 | dev->use_cif_resolution[SRAM_CH03] = 1; |
332 | }else | 332 | }else |
333 | { | 333 | { |
334 | dev->use_cif_resolution[SRAM_CH03] = 0; | 334 | dev->use_cif_resolution[SRAM_CH03] = 0; |
335 | } | 335 | } |
336 | dev->cif_width[SRAM_CH03] = fh->width; | 336 | dev->cif_width[SRAM_CH03] = fh->width; |
337 | medusa_set_resolution( dev, fh->width, SRAM_CH03 ); | 337 | medusa_set_resolution( dev, fh->width, SRAM_CH03 ); |
338 | 338 | ||
339 | dprintk(2, "%s() width=%d height=%d field=%d\n", __func__, fh->width, fh->height, fh->vidq.field); | 339 | dprintk(2, "%s() width=%d height=%d field=%d\n", __func__, fh->width, fh->height, fh->vidq.field); |
340 | cx25821_call_all(dev, video, s_fmt, f); | 340 | cx25821_call_all(dev, video, s_fmt, f); |
@@ -348,7 +348,7 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p) | |||
348 | struct cx25821_fh *fh = priv; | 348 | struct cx25821_fh *fh = priv; |
349 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 349 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
350 | 350 | ||
351 | ret_val = videobuf_dqbuf(get_queue(fh), p, file->f_flags & O_NONBLOCK); | 351 | ret_val = videobuf_dqbuf(get_queue(fh), p, file->f_flags & O_NONBLOCK); |
352 | 352 | ||
353 | p->sequence = dev->vidq[SRAM_CH03].count; | 353 | p->sequence = dev->vidq[SRAM_CH03].count; |
354 | 354 | ||
@@ -360,7 +360,7 @@ static int vidioc_log_status (struct file *file, void *priv) | |||
360 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 360 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
361 | char name[32 + 2]; | 361 | char name[32 + 2]; |
362 | 362 | ||
363 | struct sram_channel *sram_ch = &dev->sram_channels[SRAM_CH03]; | 363 | struct sram_channel *sram_ch = &dev->sram_channels[SRAM_CH03]; |
364 | u32 tmp = 0; | 364 | u32 tmp = 0; |
365 | 365 | ||
366 | snprintf(name, sizeof(name), "%s/2", dev->name); | 366 | snprintf(name, sizeof(name), "%s/2", dev->name); |
@@ -379,10 +379,10 @@ static int vidioc_s_ctrl(struct file *file, void *priv, | |||
379 | struct v4l2_control *ctl) | 379 | struct v4l2_control *ctl) |
380 | { | 380 | { |
381 | struct cx25821_fh *fh = priv; | 381 | struct cx25821_fh *fh = priv; |
382 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 382 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
383 | int err; | 383 | int err; |
384 | 384 | ||
385 | if (fh) { | 385 | if (fh) { |
386 | err = v4l2_prio_check(&dev->prio, &fh->prio); | 386 | err = v4l2_prio_check(&dev->prio, &fh->prio); |
387 | if (0 != err) | 387 | if (0 != err) |
388 | return err; | 388 | return err; |
diff --git a/drivers/staging/cx25821/cx25821-video4.c b/drivers/staging/cx25821/cx25821-video4.c index 03da3642cc3..c1799d98135 100644 --- a/drivers/staging/cx25821/cx25821-video4.c +++ b/drivers/staging/cx25821/cx25821-video4.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the Conexant CX25821 PCIe bridge | 2 | * Driver for the Conexant CX25821 PCIe bridge |
3 | * | 3 | * |
4 | * Copyright (C) 2009 Conexant Systems Inc. | 4 | * Copyright (C) 2009 Conexant Systems Inc. |
5 | * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com> | 5 | * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com> |
6 | * Based on Steven Toth <stoth@linuxtv.org> cx23885 driver | 6 | * Based on Steven Toth <stoth@linuxtv.org> cx23885 driver |
7 | * | 7 | * |
@@ -40,37 +40,37 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) | |||
40 | dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]); | 40 | dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]); |
41 | 41 | ||
42 | if (!list_empty(&q->queued)) { | 42 | if (!list_empty(&q->queued)) { |
43 | list_add_tail(&buf->vb.queue, &q->queued); | 43 | list_add_tail(&buf->vb.queue, &q->queued); |
44 | buf->vb.state = VIDEOBUF_QUEUED; | 44 | buf->vb.state = VIDEOBUF_QUEUED; |
45 | dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i); | 45 | dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i); |
46 | 46 | ||
47 | } else if (list_empty(&q->active)) { | 47 | } else if (list_empty(&q->active)) { |
48 | list_add_tail(&buf->vb.queue, &q->active); | 48 | list_add_tail(&buf->vb.queue, &q->active); |
49 | cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH04]); | 49 | cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH04]); |
50 | buf->vb.state = VIDEOBUF_ACTIVE; | 50 | buf->vb.state = VIDEOBUF_ACTIVE; |
51 | buf->count = q->count++; | 51 | buf->count = q->count++; |
52 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); | 52 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); |
53 | dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n", | 53 | dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n", |
54 | buf, buf->vb. i, buf->count, q->count); | 54 | buf, buf->vb. i, buf->count, q->count); |
55 | } else { | 55 | } else { |
56 | prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue); | 56 | prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue); |
57 | if (prev->vb.width == buf->vb.width && | 57 | if (prev->vb.width == buf->vb.width && |
58 | prev->vb.height == buf->vb.height && | 58 | prev->vb.height == buf->vb.height && |
59 | prev->fmt == buf->fmt) { | 59 | prev->fmt == buf->fmt) { |
60 | list_add_tail(&buf->vb.queue, &q->active); | 60 | list_add_tail(&buf->vb.queue, &q->active); |
61 | buf->vb.state = VIDEOBUF_ACTIVE; | 61 | buf->vb.state = VIDEOBUF_ACTIVE; |
62 | buf->count = q->count++; | 62 | buf->count = q->count++; |
63 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); | 63 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); |
64 | 64 | ||
65 | /* 64 bit bits 63-32 */ | 65 | /* 64 bit bits 63-32 */ |
66 | prev->risc.jmp[2] = cpu_to_le32(0); | 66 | prev->risc.jmp[2] = cpu_to_le32(0); |
67 | dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count); | 67 | dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count); |
68 | 68 | ||
69 | } else { | 69 | } else { |
70 | list_add_tail(&buf->vb.queue, &q->queued); | 70 | list_add_tail(&buf->vb.queue, &q->queued); |
71 | buf->vb.state = VIDEOBUF_QUEUED; | 71 | buf->vb.state = VIDEOBUF_QUEUED; |
72 | dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i); | 72 | dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i); |
73 | } | 73 | } |
74 | } | 74 | } |
75 | 75 | ||
76 | if (list_empty(&q->active)) | 76 | if (list_empty(&q->active)) |
@@ -100,17 +100,17 @@ static int video_open(struct file *file) | |||
100 | lock_kernel(); | 100 | lock_kernel(); |
101 | list_for_each(list, &cx25821_devlist) | 101 | list_for_each(list, &cx25821_devlist) |
102 | { | 102 | { |
103 | h = list_entry(list, struct cx25821_dev, devlist); | 103 | h = list_entry(list, struct cx25821_dev, devlist); |
104 | 104 | ||
105 | if (h->video_dev[SRAM_CH04] && h->video_dev[SRAM_CH04]->minor == minor) { | 105 | if (h->video_dev[SRAM_CH04] && h->video_dev[SRAM_CH04]->minor == minor) { |
106 | dev = h; | 106 | dev = h; |
107 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 107 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
108 | } | 108 | } |
109 | } | 109 | } |
110 | 110 | ||
111 | if (NULL == dev) { | 111 | if (NULL == dev) { |
112 | unlock_kernel(); | 112 | unlock_kernel(); |
113 | return -ENODEV; | 113 | return -ENODEV; |
114 | } | 114 | } |
115 | 115 | ||
116 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); | 116 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); |
@@ -118,8 +118,8 @@ static int video_open(struct file *file) | |||
118 | /* allocate + initialize per filehandle data */ | 118 | /* allocate + initialize per filehandle data */ |
119 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); | 119 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); |
120 | if (NULL == fh) { | 120 | if (NULL == fh) { |
121 | unlock_kernel(); | 121 | unlock_kernel(); |
122 | return -ENOMEM; | 122 | return -ENOMEM; |
123 | } | 123 | } |
124 | file->private_data = fh; | 124 | file->private_data = fh; |
125 | fh->dev = dev; | 125 | fh->dev = dev; |
@@ -127,9 +127,9 @@ static int video_open(struct file *file) | |||
127 | fh->width = 720; | 127 | fh->width = 720; |
128 | 128 | ||
129 | if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) | 129 | if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) |
130 | fh->height = 576; | 130 | fh->height = 576; |
131 | else | 131 | else |
132 | fh->height = 480; | 132 | fh->height = 480; |
133 | 133 | ||
134 | dev->channel_opened = SRAM_CH04; | 134 | dev->channel_opened = SRAM_CH04; |
135 | pix_format = (dev->pixel_formats[dev->channel_opened] == PIXEL_FRMT_411) ? V4L2_PIX_FMT_Y41P : V4L2_PIX_FMT_YUYV; | 135 | pix_format = (dev->pixel_formats[dev->channel_opened] == PIXEL_FRMT_411) ? V4L2_PIX_FMT_Y41P : V4L2_PIX_FMT_YUYV; |
@@ -137,11 +137,11 @@ static int video_open(struct file *file) | |||
137 | 137 | ||
138 | v4l2_prio_open(&dev->prio,&fh->prio); | 138 | v4l2_prio_open(&dev->prio,&fh->prio); |
139 | videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops, | 139 | videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops, |
140 | &dev->pci->dev, &dev->slock, | 140 | &dev->pci->dev, &dev->slock, |
141 | V4L2_BUF_TYPE_VIDEO_CAPTURE, | 141 | V4L2_BUF_TYPE_VIDEO_CAPTURE, |
142 | V4L2_FIELD_INTERLACED, | 142 | V4L2_FIELD_INTERLACED, |
143 | sizeof(struct cx25821_buffer), | 143 | sizeof(struct cx25821_buffer), |
144 | fh); | 144 | fh); |
145 | 145 | ||
146 | dprintk(1, "post videobuf_queue_init()\n"); | 146 | dprintk(1, "post videobuf_queue_init()\n"); |
147 | unlock_kernel(); | 147 | unlock_kernel(); |
@@ -155,15 +155,15 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo | |||
155 | 155 | ||
156 | switch (fh->type) | 156 | switch (fh->type) |
157 | { | 157 | { |
158 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 158 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
159 | if (res_locked(fh->dev, RESOURCE_VIDEO4)) | 159 | if (res_locked(fh->dev, RESOURCE_VIDEO4)) |
160 | return -EBUSY; | 160 | return -EBUSY; |
161 | 161 | ||
162 | return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK); | 162 | return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK); |
163 | 163 | ||
164 | default: | 164 | default: |
165 | BUG(); | 165 | BUG(); |
166 | return 0; | 166 | return 0; |
167 | } | 167 | } |
168 | } | 168 | } |
169 | 169 | ||
@@ -173,36 +173,36 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait | |||
173 | struct cx25821_buffer *buf; | 173 | struct cx25821_buffer *buf; |
174 | 174 | ||
175 | if (res_check(fh, RESOURCE_VIDEO4)) { | 175 | if (res_check(fh, RESOURCE_VIDEO4)) { |
176 | /* streaming capture */ | 176 | /* streaming capture */ |
177 | if (list_empty(&fh->vidq.stream)) | 177 | if (list_empty(&fh->vidq.stream)) |
178 | return POLLERR; | 178 | return POLLERR; |
179 | buf = list_entry(fh->vidq.stream.next, | 179 | buf = list_entry(fh->vidq.stream.next, |
180 | struct cx25821_buffer, vb.stream); | 180 | struct cx25821_buffer, vb.stream); |
181 | } else { | 181 | } else { |
182 | /* read() capture */ | 182 | /* read() capture */ |
183 | buf = (struct cx25821_buffer *)fh->vidq.read_buf; | 183 | buf = (struct cx25821_buffer *)fh->vidq.read_buf; |
184 | if (NULL == buf) | 184 | if (NULL == buf) |
185 | return POLLERR; | 185 | return POLLERR; |
186 | } | 186 | } |
187 | 187 | ||
188 | poll_wait(file, &buf->vb.done, wait); | 188 | poll_wait(file, &buf->vb.done, wait); |
189 | if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR) | 189 | if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR) |
190 | { | 190 | { |
191 | if( buf->vb.state == VIDEOBUF_DONE ) | 191 | if( buf->vb.state == VIDEOBUF_DONE ) |
192 | { | 192 | { |
193 | struct cx25821_dev *dev = fh->dev; | 193 | struct cx25821_dev *dev = fh->dev; |
194 | 194 | ||
195 | if( dev && dev->use_cif_resolution[SRAM_CH04] ) | 195 | if( dev && dev->use_cif_resolution[SRAM_CH04] ) |
196 | { | 196 | { |
197 | u8 cam_id = *((char*)buf->vb.baddr+3); | 197 | u8 cam_id = *((char*)buf->vb.baddr+3); |
198 | memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2)); | 198 | memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2)); |
199 | *((char*)buf->vb.baddr+3) = cam_id; | 199 | *((char*)buf->vb.baddr+3) = cam_id; |
200 | } | 200 | } |
201 | } | 201 | } |
202 | 202 | ||
203 | return POLLIN|POLLRDNORM; | 203 | return POLLIN|POLLRDNORM; |
204 | } | 204 | } |
205 | 205 | ||
206 | return 0; | 206 | return 0; |
207 | } | 207 | } |
208 | 208 | ||
@@ -217,13 +217,13 @@ static int video_release(struct file *file) | |||
217 | 217 | ||
218 | /* stop video capture */ | 218 | /* stop video capture */ |
219 | if (res_check(fh, RESOURCE_VIDEO4)) { | 219 | if (res_check(fh, RESOURCE_VIDEO4)) { |
220 | videobuf_queue_cancel(&fh->vidq); | 220 | videobuf_queue_cancel(&fh->vidq); |
221 | res_free(dev, fh, RESOURCE_VIDEO4); | 221 | res_free(dev, fh, RESOURCE_VIDEO4); |
222 | } | 222 | } |
223 | 223 | ||
224 | if (fh->vidq.read_buf) { | 224 | if (fh->vidq.read_buf) { |
225 | buffer_release(&fh->vidq, fh->vidq.read_buf); | 225 | buffer_release(&fh->vidq, fh->vidq.read_buf); |
226 | kfree(fh->vidq.read_buf); | 226 | kfree(fh->vidq.read_buf); |
227 | } | 227 | } |
228 | 228 | ||
229 | videobuf_mmap_free(&fh->vidq); | 229 | videobuf_mmap_free(&fh->vidq); |
@@ -243,17 +243,17 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) | |||
243 | 243 | ||
244 | if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) | 244 | if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) |
245 | { | 245 | { |
246 | return -EINVAL; | 246 | return -EINVAL; |
247 | } | 247 | } |
248 | 248 | ||
249 | if (unlikely(i != fh->type)) | 249 | if (unlikely(i != fh->type)) |
250 | { | 250 | { |
251 | return -EINVAL; | 251 | return -EINVAL; |
252 | } | 252 | } |
253 | 253 | ||
254 | if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO4)))) | 254 | if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO4)))) |
255 | { | 255 | { |
256 | return -EBUSY; | 256 | return -EBUSY; |
257 | } | 257 | } |
258 | 258 | ||
259 | return videobuf_streamon(get_queue(fh)); | 259 | return videobuf_streamon(get_queue(fh)); |
@@ -266,14 +266,14 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) | |||
266 | int err, res; | 266 | int err, res; |
267 | 267 | ||
268 | if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 268 | if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
269 | return -EINVAL; | 269 | return -EINVAL; |
270 | if (i != fh->type) | 270 | if (i != fh->type) |
271 | return -EINVAL; | 271 | return -EINVAL; |
272 | 272 | ||
273 | res = get_resource(fh, RESOURCE_VIDEO4); | 273 | res = get_resource(fh, RESOURCE_VIDEO4); |
274 | err = videobuf_streamoff(get_queue(fh)); | 274 | err = videobuf_streamoff(get_queue(fh)); |
275 | if (err < 0) | 275 | if (err < 0) |
276 | return err; | 276 | return err; |
277 | res_free(dev, fh, res); | 277 | res_free(dev, fh, res); |
278 | return 0; | 278 | return 0; |
279 | } | 279 | } |
@@ -284,21 +284,21 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma | |||
284 | { | 284 | { |
285 | struct cx25821_fh *fh = priv; | 285 | struct cx25821_fh *fh = priv; |
286 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 286 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
287 | int err; | 287 | int err; |
288 | int pix_format = 0; | 288 | int pix_format = 0; |
289 | 289 | ||
290 | // check priority | 290 | // check priority |
291 | if (fh) | 291 | if (fh) |
292 | { | 292 | { |
293 | err = v4l2_prio_check(&dev->prio, &fh->prio); | 293 | err = v4l2_prio_check(&dev->prio, &fh->prio); |
294 | if (0 != err) | 294 | if (0 != err) |
295 | return err; | 295 | return err; |
296 | } | 296 | } |
297 | dprintk(2, "%s()\n", __func__); | 297 | dprintk(2, "%s()\n", __func__); |
298 | err = vidioc_try_fmt_vid_cap(file, priv, f); | 298 | err = vidioc_try_fmt_vid_cap(file, priv, f); |
299 | 299 | ||
300 | if (0 != err) | 300 | if (0 != err) |
301 | return err; | 301 | return err; |
302 | 302 | ||
303 | fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); | 303 | fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); |
304 | fh->vidq.field = f->fmt.pix.field; | 304 | fh->vidq.field = f->fmt.pix.field; |
@@ -306,33 +306,33 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma | |||
306 | // check if width and height is valid based on set standard | 306 | // check if width and height is valid based on set standard |
307 | if (is_valid_width(f->fmt.pix.width, dev->tvnorm)) | 307 | if (is_valid_width(f->fmt.pix.width, dev->tvnorm)) |
308 | { | 308 | { |
309 | fh->width = f->fmt.pix.width; | 309 | fh->width = f->fmt.pix.width; |
310 | } | 310 | } |
311 | 311 | ||
312 | if (is_valid_height(f->fmt.pix.height, dev->tvnorm)) | 312 | if (is_valid_height(f->fmt.pix.height, dev->tvnorm)) |
313 | { | 313 | { |
314 | fh->height = f->fmt.pix.height; | 314 | fh->height = f->fmt.pix.height; |
315 | } | 315 | } |
316 | 316 | ||
317 | if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P) | 317 | if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P) |
318 | pix_format = PIXEL_FRMT_411; | 318 | pix_format = PIXEL_FRMT_411; |
319 | else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV) | 319 | else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV) |
320 | pix_format = PIXEL_FRMT_422; | 320 | pix_format = PIXEL_FRMT_422; |
321 | else | 321 | else |
322 | return -EINVAL; | 322 | return -EINVAL; |
323 | |||
324 | cx25821_set_pixel_format( dev, SRAM_CH04, pix_format ); | ||
323 | 325 | ||
324 | cx25821_set_pixel_format( dev, SRAM_CH04, pix_format ); | ||
325 | |||
326 | // check if cif resolution | 326 | // check if cif resolution |
327 | if (fh->width == 320 || fh->width == 352) | 327 | if (fh->width == 320 || fh->width == 352) |
328 | { | 328 | { |
329 | dev->use_cif_resolution[SRAM_CH04] = 1; | 329 | dev->use_cif_resolution[SRAM_CH04] = 1; |
330 | }else | 330 | }else |
331 | { | 331 | { |
332 | dev->use_cif_resolution[SRAM_CH04] = 0; | 332 | dev->use_cif_resolution[SRAM_CH04] = 0; |
333 | } | 333 | } |
334 | dev->cif_width[SRAM_CH04] = fh->width; | 334 | dev->cif_width[SRAM_CH04] = fh->width; |
335 | medusa_set_resolution( dev, fh->width, SRAM_CH04); | 335 | medusa_set_resolution( dev, fh->width, SRAM_CH04); |
336 | 336 | ||
337 | dprintk(2, "%s() width=%d height=%d field=%d\n", __func__, fh->width, fh->height, fh->vidq.field); | 337 | dprintk(2, "%s() width=%d height=%d field=%d\n", __func__, fh->width, fh->height, fh->vidq.field); |
338 | cx25821_call_all(dev, video, s_fmt, f); | 338 | cx25821_call_all(dev, video, s_fmt, f); |
@@ -346,7 +346,7 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p) | |||
346 | struct cx25821_fh *fh = priv; | 346 | struct cx25821_fh *fh = priv; |
347 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 347 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
348 | 348 | ||
349 | ret_val = videobuf_dqbuf(get_queue(fh), p, file->f_flags & O_NONBLOCK); | 349 | ret_val = videobuf_dqbuf(get_queue(fh), p, file->f_flags & O_NONBLOCK); |
350 | 350 | ||
351 | p->sequence = dev->vidq[SRAM_CH04].count; | 351 | p->sequence = dev->vidq[SRAM_CH04].count; |
352 | 352 | ||
@@ -358,7 +358,7 @@ static int vidioc_log_status (struct file *file, void *priv) | |||
358 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 358 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
359 | char name[32 + 2]; | 359 | char name[32 + 2]; |
360 | 360 | ||
361 | struct sram_channel *sram_ch = &dev->sram_channels[SRAM_CH04]; | 361 | struct sram_channel *sram_ch = &dev->sram_channels[SRAM_CH04]; |
362 | u32 tmp = 0; | 362 | u32 tmp = 0; |
363 | 363 | ||
364 | snprintf(name, sizeof(name), "%s/2", dev->name); | 364 | snprintf(name, sizeof(name), "%s/2", dev->name); |
@@ -377,10 +377,10 @@ static int vidioc_s_ctrl(struct file *file, void *priv, | |||
377 | struct v4l2_control *ctl) | 377 | struct v4l2_control *ctl) |
378 | { | 378 | { |
379 | struct cx25821_fh *fh = priv; | 379 | struct cx25821_fh *fh = priv; |
380 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 380 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
381 | int err; | 381 | int err; |
382 | 382 | ||
383 | if (fh) { | 383 | if (fh) { |
384 | err = v4l2_prio_check(&dev->prio, &fh->prio); | 384 | err = v4l2_prio_check(&dev->prio, &fh->prio); |
385 | if (0 != err) | 385 | if (0 != err) |
386 | return err; | 386 | return err; |
diff --git a/drivers/staging/cx25821/cx25821-video5.c b/drivers/staging/cx25821/cx25821-video5.c index 1d47543920b..f1b4742586e 100644 --- a/drivers/staging/cx25821/cx25821-video5.c +++ b/drivers/staging/cx25821/cx25821-video5.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the Conexant CX25821 PCIe bridge | 2 | * Driver for the Conexant CX25821 PCIe bridge |
3 | * | 3 | * |
4 | * Copyright (C) 2009 Conexant Systems Inc. | 4 | * Copyright (C) 2009 Conexant Systems Inc. |
5 | * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com> | 5 | * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com> |
6 | * Based on Steven Toth <stoth@linuxtv.org> cx23885 driver | 6 | * Based on Steven Toth <stoth@linuxtv.org> cx23885 driver |
7 | * | 7 | * |
@@ -40,37 +40,37 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) | |||
40 | dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]); | 40 | dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]); |
41 | 41 | ||
42 | if (!list_empty(&q->queued)) { | 42 | if (!list_empty(&q->queued)) { |
43 | list_add_tail(&buf->vb.queue, &q->queued); | 43 | list_add_tail(&buf->vb.queue, &q->queued); |
44 | buf->vb.state = VIDEOBUF_QUEUED; | 44 | buf->vb.state = VIDEOBUF_QUEUED; |
45 | dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i); | 45 | dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i); |
46 | 46 | ||
47 | } else if (list_empty(&q->active)) { | 47 | } else if (list_empty(&q->active)) { |
48 | list_add_tail(&buf->vb.queue, &q->active); | 48 | list_add_tail(&buf->vb.queue, &q->active); |
49 | cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH05]); | 49 | cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH05]); |
50 | buf->vb.state = VIDEOBUF_ACTIVE; | 50 | buf->vb.state = VIDEOBUF_ACTIVE; |
51 | buf->count = q->count++; | 51 | buf->count = q->count++; |
52 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); | 52 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); |
53 | dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n", | 53 | dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n", |
54 | buf, buf->vb. i, buf->count, q->count); | 54 | buf, buf->vb. i, buf->count, q->count); |
55 | } else { | 55 | } else { |
56 | prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue); | 56 | prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue); |
57 | if (prev->vb.width == buf->vb.width && | 57 | if (prev->vb.width == buf->vb.width && |
58 | prev->vb.height == buf->vb.height && | 58 | prev->vb.height == buf->vb.height && |
59 | prev->fmt == buf->fmt) { | 59 | prev->fmt == buf->fmt) { |
60 | list_add_tail(&buf->vb.queue, &q->active); | 60 | list_add_tail(&buf->vb.queue, &q->active); |
61 | buf->vb.state = VIDEOBUF_ACTIVE; | 61 | buf->vb.state = VIDEOBUF_ACTIVE; |
62 | buf->count = q->count++; | 62 | buf->count = q->count++; |
63 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); | 63 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); |
64 | 64 | ||
65 | /* 64 bit bits 63-32 */ | 65 | /* 64 bit bits 63-32 */ |
66 | prev->risc.jmp[2] = cpu_to_le32(0); | 66 | prev->risc.jmp[2] = cpu_to_le32(0); |
67 | dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count); | 67 | dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count); |
68 | 68 | ||
69 | } else { | 69 | } else { |
70 | list_add_tail(&buf->vb.queue, &q->queued); | 70 | list_add_tail(&buf->vb.queue, &q->queued); |
71 | buf->vb.state = VIDEOBUF_QUEUED; | 71 | buf->vb.state = VIDEOBUF_QUEUED; |
72 | dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i); | 72 | dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i); |
73 | } | 73 | } |
74 | } | 74 | } |
75 | 75 | ||
76 | if (list_empty(&q->active)) | 76 | if (list_empty(&q->active)) |
@@ -100,17 +100,17 @@ static int video_open(struct file *file) | |||
100 | lock_kernel(); | 100 | lock_kernel(); |
101 | list_for_each(list, &cx25821_devlist) | 101 | list_for_each(list, &cx25821_devlist) |
102 | { | 102 | { |
103 | h = list_entry(list, struct cx25821_dev, devlist); | 103 | h = list_entry(list, struct cx25821_dev, devlist); |
104 | 104 | ||
105 | if (h->video_dev[SRAM_CH05] && h->video_dev[SRAM_CH05]->minor == minor) { | 105 | if (h->video_dev[SRAM_CH05] && h->video_dev[SRAM_CH05]->minor == minor) { |
106 | dev = h; | 106 | dev = h; |
107 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 107 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
108 | } | 108 | } |
109 | } | 109 | } |
110 | 110 | ||
111 | if (NULL == dev) { | 111 | if (NULL == dev) { |
112 | unlock_kernel(); | 112 | unlock_kernel(); |
113 | return -ENODEV; | 113 | return -ENODEV; |
114 | } | 114 | } |
115 | 115 | ||
116 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); | 116 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); |
@@ -118,8 +118,8 @@ static int video_open(struct file *file) | |||
118 | /* allocate + initialize per filehandle data */ | 118 | /* allocate + initialize per filehandle data */ |
119 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); | 119 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); |
120 | if (NULL == fh) { | 120 | if (NULL == fh) { |
121 | unlock_kernel(); | 121 | unlock_kernel(); |
122 | return -ENOMEM; | 122 | return -ENOMEM; |
123 | } | 123 | } |
124 | file->private_data = fh; | 124 | file->private_data = fh; |
125 | fh->dev = dev; | 125 | fh->dev = dev; |
@@ -127,9 +127,9 @@ static int video_open(struct file *file) | |||
127 | fh->width = 720; | 127 | fh->width = 720; |
128 | 128 | ||
129 | if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) | 129 | if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) |
130 | fh->height = 576; | 130 | fh->height = 576; |
131 | else | 131 | else |
132 | fh->height = 480; | 132 | fh->height = 480; |
133 | 133 | ||
134 | dev->channel_opened = SRAM_CH05; | 134 | dev->channel_opened = SRAM_CH05; |
135 | pix_format = (dev->pixel_formats[dev->channel_opened] == PIXEL_FRMT_411) ? V4L2_PIX_FMT_Y41P : V4L2_PIX_FMT_YUYV; | 135 | pix_format = (dev->pixel_formats[dev->channel_opened] == PIXEL_FRMT_411) ? V4L2_PIX_FMT_Y41P : V4L2_PIX_FMT_YUYV; |
@@ -138,11 +138,11 @@ static int video_open(struct file *file) | |||
138 | v4l2_prio_open(&dev->prio,&fh->prio); | 138 | v4l2_prio_open(&dev->prio,&fh->prio); |
139 | 139 | ||
140 | videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops, | 140 | videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops, |
141 | &dev->pci->dev, &dev->slock, | 141 | &dev->pci->dev, &dev->slock, |
142 | V4L2_BUF_TYPE_VIDEO_CAPTURE, | 142 | V4L2_BUF_TYPE_VIDEO_CAPTURE, |
143 | V4L2_FIELD_INTERLACED, | 143 | V4L2_FIELD_INTERLACED, |
144 | sizeof(struct cx25821_buffer), | 144 | sizeof(struct cx25821_buffer), |
145 | fh); | 145 | fh); |
146 | 146 | ||
147 | dprintk(1, "post videobuf_queue_init()\n"); | 147 | dprintk(1, "post videobuf_queue_init()\n"); |
148 | unlock_kernel(); | 148 | unlock_kernel(); |
@@ -156,15 +156,15 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo | |||
156 | 156 | ||
157 | switch (fh->type) | 157 | switch (fh->type) |
158 | { | 158 | { |
159 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 159 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
160 | if (res_locked(fh->dev, RESOURCE_VIDEO5)) | 160 | if (res_locked(fh->dev, RESOURCE_VIDEO5)) |
161 | return -EBUSY; | 161 | return -EBUSY; |
162 | 162 | ||
163 | return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK); | 163 | return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK); |
164 | 164 | ||
165 | default: | 165 | default: |
166 | BUG(); | 166 | BUG(); |
167 | return 0; | 167 | return 0; |
168 | } | 168 | } |
169 | } | 169 | } |
170 | 170 | ||
@@ -174,34 +174,34 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait | |||
174 | struct cx25821_buffer *buf; | 174 | struct cx25821_buffer *buf; |
175 | 175 | ||
176 | if (res_check(fh, RESOURCE_VIDEO5)) { | 176 | if (res_check(fh, RESOURCE_VIDEO5)) { |
177 | /* streaming capture */ | 177 | /* streaming capture */ |
178 | if (list_empty(&fh->vidq.stream)) | 178 | if (list_empty(&fh->vidq.stream)) |
179 | return POLLERR; | 179 | return POLLERR; |
180 | buf = list_entry(fh->vidq.stream.next, | 180 | buf = list_entry(fh->vidq.stream.next, |
181 | struct cx25821_buffer, vb.stream); | 181 | struct cx25821_buffer, vb.stream); |
182 | } else { | 182 | } else { |
183 | /* read() capture */ | 183 | /* read() capture */ |
184 | buf = (struct cx25821_buffer *)fh->vidq.read_buf; | 184 | buf = (struct cx25821_buffer *)fh->vidq.read_buf; |
185 | if (NULL == buf) | 185 | if (NULL == buf) |
186 | return POLLERR; | 186 | return POLLERR; |
187 | } | 187 | } |
188 | 188 | ||
189 | poll_wait(file, &buf->vb.done, wait); | 189 | poll_wait(file, &buf->vb.done, wait); |
190 | if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR) | 190 | if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR) |
191 | { | 191 | { |
192 | if( buf->vb.state == VIDEOBUF_DONE ) | 192 | if( buf->vb.state == VIDEOBUF_DONE ) |
193 | { | 193 | { |
194 | struct cx25821_dev *dev = fh->dev; | 194 | struct cx25821_dev *dev = fh->dev; |
195 | 195 | ||
196 | if( dev && dev->use_cif_resolution[SRAM_CH05] ) | 196 | if( dev && dev->use_cif_resolution[SRAM_CH05] ) |
197 | { | 197 | { |
198 | u8 cam_id = *((char*)buf->vb.baddr+3); | 198 | u8 cam_id = *((char*)buf->vb.baddr+3); |
199 | memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2)); | 199 | memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2)); |
200 | *((char*)buf->vb.baddr+3) = cam_id; | 200 | *((char*)buf->vb.baddr+3) = cam_id; |
201 | } | 201 | } |
202 | } | 202 | } |
203 | 203 | ||
204 | return POLLIN|POLLRDNORM; | 204 | return POLLIN|POLLRDNORM; |
205 | } | 205 | } |
206 | 206 | ||
207 | return 0; | 207 | return 0; |
@@ -218,13 +218,13 @@ static int video_release(struct file *file) | |||
218 | 218 | ||
219 | /* stop video capture */ | 219 | /* stop video capture */ |
220 | if (res_check(fh, RESOURCE_VIDEO5)) { | 220 | if (res_check(fh, RESOURCE_VIDEO5)) { |
221 | videobuf_queue_cancel(&fh->vidq); | 221 | videobuf_queue_cancel(&fh->vidq); |
222 | res_free(dev, fh, RESOURCE_VIDEO5); | 222 | res_free(dev, fh, RESOURCE_VIDEO5); |
223 | } | 223 | } |
224 | 224 | ||
225 | if (fh->vidq.read_buf) { | 225 | if (fh->vidq.read_buf) { |
226 | buffer_release(&fh->vidq, fh->vidq.read_buf); | 226 | buffer_release(&fh->vidq, fh->vidq.read_buf); |
227 | kfree(fh->vidq.read_buf); | 227 | kfree(fh->vidq.read_buf); |
228 | } | 228 | } |
229 | 229 | ||
230 | videobuf_mmap_free(&fh->vidq); | 230 | videobuf_mmap_free(&fh->vidq); |
@@ -244,17 +244,17 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) | |||
244 | 244 | ||
245 | if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) | 245 | if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) |
246 | { | 246 | { |
247 | return -EINVAL; | 247 | return -EINVAL; |
248 | } | 248 | } |
249 | 249 | ||
250 | if (unlikely(i != fh->type)) | 250 | if (unlikely(i != fh->type)) |
251 | { | 251 | { |
252 | return -EINVAL; | 252 | return -EINVAL; |
253 | } | 253 | } |
254 | 254 | ||
255 | if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO5)))) | 255 | if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO5)))) |
256 | { | 256 | { |
257 | return -EBUSY; | 257 | return -EBUSY; |
258 | } | 258 | } |
259 | 259 | ||
260 | return videobuf_streamon(get_queue(fh)); | 260 | return videobuf_streamon(get_queue(fh)); |
@@ -267,14 +267,14 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) | |||
267 | int err, res; | 267 | int err, res; |
268 | 268 | ||
269 | if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 269 | if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
270 | return -EINVAL; | 270 | return -EINVAL; |
271 | if (i != fh->type) | 271 | if (i != fh->type) |
272 | return -EINVAL; | 272 | return -EINVAL; |
273 | 273 | ||
274 | res = get_resource(fh, RESOURCE_VIDEO5); | 274 | res = get_resource(fh, RESOURCE_VIDEO5); |
275 | err = videobuf_streamoff(get_queue(fh)); | 275 | err = videobuf_streamoff(get_queue(fh)); |
276 | if (err < 0) | 276 | if (err < 0) |
277 | return err; | 277 | return err; |
278 | res_free(dev, fh, res); | 278 | res_free(dev, fh, res); |
279 | return 0; | 279 | return 0; |
280 | } | 280 | } |
@@ -284,21 +284,21 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma | |||
284 | { | 284 | { |
285 | struct cx25821_fh *fh = priv; | 285 | struct cx25821_fh *fh = priv; |
286 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 286 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
287 | int err; | 287 | int err; |
288 | int pix_format = 0; | 288 | int pix_format = 0; |
289 | 289 | ||
290 | if (fh) | 290 | if (fh) |
291 | { | 291 | { |
292 | err = v4l2_prio_check(&dev->prio, &fh->prio); | 292 | err = v4l2_prio_check(&dev->prio, &fh->prio); |
293 | if (0 != err) | 293 | if (0 != err) |
294 | return err; | 294 | return err; |
295 | } | 295 | } |
296 | 296 | ||
297 | dprintk(2, "%s()\n", __func__); | 297 | dprintk(2, "%s()\n", __func__); |
298 | err = vidioc_try_fmt_vid_cap(file, priv, f); | 298 | err = vidioc_try_fmt_vid_cap(file, priv, f); |
299 | 299 | ||
300 | if (0 != err) | 300 | if (0 != err) |
301 | return err; | 301 | return err; |
302 | 302 | ||
303 | fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); | 303 | fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); |
304 | fh->vidq.field = f->fmt.pix.field; | 304 | fh->vidq.field = f->fmt.pix.field; |
@@ -306,33 +306,33 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma | |||
306 | // check if width and height is valid based on set standard | 306 | // check if width and height is valid based on set standard |
307 | if (is_valid_width(f->fmt.pix.width, dev->tvnorm)) | 307 | if (is_valid_width(f->fmt.pix.width, dev->tvnorm)) |
308 | { | 308 | { |
309 | fh->width = f->fmt.pix.width; | 309 | fh->width = f->fmt.pix.width; |
310 | } | 310 | } |
311 | 311 | ||
312 | if (is_valid_height(f->fmt.pix.height, dev->tvnorm)) | 312 | if (is_valid_height(f->fmt.pix.height, dev->tvnorm)) |
313 | { | 313 | { |
314 | fh->height = f->fmt.pix.height; | 314 | fh->height = f->fmt.pix.height; |
315 | } | 315 | } |
316 | 316 | ||
317 | if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P) | 317 | if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P) |
318 | pix_format = PIXEL_FRMT_411; | 318 | pix_format = PIXEL_FRMT_411; |
319 | else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV) | 319 | else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV) |
320 | pix_format = PIXEL_FRMT_422; | 320 | pix_format = PIXEL_FRMT_422; |
321 | else | 321 | else |
322 | return -EINVAL; | 322 | return -EINVAL; |
323 | |||
324 | cx25821_set_pixel_format( dev, SRAM_CH05, pix_format ); | ||
323 | 325 | ||
324 | cx25821_set_pixel_format( dev, SRAM_CH05, pix_format ); | ||
325 | |||
326 | // check if cif resolution | 326 | // check if cif resolution |
327 | if (fh->width == 320 || fh->width == 352) | 327 | if (fh->width == 320 || fh->width == 352) |
328 | { | 328 | { |
329 | dev->use_cif_resolution[SRAM_CH05] = 1; | 329 | dev->use_cif_resolution[SRAM_CH05] = 1; |
330 | }else | 330 | }else |
331 | { | 331 | { |
332 | dev->use_cif_resolution[SRAM_CH05] = 0; | 332 | dev->use_cif_resolution[SRAM_CH05] = 0; |
333 | } | 333 | } |
334 | dev->cif_width[SRAM_CH05] = fh->width; | 334 | dev->cif_width[SRAM_CH05] = fh->width; |
335 | medusa_set_resolution( dev, fh->width, SRAM_CH05 ); | 335 | medusa_set_resolution( dev, fh->width, SRAM_CH05 ); |
336 | 336 | ||
337 | dprintk(2, "%s() width=%d height=%d field=%d\n", __func__, fh->width, fh->height, fh->vidq.field); | 337 | dprintk(2, "%s() width=%d height=%d field=%d\n", __func__, fh->width, fh->height, fh->vidq.field); |
338 | cx25821_call_all(dev, video, s_fmt, f); | 338 | cx25821_call_all(dev, video, s_fmt, f); |
@@ -346,7 +346,7 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p) | |||
346 | struct cx25821_fh *fh = priv; | 346 | struct cx25821_fh *fh = priv; |
347 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 347 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
348 | 348 | ||
349 | ret_val = videobuf_dqbuf(get_queue(fh), p, file->f_flags & O_NONBLOCK); | 349 | ret_val = videobuf_dqbuf(get_queue(fh), p, file->f_flags & O_NONBLOCK); |
350 | 350 | ||
351 | p->sequence = dev->vidq[SRAM_CH05].count; | 351 | p->sequence = dev->vidq[SRAM_CH05].count; |
352 | 352 | ||
@@ -357,14 +357,14 @@ static int vidioc_log_status (struct file *file, void *priv) | |||
357 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 357 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
358 | char name[32 + 2]; | 358 | char name[32 + 2]; |
359 | 359 | ||
360 | struct sram_channel *sram_ch = &dev->sram_channels[SRAM_CH05]; | 360 | struct sram_channel *sram_ch = &dev->sram_channels[SRAM_CH05]; |
361 | u32 tmp = 0; | 361 | u32 tmp = 0; |
362 | 362 | ||
363 | snprintf(name, sizeof(name), "%s/2", dev->name); | 363 | snprintf(name, sizeof(name), "%s/2", dev->name); |
364 | printk(KERN_INFO "%s/2: ============ START LOG STATUS ============\n", | 364 | printk(KERN_INFO "%s/2: ============ START LOG STATUS ============\n", |
365 | dev->name); | 365 | dev->name); |
366 | cx25821_call_all(dev, core, log_status); | 366 | cx25821_call_all(dev, core, log_status); |
367 | 367 | ||
368 | tmp = cx_read(sram_ch->dma_ctl); | 368 | tmp = cx_read(sram_ch->dma_ctl); |
369 | printk(KERN_INFO "Video input 5 is %s\n", (tmp & 0x11)?"streaming" : "stopped"); | 369 | printk(KERN_INFO "Video input 5 is %s\n", (tmp & 0x11)?"streaming" : "stopped"); |
370 | printk(KERN_INFO "%s/2: ============= END LOG STATUS =============\n", | 370 | printk(KERN_INFO "%s/2: ============= END LOG STATUS =============\n", |
@@ -376,10 +376,10 @@ static int vidioc_s_ctrl(struct file *file, void *priv, | |||
376 | struct v4l2_control *ctl) | 376 | struct v4l2_control *ctl) |
377 | { | 377 | { |
378 | struct cx25821_fh *fh = priv; | 378 | struct cx25821_fh *fh = priv; |
379 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 379 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
380 | int err; | 380 | int err; |
381 | 381 | ||
382 | if (fh) { | 382 | if (fh) { |
383 | err = v4l2_prio_check(&dev->prio, &fh->prio); | 383 | err = v4l2_prio_check(&dev->prio, &fh->prio); |
384 | if (0 != err) | 384 | if (0 != err) |
385 | return err; | 385 | return err; |
diff --git a/drivers/staging/cx25821/cx25821-video6.c b/drivers/staging/cx25821/cx25821-video6.c index 980565af5c3..1c0319c7ade 100644 --- a/drivers/staging/cx25821/cx25821-video6.c +++ b/drivers/staging/cx25821/cx25821-video6.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the Conexant CX25821 PCIe bridge | 2 | * Driver for the Conexant CX25821 PCIe bridge |
3 | * | 3 | * |
4 | * Copyright (C) 2009 Conexant Systems Inc. | 4 | * Copyright (C) 2009 Conexant Systems Inc. |
5 | * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com> | 5 | * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com> |
6 | * Based on Steven Toth <stoth@linuxtv.org> cx23885 driver | 6 | * Based on Steven Toth <stoth@linuxtv.org> cx23885 driver |
7 | * | 7 | * |
@@ -40,37 +40,37 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) | |||
40 | dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]); | 40 | dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]); |
41 | 41 | ||
42 | if (!list_empty(&q->queued)) { | 42 | if (!list_empty(&q->queued)) { |
43 | list_add_tail(&buf->vb.queue, &q->queued); | 43 | list_add_tail(&buf->vb.queue, &q->queued); |
44 | buf->vb.state = VIDEOBUF_QUEUED; | 44 | buf->vb.state = VIDEOBUF_QUEUED; |
45 | dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i); | 45 | dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i); |
46 | 46 | ||
47 | } else if (list_empty(&q->active)) { | 47 | } else if (list_empty(&q->active)) { |
48 | list_add_tail(&buf->vb.queue, &q->active); | 48 | list_add_tail(&buf->vb.queue, &q->active); |
49 | cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH06]); | 49 | cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH06]); |
50 | buf->vb.state = VIDEOBUF_ACTIVE; | 50 | buf->vb.state = VIDEOBUF_ACTIVE; |
51 | buf->count = q->count++; | 51 | buf->count = q->count++; |
52 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); | 52 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); |
53 | dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n", | 53 | dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n", |
54 | buf, buf->vb. i, buf->count, q->count); | 54 | buf, buf->vb. i, buf->count, q->count); |
55 | } else { | 55 | } else { |
56 | prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue); | 56 | prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue); |
57 | if (prev->vb.width == buf->vb.width && | 57 | if (prev->vb.width == buf->vb.width && |
58 | prev->vb.height == buf->vb.height && | 58 | prev->vb.height == buf->vb.height && |
59 | prev->fmt == buf->fmt) { | 59 | prev->fmt == buf->fmt) { |
60 | list_add_tail(&buf->vb.queue, &q->active); | 60 | list_add_tail(&buf->vb.queue, &q->active); |
61 | buf->vb.state = VIDEOBUF_ACTIVE; | 61 | buf->vb.state = VIDEOBUF_ACTIVE; |
62 | buf->count = q->count++; | 62 | buf->count = q->count++; |
63 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); | 63 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); |
64 | 64 | ||
65 | /* 64 bit bits 63-32 */ | 65 | /* 64 bit bits 63-32 */ |
66 | prev->risc.jmp[2] = cpu_to_le32(0); | 66 | prev->risc.jmp[2] = cpu_to_le32(0); |
67 | dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count); | 67 | dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count); |
68 | 68 | ||
69 | } else { | 69 | } else { |
70 | list_add_tail(&buf->vb.queue, &q->queued); | 70 | list_add_tail(&buf->vb.queue, &q->queued); |
71 | buf->vb.state = VIDEOBUF_QUEUED; | 71 | buf->vb.state = VIDEOBUF_QUEUED; |
72 | dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i); | 72 | dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i); |
73 | } | 73 | } |
74 | } | 74 | } |
75 | 75 | ||
76 | if (list_empty(&q->active)) | 76 | if (list_empty(&q->active)) |
@@ -100,17 +100,17 @@ static int video_open(struct file *file) | |||
100 | lock_kernel(); | 100 | lock_kernel(); |
101 | list_for_each(list, &cx25821_devlist) | 101 | list_for_each(list, &cx25821_devlist) |
102 | { | 102 | { |
103 | h = list_entry(list, struct cx25821_dev, devlist); | 103 | h = list_entry(list, struct cx25821_dev, devlist); |
104 | 104 | ||
105 | if (h->video_dev[SRAM_CH06] && h->video_dev[SRAM_CH06]->minor == minor) { | 105 | if (h->video_dev[SRAM_CH06] && h->video_dev[SRAM_CH06]->minor == minor) { |
106 | dev = h; | 106 | dev = h; |
107 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 107 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
108 | } | 108 | } |
109 | } | 109 | } |
110 | 110 | ||
111 | if (NULL == dev) { | 111 | if (NULL == dev) { |
112 | unlock_kernel(); | 112 | unlock_kernel(); |
113 | return -ENODEV; | 113 | return -ENODEV; |
114 | } | 114 | } |
115 | 115 | ||
116 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); | 116 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); |
@@ -118,8 +118,8 @@ static int video_open(struct file *file) | |||
118 | /* allocate + initialize per filehandle data */ | 118 | /* allocate + initialize per filehandle data */ |
119 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); | 119 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); |
120 | if (NULL == fh) { | 120 | if (NULL == fh) { |
121 | unlock_kernel(); | 121 | unlock_kernel(); |
122 | return -ENOMEM; | 122 | return -ENOMEM; |
123 | } | 123 | } |
124 | file->private_data = fh; | 124 | file->private_data = fh; |
125 | fh->dev = dev; | 125 | fh->dev = dev; |
@@ -127,9 +127,9 @@ static int video_open(struct file *file) | |||
127 | fh->width = 720; | 127 | fh->width = 720; |
128 | 128 | ||
129 | if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) | 129 | if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) |
130 | fh->height = 576; | 130 | fh->height = 576; |
131 | else | 131 | else |
132 | fh->height = 480; | 132 | fh->height = 480; |
133 | 133 | ||
134 | dev->channel_opened = SRAM_CH06; | 134 | dev->channel_opened = SRAM_CH06; |
135 | pix_format = (dev->pixel_formats[dev->channel_opened] == PIXEL_FRMT_411) ? V4L2_PIX_FMT_Y41P : V4L2_PIX_FMT_YUYV; | 135 | pix_format = (dev->pixel_formats[dev->channel_opened] == PIXEL_FRMT_411) ? V4L2_PIX_FMT_Y41P : V4L2_PIX_FMT_YUYV; |
@@ -138,11 +138,11 @@ static int video_open(struct file *file) | |||
138 | v4l2_prio_open(&dev->prio,&fh->prio); | 138 | v4l2_prio_open(&dev->prio,&fh->prio); |
139 | 139 | ||
140 | videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops, | 140 | videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops, |
141 | &dev->pci->dev, &dev->slock, | 141 | &dev->pci->dev, &dev->slock, |
142 | V4L2_BUF_TYPE_VIDEO_CAPTURE, | 142 | V4L2_BUF_TYPE_VIDEO_CAPTURE, |
143 | V4L2_FIELD_INTERLACED, | 143 | V4L2_FIELD_INTERLACED, |
144 | sizeof(struct cx25821_buffer), | 144 | sizeof(struct cx25821_buffer), |
145 | fh); | 145 | fh); |
146 | 146 | ||
147 | dprintk(1, "post videobuf_queue_init()\n"); | 147 | dprintk(1, "post videobuf_queue_init()\n"); |
148 | unlock_kernel(); | 148 | unlock_kernel(); |
@@ -156,15 +156,15 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo | |||
156 | 156 | ||
157 | switch (fh->type) | 157 | switch (fh->type) |
158 | { | 158 | { |
159 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 159 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
160 | if (res_locked(fh->dev, RESOURCE_VIDEO6)) | 160 | if (res_locked(fh->dev, RESOURCE_VIDEO6)) |
161 | return -EBUSY; | 161 | return -EBUSY; |
162 | 162 | ||
163 | return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK); | 163 | return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK); |
164 | 164 | ||
165 | default: | 165 | default: |
166 | BUG(); | 166 | BUG(); |
167 | return 0; | 167 | return 0; |
168 | } | 168 | } |
169 | } | 169 | } |
170 | 170 | ||
@@ -174,36 +174,36 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait | |||
174 | struct cx25821_buffer *buf; | 174 | struct cx25821_buffer *buf; |
175 | 175 | ||
176 | if (res_check(fh, RESOURCE_VIDEO6)) { | 176 | if (res_check(fh, RESOURCE_VIDEO6)) { |
177 | /* streaming capture */ | 177 | /* streaming capture */ |
178 | if (list_empty(&fh->vidq.stream)) | 178 | if (list_empty(&fh->vidq.stream)) |
179 | return POLLERR; | 179 | return POLLERR; |
180 | buf = list_entry(fh->vidq.stream.next, | 180 | buf = list_entry(fh->vidq.stream.next, |
181 | struct cx25821_buffer, vb.stream); | 181 | struct cx25821_buffer, vb.stream); |
182 | } else { | 182 | } else { |
183 | /* read() capture */ | 183 | /* read() capture */ |
184 | buf = (struct cx25821_buffer *)fh->vidq.read_buf; | 184 | buf = (struct cx25821_buffer *)fh->vidq.read_buf; |
185 | if (NULL == buf) | 185 | if (NULL == buf) |
186 | return POLLERR; | 186 | return POLLERR; |
187 | } | 187 | } |
188 | 188 | ||
189 | poll_wait(file, &buf->vb.done, wait); | 189 | poll_wait(file, &buf->vb.done, wait); |
190 | if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR) | 190 | if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR) |
191 | { | 191 | { |
192 | if( buf->vb.state == VIDEOBUF_DONE ) | 192 | if( buf->vb.state == VIDEOBUF_DONE ) |
193 | { | 193 | { |
194 | struct cx25821_dev *dev = fh->dev; | 194 | struct cx25821_dev *dev = fh->dev; |
195 | 195 | ||
196 | if( dev && dev->use_cif_resolution[SRAM_CH06] ) | 196 | if( dev && dev->use_cif_resolution[SRAM_CH06] ) |
197 | { | 197 | { |
198 | u8 cam_id = *((char*)buf->vb.baddr+3); | 198 | u8 cam_id = *((char*)buf->vb.baddr+3); |
199 | memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2)); | 199 | memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2)); |
200 | *((char*)buf->vb.baddr+3) = cam_id; | 200 | *((char*)buf->vb.baddr+3) = cam_id; |
201 | } | 201 | } |
202 | } | 202 | } |
203 | 203 | ||
204 | return POLLIN|POLLRDNORM; | 204 | return POLLIN|POLLRDNORM; |
205 | } | 205 | } |
206 | 206 | ||
207 | return 0; | 207 | return 0; |
208 | } | 208 | } |
209 | 209 | ||
@@ -218,12 +218,12 @@ static int video_release(struct file *file) | |||
218 | 218 | ||
219 | /* stop video capture */ | 219 | /* stop video capture */ |
220 | if (res_check(fh, RESOURCE_VIDEO6)) { | 220 | if (res_check(fh, RESOURCE_VIDEO6)) { |
221 | videobuf_queue_cancel(&fh->vidq); | 221 | videobuf_queue_cancel(&fh->vidq); |
222 | res_free(dev, fh, RESOURCE_VIDEO6); | 222 | res_free(dev, fh, RESOURCE_VIDEO6); |
223 | } | 223 | } |
224 | if (fh->vidq.read_buf) { | 224 | if (fh->vidq.read_buf) { |
225 | buffer_release(&fh->vidq, fh->vidq.read_buf); | 225 | buffer_release(&fh->vidq, fh->vidq.read_buf); |
226 | kfree(fh->vidq.read_buf); | 226 | kfree(fh->vidq.read_buf); |
227 | } | 227 | } |
228 | 228 | ||
229 | videobuf_mmap_free(&fh->vidq); | 229 | videobuf_mmap_free(&fh->vidq); |
@@ -243,17 +243,17 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) | |||
243 | 243 | ||
244 | if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) | 244 | if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) |
245 | { | 245 | { |
246 | return -EINVAL; | 246 | return -EINVAL; |
247 | } | 247 | } |
248 | 248 | ||
249 | if (unlikely(i != fh->type)) | 249 | if (unlikely(i != fh->type)) |
250 | { | 250 | { |
251 | return -EINVAL; | 251 | return -EINVAL; |
252 | } | 252 | } |
253 | 253 | ||
254 | if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO6)))) | 254 | if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO6)))) |
255 | { | 255 | { |
256 | return -EBUSY; | 256 | return -EBUSY; |
257 | } | 257 | } |
258 | 258 | ||
259 | return videobuf_streamon(get_queue(fh)); | 259 | return videobuf_streamon(get_queue(fh)); |
@@ -266,14 +266,14 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) | |||
266 | int err, res; | 266 | int err, res; |
267 | 267 | ||
268 | if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 268 | if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
269 | return -EINVAL; | 269 | return -EINVAL; |
270 | if (i != fh->type) | 270 | if (i != fh->type) |
271 | return -EINVAL; | 271 | return -EINVAL; |
272 | 272 | ||
273 | res = get_resource(fh, RESOURCE_VIDEO6); | 273 | res = get_resource(fh, RESOURCE_VIDEO6); |
274 | err = videobuf_streamoff(get_queue(fh)); | 274 | err = videobuf_streamoff(get_queue(fh)); |
275 | if (err < 0) | 275 | if (err < 0) |
276 | return err; | 276 | return err; |
277 | res_free(dev, fh, res); | 277 | res_free(dev, fh, res); |
278 | return 0; | 278 | return 0; |
279 | } | 279 | } |
@@ -283,21 +283,21 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma | |||
283 | { | 283 | { |
284 | struct cx25821_fh *fh = priv; | 284 | struct cx25821_fh *fh = priv; |
285 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 285 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
286 | int err; | 286 | int err; |
287 | int pix_format = 0; | 287 | int pix_format = 0; |
288 | 288 | ||
289 | if (fh) | 289 | if (fh) |
290 | { | 290 | { |
291 | err = v4l2_prio_check(&dev->prio, &fh->prio); | 291 | err = v4l2_prio_check(&dev->prio, &fh->prio); |
292 | if (0 != err) | 292 | if (0 != err) |
293 | return err; | 293 | return err; |
294 | } | 294 | } |
295 | 295 | ||
296 | dprintk(2, "%s()\n", __func__); | 296 | dprintk(2, "%s()\n", __func__); |
297 | err = vidioc_try_fmt_vid_cap(file, priv, f); | 297 | err = vidioc_try_fmt_vid_cap(file, priv, f); |
298 | 298 | ||
299 | if (0 != err) | 299 | if (0 != err) |
300 | return err; | 300 | return err; |
301 | 301 | ||
302 | fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); | 302 | fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); |
303 | fh->vidq.field = f->fmt.pix.field; | 303 | fh->vidq.field = f->fmt.pix.field; |
@@ -305,33 +305,33 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma | |||
305 | // check if width and height is valid based on set standard | 305 | // check if width and height is valid based on set standard |
306 | if (is_valid_width(f->fmt.pix.width, dev->tvnorm)) | 306 | if (is_valid_width(f->fmt.pix.width, dev->tvnorm)) |
307 | { | 307 | { |
308 | fh->width = f->fmt.pix.width; | 308 | fh->width = f->fmt.pix.width; |
309 | } | 309 | } |
310 | 310 | ||
311 | if (is_valid_height(f->fmt.pix.height, dev->tvnorm)) | 311 | if (is_valid_height(f->fmt.pix.height, dev->tvnorm)) |
312 | { | 312 | { |
313 | fh->height = f->fmt.pix.height; | 313 | fh->height = f->fmt.pix.height; |
314 | } | 314 | } |
315 | 315 | ||
316 | if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P) | 316 | if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P) |
317 | pix_format = PIXEL_FRMT_411; | 317 | pix_format = PIXEL_FRMT_411; |
318 | else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV) | 318 | else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV) |
319 | pix_format = PIXEL_FRMT_422; | 319 | pix_format = PIXEL_FRMT_422; |
320 | else | 320 | else |
321 | return -EINVAL; | 321 | return -EINVAL; |
322 | |||
323 | cx25821_set_pixel_format( dev, SRAM_CH06, pix_format ); | ||
322 | 324 | ||
323 | cx25821_set_pixel_format( dev, SRAM_CH06, pix_format ); | ||
324 | |||
325 | // check if cif resolution | 325 | // check if cif resolution |
326 | if (fh->width == 320 || fh->width == 352) | 326 | if (fh->width == 320 || fh->width == 352) |
327 | { | 327 | { |
328 | dev->use_cif_resolution[SRAM_CH06] = 1; | 328 | dev->use_cif_resolution[SRAM_CH06] = 1; |
329 | }else | 329 | }else |
330 | { | 330 | { |
331 | dev->use_cif_resolution[SRAM_CH06] = 0; | 331 | dev->use_cif_resolution[SRAM_CH06] = 0; |
332 | } | 332 | } |
333 | dev->cif_width[SRAM_CH06] = fh->width; | 333 | dev->cif_width[SRAM_CH06] = fh->width; |
334 | medusa_set_resolution( dev, fh->width, SRAM_CH06 ); | 334 | medusa_set_resolution( dev, fh->width, SRAM_CH06 ); |
335 | 335 | ||
336 | dprintk(2, "%s() width=%d height=%d field=%d\n", __func__, fh->width, fh->height, fh->vidq.field); | 336 | dprintk(2, "%s() width=%d height=%d field=%d\n", __func__, fh->width, fh->height, fh->vidq.field); |
337 | cx25821_call_all(dev, video, s_fmt, f); | 337 | cx25821_call_all(dev, video, s_fmt, f); |
@@ -345,7 +345,7 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p) | |||
345 | struct cx25821_fh *fh = priv; | 345 | struct cx25821_fh *fh = priv; |
346 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 346 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
347 | 347 | ||
348 | ret_val = videobuf_dqbuf(get_queue(fh), p, file->f_flags & O_NONBLOCK); | 348 | ret_val = videobuf_dqbuf(get_queue(fh), p, file->f_flags & O_NONBLOCK); |
349 | 349 | ||
350 | p->sequence = dev->vidq[SRAM_CH06].count; | 350 | p->sequence = dev->vidq[SRAM_CH06].count; |
351 | 351 | ||
@@ -357,14 +357,14 @@ static int vidioc_log_status (struct file *file, void *priv) | |||
357 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 357 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
358 | char name[32 + 2]; | 358 | char name[32 + 2]; |
359 | 359 | ||
360 | struct sram_channel *sram_ch = &dev->sram_channels[SRAM_CH06]; | 360 | struct sram_channel *sram_ch = &dev->sram_channels[SRAM_CH06]; |
361 | u32 tmp = 0; | 361 | u32 tmp = 0; |
362 | 362 | ||
363 | snprintf(name, sizeof(name), "%s/2", dev->name); | 363 | snprintf(name, sizeof(name), "%s/2", dev->name); |
364 | printk(KERN_INFO "%s/2: ============ START LOG STATUS ============\n", | 364 | printk(KERN_INFO "%s/2: ============ START LOG STATUS ============\n", |
365 | dev->name); | 365 | dev->name); |
366 | cx25821_call_all(dev, core, log_status); | 366 | cx25821_call_all(dev, core, log_status); |
367 | 367 | ||
368 | tmp = cx_read(sram_ch->dma_ctl); | 368 | tmp = cx_read(sram_ch->dma_ctl); |
369 | printk(KERN_INFO "Video input 6 is %s\n", (tmp & 0x11)?"streaming" : "stopped"); | 369 | printk(KERN_INFO "Video input 6 is %s\n", (tmp & 0x11)?"streaming" : "stopped"); |
370 | printk(KERN_INFO "%s/2: ============= END LOG STATUS =============\n", | 370 | printk(KERN_INFO "%s/2: ============= END LOG STATUS =============\n", |
@@ -376,10 +376,10 @@ static int vidioc_s_ctrl(struct file *file, void *priv, | |||
376 | struct v4l2_control *ctl) | 376 | struct v4l2_control *ctl) |
377 | { | 377 | { |
378 | struct cx25821_fh *fh = priv; | 378 | struct cx25821_fh *fh = priv; |
379 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 379 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
380 | int err; | 380 | int err; |
381 | 381 | ||
382 | if (fh) { | 382 | if (fh) { |
383 | err = v4l2_prio_check(&dev->prio, &fh->prio); | 383 | err = v4l2_prio_check(&dev->prio, &fh->prio); |
384 | if (0 != err) | 384 | if (0 != err) |
385 | return err; | 385 | return err; |
diff --git a/drivers/staging/cx25821/cx25821-video7.c b/drivers/staging/cx25821/cx25821-video7.c index 966e369a4ab..71da80992b6 100644 --- a/drivers/staging/cx25821/cx25821-video7.c +++ b/drivers/staging/cx25821/cx25821-video7.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the Conexant CX25821 PCIe bridge | 2 | * Driver for the Conexant CX25821 PCIe bridge |
3 | * | 3 | * |
4 | * Copyright (C) 2009 Conexant Systems Inc. | 4 | * Copyright (C) 2009 Conexant Systems Inc. |
5 | * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com> | 5 | * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com> |
6 | * Based on Steven Toth <stoth@linuxtv.org> cx23885 driver | 6 | * Based on Steven Toth <stoth@linuxtv.org> cx23885 driver |
7 | * | 7 | * |
@@ -37,39 +37,39 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) | |||
37 | buf->risc.jmp[1] = cpu_to_le32(q->stopper.dma); | 37 | buf->risc.jmp[1] = cpu_to_le32(q->stopper.dma); |
38 | buf->risc.jmp[2] = cpu_to_le32(0); /* bits 63-32 */ | 38 | buf->risc.jmp[2] = cpu_to_le32(0); /* bits 63-32 */ |
39 | 39 | ||
40 | dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]); | 40 | dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]); |
41 | if (!list_empty(&q->queued)) { | 41 | if (!list_empty(&q->queued)) { |
42 | list_add_tail(&buf->vb.queue, &q->queued); | 42 | list_add_tail(&buf->vb.queue, &q->queued); |
43 | buf->vb.state = VIDEOBUF_QUEUED; | 43 | buf->vb.state = VIDEOBUF_QUEUED; |
44 | dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i); | 44 | dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i); |
45 | 45 | ||
46 | } else if (list_empty(&q->active)) { | 46 | } else if (list_empty(&q->active)) { |
47 | list_add_tail(&buf->vb.queue, &q->active); | 47 | list_add_tail(&buf->vb.queue, &q->active); |
48 | cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH07]); | 48 | cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH07]); |
49 | buf->vb.state = VIDEOBUF_ACTIVE; | 49 | buf->vb.state = VIDEOBUF_ACTIVE; |
50 | buf->count = q->count++; | 50 | buf->count = q->count++; |
51 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); | 51 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); |
52 | dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n", | 52 | dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n", |
53 | buf, buf->vb. i, buf->count, q->count); | 53 | buf, buf->vb. i, buf->count, q->count); |
54 | } else { | 54 | } else { |
55 | prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue); | 55 | prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue); |
56 | if (prev->vb.width == buf->vb.width && | 56 | if (prev->vb.width == buf->vb.width && |
57 | prev->vb.height == buf->vb.height && | 57 | prev->vb.height == buf->vb.height && |
58 | prev->fmt == buf->fmt) { | 58 | prev->fmt == buf->fmt) { |
59 | list_add_tail(&buf->vb.queue, &q->active); | 59 | list_add_tail(&buf->vb.queue, &q->active); |
60 | buf->vb.state = VIDEOBUF_ACTIVE; | 60 | buf->vb.state = VIDEOBUF_ACTIVE; |
61 | buf->count = q->count++; | 61 | buf->count = q->count++; |
62 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); | 62 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); |
63 | 63 | ||
64 | /* 64 bit bits 63-32 */ | 64 | /* 64 bit bits 63-32 */ |
65 | prev->risc.jmp[2] = cpu_to_le32(0); | 65 | prev->risc.jmp[2] = cpu_to_le32(0); |
66 | dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count); | 66 | dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count); |
67 | 67 | ||
68 | } else { | 68 | } else { |
69 | list_add_tail(&buf->vb.queue, &q->queued); | 69 | list_add_tail(&buf->vb.queue, &q->queued); |
70 | buf->vb.state = VIDEOBUF_QUEUED; | 70 | buf->vb.state = VIDEOBUF_QUEUED; |
71 | dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i); | 71 | dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i); |
72 | } | 72 | } |
73 | } | 73 | } |
74 | 74 | ||
75 | if (list_empty(&q->active)) | 75 | if (list_empty(&q->active)) |
@@ -99,17 +99,17 @@ static int video_open(struct file *file) | |||
99 | lock_kernel(); | 99 | lock_kernel(); |
100 | list_for_each(list, &cx25821_devlist) | 100 | list_for_each(list, &cx25821_devlist) |
101 | { | 101 | { |
102 | h = list_entry(list, struct cx25821_dev, devlist); | 102 | h = list_entry(list, struct cx25821_dev, devlist); |
103 | 103 | ||
104 | if (h->video_dev[SRAM_CH07] && h->video_dev[SRAM_CH07]->minor == minor) { | 104 | if (h->video_dev[SRAM_CH07] && h->video_dev[SRAM_CH07]->minor == minor) { |
105 | dev = h; | 105 | dev = h; |
106 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 106 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
107 | } | 107 | } |
108 | } | 108 | } |
109 | 109 | ||
110 | if (NULL == dev) { | 110 | if (NULL == dev) { |
111 | unlock_kernel(); | 111 | unlock_kernel(); |
112 | return -ENODEV; | 112 | return -ENODEV; |
113 | } | 113 | } |
114 | 114 | ||
115 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); | 115 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); |
@@ -117,8 +117,8 @@ static int video_open(struct file *file) | |||
117 | /* allocate + initialize per filehandle data */ | 117 | /* allocate + initialize per filehandle data */ |
118 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); | 118 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); |
119 | if (NULL == fh) { | 119 | if (NULL == fh) { |
120 | unlock_kernel(); | 120 | unlock_kernel(); |
121 | return -ENOMEM; | 121 | return -ENOMEM; |
122 | } | 122 | } |
123 | file->private_data = fh; | 123 | file->private_data = fh; |
124 | fh->dev = dev; | 124 | fh->dev = dev; |
@@ -126,22 +126,22 @@ static int video_open(struct file *file) | |||
126 | fh->width = 720; | 126 | fh->width = 720; |
127 | 127 | ||
128 | if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) | 128 | if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) |
129 | fh->height = 576; | 129 | fh->height = 576; |
130 | else | 130 | else |
131 | fh->height = 480; | 131 | fh->height = 480; |
132 | 132 | ||
133 | dev->channel_opened = SRAM_CH07; | 133 | dev->channel_opened = SRAM_CH07; |
134 | pix_format = (dev->pixel_formats[dev->channel_opened] == PIXEL_FRMT_411) ? V4L2_PIX_FMT_Y41P : V4L2_PIX_FMT_YUYV; | 134 | pix_format = (dev->pixel_formats[dev->channel_opened] == PIXEL_FRMT_411) ? V4L2_PIX_FMT_Y41P : V4L2_PIX_FMT_YUYV; |
135 | fh->fmt = format_by_fourcc(pix_format); | 135 | fh->fmt = format_by_fourcc(pix_format); |
136 | 136 | ||
137 | v4l2_prio_open(&dev->prio,&fh->prio); | 137 | v4l2_prio_open(&dev->prio,&fh->prio); |
138 | 138 | ||
139 | videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops, | 139 | videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops, |
140 | &dev->pci->dev, &dev->slock, | 140 | &dev->pci->dev, &dev->slock, |
141 | V4L2_BUF_TYPE_VIDEO_CAPTURE, | 141 | V4L2_BUF_TYPE_VIDEO_CAPTURE, |
142 | V4L2_FIELD_INTERLACED, | 142 | V4L2_FIELD_INTERLACED, |
143 | sizeof(struct cx25821_buffer), | 143 | sizeof(struct cx25821_buffer), |
144 | fh); | 144 | fh); |
145 | 145 | ||
146 | dprintk(1, "post videobuf_queue_init()\n"); | 146 | dprintk(1, "post videobuf_queue_init()\n"); |
147 | unlock_kernel(); | 147 | unlock_kernel(); |
@@ -155,15 +155,15 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo | |||
155 | 155 | ||
156 | switch (fh->type) | 156 | switch (fh->type) |
157 | { | 157 | { |
158 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 158 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
159 | if (res_locked(fh->dev, RESOURCE_VIDEO7)) | 159 | if (res_locked(fh->dev, RESOURCE_VIDEO7)) |
160 | return -EBUSY; | 160 | return -EBUSY; |
161 | 161 | ||
162 | return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK); | 162 | return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK); |
163 | 163 | ||
164 | default: | 164 | default: |
165 | BUG(); | 165 | BUG(); |
166 | return 0; | 166 | return 0; |
167 | } | 167 | } |
168 | } | 168 | } |
169 | 169 | ||
@@ -173,34 +173,34 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait | |||
173 | struct cx25821_buffer *buf; | 173 | struct cx25821_buffer *buf; |
174 | 174 | ||
175 | if (res_check(fh, RESOURCE_VIDEO7)) { | 175 | if (res_check(fh, RESOURCE_VIDEO7)) { |
176 | /* streaming capture */ | 176 | /* streaming capture */ |
177 | if (list_empty(&fh->vidq.stream)) | 177 | if (list_empty(&fh->vidq.stream)) |
178 | return POLLERR; | 178 | return POLLERR; |
179 | buf = list_entry(fh->vidq.stream.next, | 179 | buf = list_entry(fh->vidq.stream.next, |
180 | struct cx25821_buffer, vb.stream); | 180 | struct cx25821_buffer, vb.stream); |
181 | } else { | 181 | } else { |
182 | /* read() capture */ | 182 | /* read() capture */ |
183 | buf = (struct cx25821_buffer *)fh->vidq.read_buf; | 183 | buf = (struct cx25821_buffer *)fh->vidq.read_buf; |
184 | if (NULL == buf) | 184 | if (NULL == buf) |
185 | return POLLERR; | 185 | return POLLERR; |
186 | } | 186 | } |
187 | 187 | ||
188 | poll_wait(file, &buf->vb.done, wait); | 188 | poll_wait(file, &buf->vb.done, wait); |
189 | if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR) | 189 | if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR) |
190 | { | 190 | { |
191 | if( buf->vb.state == VIDEOBUF_DONE ) | 191 | if( buf->vb.state == VIDEOBUF_DONE ) |
192 | { | 192 | { |
193 | struct cx25821_dev *dev = fh->dev; | 193 | struct cx25821_dev *dev = fh->dev; |
194 | 194 | ||
195 | if( dev && dev->use_cif_resolution[SRAM_CH07] ) | 195 | if( dev && dev->use_cif_resolution[SRAM_CH07] ) |
196 | { | 196 | { |
197 | u8 cam_id = *((char*)buf->vb.baddr+3); | 197 | u8 cam_id = *((char*)buf->vb.baddr+3); |
198 | memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2)); | 198 | memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2)); |
199 | *((char*)buf->vb.baddr+3) = cam_id; | 199 | *((char*)buf->vb.baddr+3) = cam_id; |
200 | } | 200 | } |
201 | } | 201 | } |
202 | 202 | ||
203 | return POLLIN|POLLRDNORM; | 203 | return POLLIN|POLLRDNORM; |
204 | } | 204 | } |
205 | 205 | ||
206 | return 0; | 206 | return 0; |
@@ -217,13 +217,13 @@ static int video_release(struct file *file) | |||
217 | 217 | ||
218 | /* stop video capture */ | 218 | /* stop video capture */ |
219 | if (res_check(fh, RESOURCE_VIDEO7)) { | 219 | if (res_check(fh, RESOURCE_VIDEO7)) { |
220 | videobuf_queue_cancel(&fh->vidq); | 220 | videobuf_queue_cancel(&fh->vidq); |
221 | res_free(dev, fh, RESOURCE_VIDEO7); | 221 | res_free(dev, fh, RESOURCE_VIDEO7); |
222 | } | 222 | } |
223 | 223 | ||
224 | if (fh->vidq.read_buf) { | 224 | if (fh->vidq.read_buf) { |
225 | buffer_release(&fh->vidq, fh->vidq.read_buf); | 225 | buffer_release(&fh->vidq, fh->vidq.read_buf); |
226 | kfree(fh->vidq.read_buf); | 226 | kfree(fh->vidq.read_buf); |
227 | } | 227 | } |
228 | 228 | ||
229 | videobuf_mmap_free(&fh->vidq); | 229 | videobuf_mmap_free(&fh->vidq); |
@@ -243,17 +243,17 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) | |||
243 | 243 | ||
244 | if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) | 244 | if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) |
245 | { | 245 | { |
246 | return -EINVAL; | 246 | return -EINVAL; |
247 | } | 247 | } |
248 | 248 | ||
249 | if (unlikely(i != fh->type)) | 249 | if (unlikely(i != fh->type)) |
250 | { | 250 | { |
251 | return -EINVAL; | 251 | return -EINVAL; |
252 | } | 252 | } |
253 | 253 | ||
254 | if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO7)))) | 254 | if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO7)))) |
255 | { | 255 | { |
256 | return -EBUSY; | 256 | return -EBUSY; |
257 | } | 257 | } |
258 | 258 | ||
259 | return videobuf_streamon(get_queue(fh)); | 259 | return videobuf_streamon(get_queue(fh)); |
@@ -266,14 +266,14 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) | |||
266 | int err, res; | 266 | int err, res; |
267 | 267 | ||
268 | if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 268 | if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
269 | return -EINVAL; | 269 | return -EINVAL; |
270 | if (i != fh->type) | 270 | if (i != fh->type) |
271 | return -EINVAL; | 271 | return -EINVAL; |
272 | 272 | ||
273 | res = get_resource(fh, RESOURCE_VIDEO7); | 273 | res = get_resource(fh, RESOURCE_VIDEO7); |
274 | err = videobuf_streamoff(get_queue(fh)); | 274 | err = videobuf_streamoff(get_queue(fh)); |
275 | if (err < 0) | 275 | if (err < 0) |
276 | return err; | 276 | return err; |
277 | res_free(dev, fh, res); | 277 | res_free(dev, fh, res); |
278 | return 0; | 278 | return 0; |
279 | } | 279 | } |
@@ -283,13 +283,13 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma | |||
283 | { | 283 | { |
284 | struct cx25821_fh *fh = priv; | 284 | struct cx25821_fh *fh = priv; |
285 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 285 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
286 | int err; | 286 | int err; |
287 | int pix_format = 0; | 287 | int pix_format = 0; |
288 | 288 | ||
289 | if (fh) | 289 | if (fh) |
290 | { | 290 | { |
291 | err = v4l2_prio_check(&dev->prio, &fh->prio); | 291 | err = v4l2_prio_check(&dev->prio, &fh->prio); |
292 | if (0 != err) | 292 | if (0 != err) |
293 | return err; | 293 | return err; |
294 | } | 294 | } |
295 | 295 | ||
@@ -297,7 +297,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma | |||
297 | err = vidioc_try_fmt_vid_cap(file, priv, f); | 297 | err = vidioc_try_fmt_vid_cap(file, priv, f); |
298 | 298 | ||
299 | if (0 != err) | 299 | if (0 != err) |
300 | return err; | 300 | return err; |
301 | 301 | ||
302 | fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); | 302 | fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); |
303 | fh->vidq.field = f->fmt.pix.field; | 303 | fh->vidq.field = f->fmt.pix.field; |
@@ -305,33 +305,33 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma | |||
305 | // check if width and height is valid based on set standard | 305 | // check if width and height is valid based on set standard |
306 | if (is_valid_width(f->fmt.pix.width, dev->tvnorm)) | 306 | if (is_valid_width(f->fmt.pix.width, dev->tvnorm)) |
307 | { | 307 | { |
308 | fh->width = f->fmt.pix.width; | 308 | fh->width = f->fmt.pix.width; |
309 | } | 309 | } |
310 | 310 | ||
311 | if (is_valid_height(f->fmt.pix.height, dev->tvnorm)) | 311 | if (is_valid_height(f->fmt.pix.height, dev->tvnorm)) |
312 | { | 312 | { |
313 | fh->height = f->fmt.pix.height; | 313 | fh->height = f->fmt.pix.height; |
314 | } | 314 | } |
315 | 315 | ||
316 | if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P) | 316 | if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P) |
317 | pix_format = PIXEL_FRMT_411; | 317 | pix_format = PIXEL_FRMT_411; |
318 | else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV) | 318 | else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV) |
319 | pix_format = PIXEL_FRMT_422; | 319 | pix_format = PIXEL_FRMT_422; |
320 | else | 320 | else |
321 | return -EINVAL; | 321 | return -EINVAL; |
322 | |||
323 | cx25821_set_pixel_format( dev, SRAM_CH07, pix_format ); | ||
322 | 324 | ||
323 | cx25821_set_pixel_format( dev, SRAM_CH07, pix_format ); | ||
324 | |||
325 | // check if cif resolution | 325 | // check if cif resolution |
326 | if (fh->width == 320 || fh->width == 352) | 326 | if (fh->width == 320 || fh->width == 352) |
327 | { | 327 | { |
328 | dev->use_cif_resolution[SRAM_CH07] = 1; | 328 | dev->use_cif_resolution[SRAM_CH07] = 1; |
329 | }else | 329 | }else |
330 | { | 330 | { |
331 | dev->use_cif_resolution[SRAM_CH07] = 0; | 331 | dev->use_cif_resolution[SRAM_CH07] = 0; |
332 | } | 332 | } |
333 | dev->cif_width[SRAM_CH07] = fh->width; | 333 | dev->cif_width[SRAM_CH07] = fh->width; |
334 | medusa_set_resolution( dev, fh->width, SRAM_CH07 ); | 334 | medusa_set_resolution( dev, fh->width, SRAM_CH07 ); |
335 | 335 | ||
336 | dprintk(2, "%s() width=%d height=%d field=%d\n", __func__, fh->width, fh->height, fh->vidq.field); | 336 | dprintk(2, "%s() width=%d height=%d field=%d\n", __func__, fh->width, fh->height, fh->vidq.field); |
337 | cx25821_call_all(dev, video, s_fmt, f); | 337 | cx25821_call_all(dev, video, s_fmt, f); |
@@ -345,7 +345,7 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p) | |||
345 | struct cx25821_fh *fh = priv; | 345 | struct cx25821_fh *fh = priv; |
346 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 346 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
347 | 347 | ||
348 | ret_val = videobuf_dqbuf(get_queue(fh), p, file->f_flags & O_NONBLOCK); | 348 | ret_val = videobuf_dqbuf(get_queue(fh), p, file->f_flags & O_NONBLOCK); |
349 | 349 | ||
350 | p->sequence = dev->vidq[SRAM_CH07].count; | 350 | p->sequence = dev->vidq[SRAM_CH07].count; |
351 | 351 | ||
@@ -356,14 +356,14 @@ static int vidioc_log_status (struct file *file, void *priv) | |||
356 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 356 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
357 | char name[32 + 2]; | 357 | char name[32 + 2]; |
358 | 358 | ||
359 | struct sram_channel *sram_ch = &dev->sram_channels[SRAM_CH07]; | 359 | struct sram_channel *sram_ch = &dev->sram_channels[SRAM_CH07]; |
360 | u32 tmp = 0; | 360 | u32 tmp = 0; |
361 | 361 | ||
362 | snprintf(name, sizeof(name), "%s/2", dev->name); | 362 | snprintf(name, sizeof(name), "%s/2", dev->name); |
363 | printk(KERN_INFO "%s/2: ============ START LOG STATUS ============\n", | 363 | printk(KERN_INFO "%s/2: ============ START LOG STATUS ============\n", |
364 | dev->name); | 364 | dev->name); |
365 | cx25821_call_all(dev, core, log_status); | 365 | cx25821_call_all(dev, core, log_status); |
366 | 366 | ||
367 | tmp = cx_read(sram_ch->dma_ctl); | 367 | tmp = cx_read(sram_ch->dma_ctl); |
368 | printk(KERN_INFO "Video input 7 is %s\n", (tmp & 0x11)?"streaming" : "stopped"); | 368 | printk(KERN_INFO "Video input 7 is %s\n", (tmp & 0x11)?"streaming" : "stopped"); |
369 | printk(KERN_INFO "%s/2: ============= END LOG STATUS =============\n", | 369 | printk(KERN_INFO "%s/2: ============= END LOG STATUS =============\n", |
@@ -375,10 +375,10 @@ static int vidioc_s_ctrl(struct file *file, void *priv, | |||
375 | struct v4l2_control *ctl) | 375 | struct v4l2_control *ctl) |
376 | { | 376 | { |
377 | struct cx25821_fh *fh = priv; | 377 | struct cx25821_fh *fh = priv; |
378 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 378 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
379 | int err; | 379 | int err; |
380 | 380 | ||
381 | if (fh) { | 381 | if (fh) { |
382 | err = v4l2_prio_check(&dev->prio, &fh->prio); | 382 | err = v4l2_prio_check(&dev->prio, &fh->prio); |
383 | if (0 != err) | 383 | if (0 != err) |
384 | return err; | 384 | return err; |
diff --git a/drivers/staging/cx25821/cx25821-videoioctl.c b/drivers/staging/cx25821/cx25821-videoioctl.c index a5363e486f7..ca93cd2af2d 100644 --- a/drivers/staging/cx25821/cx25821-videoioctl.c +++ b/drivers/staging/cx25821/cx25821-videoioctl.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the Conexant CX25821 PCIe bridge | 2 | * Driver for the Conexant CX25821 PCIe bridge |
3 | * | 3 | * |
4 | * Copyright (C) 2009 Conexant Systems Inc. | 4 | * Copyright (C) 2009 Conexant Systems Inc. |
5 | * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com> | 5 | * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com> |
6 | * Based on Steven Toth <stoth@linuxtv.org> cx23885 driver | 6 | * Based on Steven Toth <stoth@linuxtv.org> cx23885 driver |
7 | * | 7 | * |
@@ -40,37 +40,37 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) | |||
40 | dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]); | 40 | dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]); |
41 | 41 | ||
42 | if (!list_empty(&q->queued)) { | 42 | if (!list_empty(&q->queued)) { |
43 | list_add_tail(&buf->vb.queue, &q->queued); | 43 | list_add_tail(&buf->vb.queue, &q->queued); |
44 | buf->vb.state = VIDEOBUF_QUEUED; | 44 | buf->vb.state = VIDEOBUF_QUEUED; |
45 | dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i); | 45 | dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i); |
46 | 46 | ||
47 | } else if (list_empty(&q->active)) { | 47 | } else if (list_empty(&q->active)) { |
48 | list_add_tail(&buf->vb.queue, &q->active); | 48 | list_add_tail(&buf->vb.queue, &q->active); |
49 | cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[VIDEO_IOCTL_CH]); | 49 | cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[VIDEO_IOCTL_CH]); |
50 | buf->vb.state = VIDEOBUF_ACTIVE; | 50 | buf->vb.state = VIDEOBUF_ACTIVE; |
51 | buf->count = q->count++; | 51 | buf->count = q->count++; |
52 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); | 52 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); |
53 | dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n", | 53 | dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n", |
54 | buf, buf->vb. i, buf->count, q->count); | 54 | buf, buf->vb. i, buf->count, q->count); |
55 | } else { | 55 | } else { |
56 | prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue); | 56 | prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue); |
57 | if (prev->vb.width == buf->vb.width && | 57 | if (prev->vb.width == buf->vb.width && |
58 | prev->vb.height == buf->vb.height && | 58 | prev->vb.height == buf->vb.height && |
59 | prev->fmt == buf->fmt) { | 59 | prev->fmt == buf->fmt) { |
60 | list_add_tail(&buf->vb.queue, &q->active); | 60 | list_add_tail(&buf->vb.queue, &q->active); |
61 | buf->vb.state = VIDEOBUF_ACTIVE; | 61 | buf->vb.state = VIDEOBUF_ACTIVE; |
62 | buf->count = q->count++; | 62 | buf->count = q->count++; |
63 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); | 63 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); |
64 | 64 | ||
65 | /* 64 bit bits 63-32 */ | 65 | /* 64 bit bits 63-32 */ |
66 | prev->risc.jmp[2] = cpu_to_le32(0); | 66 | prev->risc.jmp[2] = cpu_to_le32(0); |
67 | dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count); | 67 | dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count); |
68 | 68 | ||
69 | } else { | 69 | } else { |
70 | list_add_tail(&buf->vb.queue, &q->queued); | 70 | list_add_tail(&buf->vb.queue, &q->queued); |
71 | buf->vb.state = VIDEOBUF_QUEUED; | 71 | buf->vb.state = VIDEOBUF_QUEUED; |
72 | dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i); | 72 | dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i); |
73 | } | 73 | } |
74 | } | 74 | } |
75 | 75 | ||
76 | if (list_empty(&q->active)) | 76 | if (list_empty(&q->active)) |
@@ -100,18 +100,18 @@ static int video_open(struct file *file) | |||
100 | lock_kernel(); | 100 | lock_kernel(); |
101 | list_for_each(list, &cx25821_devlist) | 101 | list_for_each(list, &cx25821_devlist) |
102 | { | 102 | { |
103 | h = list_entry(list, struct cx25821_dev, devlist); | 103 | h = list_entry(list, struct cx25821_dev, devlist); |
104 | 104 | ||
105 | if (h->ioctl_dev && h->ioctl_dev->minor == minor) | 105 | if (h->ioctl_dev && h->ioctl_dev->minor == minor) |
106 | { | 106 | { |
107 | dev = h; | 107 | dev = h; |
108 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 108 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
109 | } | 109 | } |
110 | } | 110 | } |
111 | 111 | ||
112 | if (NULL == dev) { | 112 | if (NULL == dev) { |
113 | unlock_kernel(); | 113 | unlock_kernel(); |
114 | return -ENODEV; | 114 | return -ENODEV; |
115 | } | 115 | } |
116 | 116 | ||
117 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); | 117 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); |
@@ -119,8 +119,8 @@ static int video_open(struct file *file) | |||
119 | /* allocate + initialize per filehandle data */ | 119 | /* allocate + initialize per filehandle data */ |
120 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); | 120 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); |
121 | if (NULL == fh) { | 121 | if (NULL == fh) { |
122 | unlock_kernel(); | 122 | unlock_kernel(); |
123 | return -ENOMEM; | 123 | return -ENOMEM; |
124 | } | 124 | } |
125 | 125 | ||
126 | file->private_data = fh; | 126 | file->private_data = fh; |
@@ -129,22 +129,22 @@ static int video_open(struct file *file) | |||
129 | fh->width = 720; | 129 | fh->width = 720; |
130 | 130 | ||
131 | if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) | 131 | if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) |
132 | fh->height = 576; | 132 | fh->height = 576; |
133 | else | 133 | else |
134 | fh->height = 480; | 134 | fh->height = 480; |
135 | 135 | ||
136 | dev->channel_opened = VIDEO_IOCTL_CH; | 136 | dev->channel_opened = VIDEO_IOCTL_CH; |
137 | pix_format = V4L2_PIX_FMT_YUYV; | 137 | pix_format = V4L2_PIX_FMT_YUYV; |
138 | fh->fmt = format_by_fourcc(pix_format); | 138 | fh->fmt = format_by_fourcc(pix_format); |
139 | 139 | ||
140 | v4l2_prio_open(&dev->prio,&fh->prio); | 140 | v4l2_prio_open(&dev->prio,&fh->prio); |
141 | 141 | ||
142 | videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops, | 142 | videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops, |
143 | &dev->pci->dev, &dev->slock, | 143 | &dev->pci->dev, &dev->slock, |
144 | V4L2_BUF_TYPE_VIDEO_CAPTURE, | 144 | V4L2_BUF_TYPE_VIDEO_CAPTURE, |
145 | V4L2_FIELD_INTERLACED, | 145 | V4L2_FIELD_INTERLACED, |
146 | sizeof(struct cx25821_buffer), | 146 | sizeof(struct cx25821_buffer), |
147 | fh); | 147 | fh); |
148 | 148 | ||
149 | dprintk(1, "post videobuf_queue_init()\n"); | 149 | dprintk(1, "post videobuf_queue_init()\n"); |
150 | unlock_kernel(); | 150 | unlock_kernel(); |
@@ -158,15 +158,15 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo | |||
158 | 158 | ||
159 | switch (fh->type) | 159 | switch (fh->type) |
160 | { | 160 | { |
161 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 161 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
162 | if (res_locked(fh->dev, RESOURCE_VIDEO_IOCTL)) | 162 | if (res_locked(fh->dev, RESOURCE_VIDEO_IOCTL)) |
163 | return -EBUSY; | 163 | return -EBUSY; |
164 | 164 | ||
165 | return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK); | 165 | return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK); |
166 | 166 | ||
167 | default: | 167 | default: |
168 | BUG(); | 168 | BUG(); |
169 | return 0; | 169 | return 0; |
170 | } | 170 | } |
171 | } | 171 | } |
172 | 172 | ||
@@ -176,22 +176,22 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait | |||
176 | struct cx25821_buffer *buf; | 176 | struct cx25821_buffer *buf; |
177 | 177 | ||
178 | if (res_check(fh, RESOURCE_VIDEO_IOCTL)) { | 178 | if (res_check(fh, RESOURCE_VIDEO_IOCTL)) { |
179 | /* streaming capture */ | 179 | /* streaming capture */ |
180 | if (list_empty(&fh->vidq.stream)) | 180 | if (list_empty(&fh->vidq.stream)) |
181 | return POLLERR; | 181 | return POLLERR; |
182 | buf = list_entry(fh->vidq.stream.next, | 182 | buf = list_entry(fh->vidq.stream.next, |
183 | struct cx25821_buffer, vb.stream); | 183 | struct cx25821_buffer, vb.stream); |
184 | } else { | 184 | } else { |
185 | /* read() capture */ | 185 | /* read() capture */ |
186 | buf = (struct cx25821_buffer *)fh->vidq.read_buf; | 186 | buf = (struct cx25821_buffer *)fh->vidq.read_buf; |
187 | if (NULL == buf) | 187 | if (NULL == buf) |
188 | return POLLERR; | 188 | return POLLERR; |
189 | } | 189 | } |
190 | 190 | ||
191 | poll_wait(file, &buf->vb.done, wait); | 191 | poll_wait(file, &buf->vb.done, wait); |
192 | if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR) | 192 | if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR) |
193 | return POLLIN|POLLRDNORM; | 193 | return POLLIN|POLLRDNORM; |
194 | 194 | ||
195 | return 0; | 195 | return 0; |
196 | } | 196 | } |
197 | 197 | ||
@@ -199,17 +199,17 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait | |||
199 | static int video_release(struct file *file) | 199 | static int video_release(struct file *file) |
200 | { | 200 | { |
201 | struct cx25821_fh *fh = file->private_data; | 201 | struct cx25821_fh *fh = file->private_data; |
202 | struct cx25821_dev *dev = fh->dev; | 202 | struct cx25821_dev *dev = fh->dev; |
203 | 203 | ||
204 | /* stop video capture */ | 204 | /* stop video capture */ |
205 | if (res_check(fh, RESOURCE_VIDEO_IOCTL)) { | 205 | if (res_check(fh, RESOURCE_VIDEO_IOCTL)) { |
206 | videobuf_queue_cancel(&fh->vidq); | 206 | videobuf_queue_cancel(&fh->vidq); |
207 | res_free(dev, fh, RESOURCE_VIDEO_IOCTL); | 207 | res_free(dev, fh, RESOURCE_VIDEO_IOCTL); |
208 | } | 208 | } |
209 | 209 | ||
210 | if (fh->vidq.read_buf) { | 210 | if (fh->vidq.read_buf) { |
211 | buffer_release(&fh->vidq, fh->vidq.read_buf); | 211 | buffer_release(&fh->vidq, fh->vidq.read_buf); |
212 | kfree(fh->vidq.read_buf); | 212 | kfree(fh->vidq.read_buf); |
213 | } | 213 | } |
214 | 214 | ||
215 | videobuf_mmap_free(&fh->vidq); | 215 | videobuf_mmap_free(&fh->vidq); |
@@ -230,17 +230,17 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) | |||
230 | 230 | ||
231 | if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) | 231 | if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) |
232 | { | 232 | { |
233 | return -EINVAL; | 233 | return -EINVAL; |
234 | } | 234 | } |
235 | 235 | ||
236 | if (unlikely(i != fh->type)) | 236 | if (unlikely(i != fh->type)) |
237 | { | 237 | { |
238 | return -EINVAL; | 238 | return -EINVAL; |
239 | } | 239 | } |
240 | 240 | ||
241 | if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO_IOCTL)))) | 241 | if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO_IOCTL)))) |
242 | { | 242 | { |
243 | return -EBUSY; | 243 | return -EBUSY; |
244 | } | 244 | } |
245 | 245 | ||
246 | return videobuf_streamon(get_queue(fh)); | 246 | return videobuf_streamon(get_queue(fh)); |
@@ -253,14 +253,14 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) | |||
253 | int err, res; | 253 | int err, res; |
254 | 254 | ||
255 | if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 255 | if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
256 | return -EINVAL; | 256 | return -EINVAL; |
257 | if (i != fh->type) | 257 | if (i != fh->type) |
258 | return -EINVAL; | 258 | return -EINVAL; |
259 | 259 | ||
260 | res = get_resource(fh, RESOURCE_VIDEO_IOCTL); | 260 | res = get_resource(fh, RESOURCE_VIDEO_IOCTL); |
261 | err = videobuf_streamoff(get_queue(fh)); | 261 | err = videobuf_streamoff(get_queue(fh)); |
262 | if (err < 0) | 262 | if (err < 0) |
263 | return err; | 263 | return err; |
264 | res_free(dev, fh, res); | 264 | res_free(dev, fh, res); |
265 | return 0; | 265 | return 0; |
266 | } | 266 | } |
@@ -272,18 +272,18 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma | |||
272 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 272 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
273 | int err; | 273 | int err; |
274 | 274 | ||
275 | if (fh) | 275 | if (fh) |
276 | { | 276 | { |
277 | err = v4l2_prio_check(&dev->prio, &fh->prio); | 277 | err = v4l2_prio_check(&dev->prio, &fh->prio); |
278 | if (0 != err) | 278 | if (0 != err) |
279 | return err; | 279 | return err; |
280 | } | 280 | } |
281 | 281 | ||
282 | dprintk(2, "%s()\n", __func__); | 282 | dprintk(2, "%s()\n", __func__); |
283 | err = vidioc_try_fmt_vid_cap(file, priv, f); | 283 | err = vidioc_try_fmt_vid_cap(file, priv, f); |
284 | 284 | ||
285 | if (0 != err) | 285 | if (0 != err) |
286 | return err; | 286 | return err; |
287 | fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); | 287 | fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); |
288 | fh->width = f->fmt.pix.width; | 288 | fh->width = f->fmt.pix.width; |
289 | fh->height = f->fmt.pix.height; | 289 | fh->height = f->fmt.pix.height; |
@@ -299,8 +299,8 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p) | |||
299 | return videobuf_dqbuf(get_queue(fh), p, file->f_flags & O_NONBLOCK); | 299 | return videobuf_dqbuf(get_queue(fh), p, file->f_flags & O_NONBLOCK); |
300 | } | 300 | } |
301 | 301 | ||
302 | static long video_ioctl_set(struct file *file, unsigned int cmd, unsigned long arg) | 302 | static long video_ioctl_set(struct file *file, unsigned int cmd, unsigned long arg) |
303 | { | 303 | { |
304 | struct cx25821_fh *fh = file->private_data; | 304 | struct cx25821_fh *fh = file->private_data; |
305 | struct cx25821_dev *dev = fh->dev; | 305 | struct cx25821_dev *dev = fh->dev; |
306 | struct downstream_user_struct *data_from_user; | 306 | struct downstream_user_struct *data_from_user; |
@@ -310,96 +310,96 @@ static long video_ioctl_set(struct file *file, unsigned int cmd, unsigned long a | |||
310 | int cif_enable = 0, cif_width = 0; | 310 | int cif_enable = 0, cif_width = 0; |
311 | u32 value = 0; | 311 | u32 value = 0; |
312 | 312 | ||
313 | 313 | ||
314 | data_from_user = (struct downstream_user_struct *)arg; | 314 | data_from_user = (struct downstream_user_struct *)arg; |
315 | 315 | ||
316 | if( !data_from_user ) | 316 | if( !data_from_user ) |
317 | { | 317 | { |
318 | printk("cx25821 in %s(): User data is INVALID. Returning.\n", __func__); | 318 | printk("cx25821 in %s(): User data is INVALID. Returning.\n", __func__); |
319 | return 0; | 319 | return 0; |
320 | } | 320 | } |
321 | 321 | ||
322 | command = data_from_user->command; | 322 | command = data_from_user->command; |
323 | 323 | ||
324 | if( command != SET_VIDEO_STD && command != SET_PIXEL_FORMAT && command != ENABLE_CIF_RESOLUTION && | 324 | if( command != SET_VIDEO_STD && command != SET_PIXEL_FORMAT && command != ENABLE_CIF_RESOLUTION && |
325 | command != REG_READ && command != REG_WRITE && command != MEDUSA_READ && command != MEDUSA_WRITE) | 325 | command != REG_READ && command != REG_WRITE && command != MEDUSA_READ && command != MEDUSA_WRITE) |
326 | { | 326 | { |
327 | return 0; | 327 | return 0; |
328 | } | 328 | } |
329 | 329 | ||
330 | 330 | ||
331 | switch(command) | 331 | switch(command) |
332 | { | 332 | { |
333 | case SET_VIDEO_STD: | 333 | case SET_VIDEO_STD: |
334 | dev->tvnorm = !strcmp(data_from_user->vid_stdname,"PAL") ? V4L2_STD_PAL_BG : V4L2_STD_NTSC_M; | 334 | dev->tvnorm = !strcmp(data_from_user->vid_stdname,"PAL") ? V4L2_STD_PAL_BG : V4L2_STD_NTSC_M; |
335 | medusa_set_videostandard(dev); | 335 | medusa_set_videostandard(dev); |
336 | break; | 336 | break; |
337 | 337 | ||
338 | case SET_PIXEL_FORMAT: | 338 | case SET_PIXEL_FORMAT: |
339 | selected_channel = data_from_user->decoder_select; | 339 | selected_channel = data_from_user->decoder_select; |
340 | pix_format = data_from_user->pixel_format; | 340 | pix_format = data_from_user->pixel_format; |
341 | 341 | ||
342 | if( !(selected_channel <= 7 && selected_channel >= 0) ) | 342 | if( !(selected_channel <= 7 && selected_channel >= 0) ) |
343 | { | 343 | { |
344 | selected_channel -= 4; | 344 | selected_channel -= 4; |
345 | selected_channel = selected_channel % 8; | 345 | selected_channel = selected_channel % 8; |
346 | } | 346 | } |
347 | 347 | ||
348 | if( selected_channel >= 0 ) | 348 | if( selected_channel >= 0 ) |
349 | cx25821_set_pixel_format( dev, selected_channel, pix_format ); | 349 | cx25821_set_pixel_format( dev, selected_channel, pix_format ); |
350 | 350 | ||
351 | break; | 351 | break; |
352 | 352 | ||
353 | case ENABLE_CIF_RESOLUTION: | 353 | case ENABLE_CIF_RESOLUTION: |
354 | selected_channel = data_from_user->decoder_select; | 354 | selected_channel = data_from_user->decoder_select; |
355 | cif_enable = data_from_user->cif_resolution_enable; | 355 | cif_enable = data_from_user->cif_resolution_enable; |
356 | cif_width = data_from_user->cif_width; | 356 | cif_width = data_from_user->cif_width; |
357 | 357 | ||
358 | if( cif_enable ) | 358 | if( cif_enable ) |
359 | { | 359 | { |
360 | if( dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK ) | 360 | if( dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK ) |
361 | width = 352; | 361 | width = 352; |
362 | else | 362 | else |
363 | width = (cif_width == 320 || cif_width == 352) ? cif_width : 320; | 363 | width = (cif_width == 320 || cif_width == 352) ? cif_width : 320; |
364 | } | 364 | } |
365 | 365 | ||
366 | if( !(selected_channel <= 7 && selected_channel >= 0) ) | 366 | if( !(selected_channel <= 7 && selected_channel >= 0) ) |
367 | { | 367 | { |
368 | selected_channel -= 4; | 368 | selected_channel -= 4; |
369 | selected_channel = selected_channel % 8; | 369 | selected_channel = selected_channel % 8; |
370 | } | 370 | } |
371 | 371 | ||
372 | 372 | ||
373 | if( selected_channel <= 7 && selected_channel >= 0 ) | 373 | if( selected_channel <= 7 && selected_channel >= 0 ) |
374 | { | 374 | { |
375 | dev->use_cif_resolution[selected_channel] = cif_enable; | 375 | dev->use_cif_resolution[selected_channel] = cif_enable; |
376 | dev->cif_width[selected_channel] = width; | 376 | dev->cif_width[selected_channel] = width; |
377 | } | 377 | } |
378 | else | 378 | else |
379 | { | 379 | { |
380 | for( i=0; i < VID_CHANNEL_NUM; i++ ) | 380 | for( i=0; i < VID_CHANNEL_NUM; i++ ) |
381 | { | 381 | { |
382 | dev->use_cif_resolution[i] = cif_enable; | 382 | dev->use_cif_resolution[i] = cif_enable; |
383 | dev->cif_width[i] = width; | 383 | dev->cif_width[i] = width; |
384 | } | 384 | } |
385 | } | 385 | } |
386 | 386 | ||
387 | medusa_set_resolution( dev, width, selected_channel ); | 387 | medusa_set_resolution( dev, width, selected_channel ); |
388 | break; | 388 | break; |
389 | case REG_READ: | 389 | case REG_READ: |
390 | data_from_user->reg_data = cx_read(data_from_user->reg_address); | 390 | data_from_user->reg_data = cx_read(data_from_user->reg_address); |
391 | break; | 391 | break; |
392 | case REG_WRITE: | 392 | case REG_WRITE: |
393 | cx_write(data_from_user->reg_address, data_from_user->reg_data); | 393 | cx_write(data_from_user->reg_address, data_from_user->reg_data); |
394 | break; | 394 | break; |
395 | case MEDUSA_READ: | 395 | case MEDUSA_READ: |
396 | value = cx25821_i2c_read(&dev->i2c_bus[0], (u16)data_from_user->reg_address, &data_from_user->reg_data); | 396 | value = cx25821_i2c_read(&dev->i2c_bus[0], (u16)data_from_user->reg_address, &data_from_user->reg_data); |
397 | break; | 397 | break; |
398 | case MEDUSA_WRITE: | 398 | case MEDUSA_WRITE: |
399 | cx25821_i2c_write(&dev->i2c_bus[0], (u16)data_from_user->reg_address, data_from_user->reg_data); | 399 | cx25821_i2c_write(&dev->i2c_bus[0], (u16)data_from_user->reg_address, data_from_user->reg_data); |
400 | break; | 400 | break; |
401 | } | 401 | } |
402 | 402 | ||
403 | return 0; | 403 | return 0; |
404 | } | 404 | } |
405 | 405 | ||
@@ -423,12 +423,12 @@ static int vidioc_s_ctrl(struct file *file, void *priv, | |||
423 | struct cx25821_fh *fh = priv; | 423 | struct cx25821_fh *fh = priv; |
424 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 424 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
425 | int err; | 425 | int err; |
426 | 426 | ||
427 | if (fh) | 427 | if (fh) |
428 | { | 428 | { |
429 | err = v4l2_prio_check(&dev->prio, &fh->prio); | 429 | err = v4l2_prio_check(&dev->prio, &fh->prio); |
430 | if (0 != err) | 430 | if (0 != err) |
431 | return err; | 431 | return err; |
432 | } | 432 | } |
433 | 433 | ||
434 | return 0; | 434 | return 0; |
diff --git a/drivers/staging/cx25821/cx25821-vidups10.c b/drivers/staging/cx25821/cx25821-vidups10.c index 4738e9184a8..1e18a87669b 100644 --- a/drivers/staging/cx25821/cx25821-vidups10.c +++ b/drivers/staging/cx25821/cx25821-vidups10.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the Conexant CX25821 PCIe bridge | 2 | * Driver for the Conexant CX25821 PCIe bridge |
3 | * | 3 | * |
4 | * Copyright (C) 2009 Conexant Systems Inc. | 4 | * Copyright (C) 2009 Conexant Systems Inc. |
5 | * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com> | 5 | * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com> |
6 | * Based on Steven Toth <stoth@linuxtv.org> cx23885 driver | 6 | * Based on Steven Toth <stoth@linuxtv.org> cx23885 driver |
7 | * | 7 | * |
@@ -41,37 +41,37 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) | |||
41 | dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]); | 41 | dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]); |
42 | 42 | ||
43 | if (!list_empty(&q->queued)) { | 43 | if (!list_empty(&q->queued)) { |
44 | list_add_tail(&buf->vb.queue, &q->queued); | 44 | list_add_tail(&buf->vb.queue, &q->queued); |
45 | buf->vb.state = VIDEOBUF_QUEUED; | 45 | buf->vb.state = VIDEOBUF_QUEUED; |
46 | dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i); | 46 | dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i); |
47 | 47 | ||
48 | } else if (list_empty(&q->active)) { | 48 | } else if (list_empty(&q->active)) { |
49 | list_add_tail(&buf->vb.queue, &q->active); | 49 | list_add_tail(&buf->vb.queue, &q->active); |
50 | cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH10]); | 50 | cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH10]); |
51 | buf->vb.state = VIDEOBUF_ACTIVE; | 51 | buf->vb.state = VIDEOBUF_ACTIVE; |
52 | buf->count = q->count++; | 52 | buf->count = q->count++; |
53 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); | 53 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); |
54 | dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n", | 54 | dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n", |
55 | buf, buf->vb. i, buf->count, q->count); | 55 | buf, buf->vb. i, buf->count, q->count); |
56 | } else { | 56 | } else { |
57 | prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue); | 57 | prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue); |
58 | if (prev->vb.width == buf->vb.width && | 58 | if (prev->vb.width == buf->vb.width && |
59 | prev->vb.height == buf->vb.height && | 59 | prev->vb.height == buf->vb.height && |
60 | prev->fmt == buf->fmt) { | 60 | prev->fmt == buf->fmt) { |
61 | list_add_tail(&buf->vb.queue, &q->active); | 61 | list_add_tail(&buf->vb.queue, &q->active); |
62 | buf->vb.state = VIDEOBUF_ACTIVE; | 62 | buf->vb.state = VIDEOBUF_ACTIVE; |
63 | buf->count = q->count++; | 63 | buf->count = q->count++; |
64 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); | 64 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); |
65 | 65 | ||
66 | /* 64 bit bits 63-32 */ | 66 | /* 64 bit bits 63-32 */ |
67 | prev->risc.jmp[2] = cpu_to_le32(0); | 67 | prev->risc.jmp[2] = cpu_to_le32(0); |
68 | dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count); | 68 | dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count); |
69 | 69 | ||
70 | } else { | 70 | } else { |
71 | list_add_tail(&buf->vb.queue, &q->queued); | 71 | list_add_tail(&buf->vb.queue, &q->queued); |
72 | buf->vb.state = VIDEOBUF_QUEUED; | 72 | buf->vb.state = VIDEOBUF_QUEUED; |
73 | dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i); | 73 | dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i); |
74 | } | 74 | } |
75 | } | 75 | } |
76 | 76 | ||
77 | if (list_empty(&q->active)) | 77 | if (list_empty(&q->active)) |
@@ -100,17 +100,17 @@ static int video_open(struct file *file) | |||
100 | lock_kernel(); | 100 | lock_kernel(); |
101 | list_for_each(list, &cx25821_devlist) | 101 | list_for_each(list, &cx25821_devlist) |
102 | { | 102 | { |
103 | h = list_entry(list, struct cx25821_dev, devlist); | 103 | h = list_entry(list, struct cx25821_dev, devlist); |
104 | 104 | ||
105 | if (h->video_dev[SRAM_CH10] && h->video_dev[SRAM_CH10]->minor == minor) { | 105 | if (h->video_dev[SRAM_CH10] && h->video_dev[SRAM_CH10]->minor == minor) { |
106 | dev = h; | 106 | dev = h; |
107 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 107 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
108 | } | 108 | } |
109 | } | 109 | } |
110 | 110 | ||
111 | if (NULL == dev) { | 111 | if (NULL == dev) { |
112 | unlock_kernel(); | 112 | unlock_kernel(); |
113 | return -ENODEV; | 113 | return -ENODEV; |
114 | } | 114 | } |
115 | 115 | ||
116 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); | 116 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); |
@@ -118,8 +118,8 @@ static int video_open(struct file *file) | |||
118 | /* allocate + initialize per filehandle data */ | 118 | /* allocate + initialize per filehandle data */ |
119 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); | 119 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); |
120 | if (NULL == fh) { | 120 | if (NULL == fh) { |
121 | unlock_kernel(); | 121 | unlock_kernel(); |
122 | return -ENOMEM; | 122 | return -ENOMEM; |
123 | } | 123 | } |
124 | 124 | ||
125 | file->private_data = fh; | 125 | file->private_data = fh; |
@@ -128,22 +128,22 @@ static int video_open(struct file *file) | |||
128 | fh->width = 720; | 128 | fh->width = 720; |
129 | 129 | ||
130 | if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) | 130 | if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) |
131 | fh->height = 576; | 131 | fh->height = 576; |
132 | else | 132 | else |
133 | fh->height = 480; | 133 | fh->height = 480; |
134 | |||
134 | 135 | ||
135 | |||
136 | dev->channel_opened = 9; | 136 | dev->channel_opened = 9; |
137 | fh->fmt = format_by_fourcc(V4L2_PIX_FMT_YUYV); | 137 | fh->fmt = format_by_fourcc(V4L2_PIX_FMT_YUYV); |
138 | 138 | ||
139 | v4l2_prio_open(&dev->prio,&fh->prio); | 139 | v4l2_prio_open(&dev->prio,&fh->prio); |
140 | 140 | ||
141 | videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops, | 141 | videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops, |
142 | &dev->pci->dev, &dev->slock, | 142 | &dev->pci->dev, &dev->slock, |
143 | V4L2_BUF_TYPE_VIDEO_CAPTURE, | 143 | V4L2_BUF_TYPE_VIDEO_CAPTURE, |
144 | V4L2_FIELD_INTERLACED, | 144 | V4L2_FIELD_INTERLACED, |
145 | sizeof(struct cx25821_buffer), | 145 | sizeof(struct cx25821_buffer), |
146 | fh); | 146 | fh); |
147 | 147 | ||
148 | dprintk(1, "post videobuf_queue_init()\n"); | 148 | dprintk(1, "post videobuf_queue_init()\n"); |
149 | unlock_kernel(); | 149 | unlock_kernel(); |
@@ -157,15 +157,15 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo | |||
157 | 157 | ||
158 | switch (fh->type) | 158 | switch (fh->type) |
159 | { | 159 | { |
160 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 160 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
161 | if (res_locked(fh->dev, RESOURCE_VIDEO10)) | 161 | if (res_locked(fh->dev, RESOURCE_VIDEO10)) |
162 | return -EBUSY; | 162 | return -EBUSY; |
163 | 163 | ||
164 | return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK); | 164 | return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK); |
165 | 165 | ||
166 | default: | 166 | default: |
167 | BUG(); | 167 | BUG(); |
168 | return 0; | 168 | return 0; |
169 | } | 169 | } |
170 | } | 170 | } |
171 | 171 | ||
@@ -175,21 +175,21 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait | |||
175 | struct cx25821_buffer *buf; | 175 | struct cx25821_buffer *buf; |
176 | 176 | ||
177 | if (res_check(fh, RESOURCE_VIDEO10)) { | 177 | if (res_check(fh, RESOURCE_VIDEO10)) { |
178 | /* streaming capture */ | 178 | /* streaming capture */ |
179 | if (list_empty(&fh->vidq.stream)) | 179 | if (list_empty(&fh->vidq.stream)) |
180 | return POLLERR; | 180 | return POLLERR; |
181 | buf = list_entry(fh->vidq.stream.next, | 181 | buf = list_entry(fh->vidq.stream.next, |
182 | struct cx25821_buffer, vb.stream); | 182 | struct cx25821_buffer, vb.stream); |
183 | } else { | 183 | } else { |
184 | /* read() capture */ | 184 | /* read() capture */ |
185 | buf = (struct cx25821_buffer *)fh->vidq.read_buf; | 185 | buf = (struct cx25821_buffer *)fh->vidq.read_buf; |
186 | if (NULL == buf) | 186 | if (NULL == buf) |
187 | return POLLERR; | 187 | return POLLERR; |
188 | } | 188 | } |
189 | 189 | ||
190 | poll_wait(file, &buf->vb.done, wait); | 190 | poll_wait(file, &buf->vb.done, wait); |
191 | if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR) | 191 | if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR) |
192 | return POLLIN|POLLRDNORM; | 192 | return POLLIN|POLLRDNORM; |
193 | return 0; | 193 | return 0; |
194 | } | 194 | } |
195 | 195 | ||
@@ -199,17 +199,17 @@ static int video_release(struct file *file) | |||
199 | struct cx25821_dev *dev = fh->dev; | 199 | struct cx25821_dev *dev = fh->dev; |
200 | 200 | ||
201 | //stop the risc engine and fifo | 201 | //stop the risc engine and fifo |
202 | //cx_write(channel10->dma_ctl, 0); | 202 | //cx_write(channel10->dma_ctl, 0); |
203 | 203 | ||
204 | /* stop video capture */ | 204 | /* stop video capture */ |
205 | if (res_check(fh, RESOURCE_VIDEO10)) { | 205 | if (res_check(fh, RESOURCE_VIDEO10)) { |
206 | videobuf_queue_cancel(&fh->vidq); | 206 | videobuf_queue_cancel(&fh->vidq); |
207 | res_free(dev, fh, RESOURCE_VIDEO10); | 207 | res_free(dev, fh, RESOURCE_VIDEO10); |
208 | } | 208 | } |
209 | 209 | ||
210 | if (fh->vidq.read_buf) { | 210 | if (fh->vidq.read_buf) { |
211 | buffer_release(&fh->vidq, fh->vidq.read_buf); | 211 | buffer_release(&fh->vidq, fh->vidq.read_buf); |
212 | kfree(fh->vidq.read_buf); | 212 | kfree(fh->vidq.read_buf); |
213 | } | 213 | } |
214 | 214 | ||
215 | videobuf_mmap_free(&fh->vidq); | 215 | videobuf_mmap_free(&fh->vidq); |
@@ -230,17 +230,17 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) | |||
230 | 230 | ||
231 | if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) | 231 | if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) |
232 | { | 232 | { |
233 | return -EINVAL; | 233 | return -EINVAL; |
234 | } | 234 | } |
235 | 235 | ||
236 | if (unlikely(i != fh->type)) | 236 | if (unlikely(i != fh->type)) |
237 | { | 237 | { |
238 | return -EINVAL; | 238 | return -EINVAL; |
239 | } | 239 | } |
240 | 240 | ||
241 | if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO10)))) | 241 | if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO10)))) |
242 | { | 242 | { |
243 | return -EBUSY; | 243 | return -EBUSY; |
244 | } | 244 | } |
245 | 245 | ||
246 | return videobuf_streamon(get_queue(fh)); | 246 | return videobuf_streamon(get_queue(fh)); |
@@ -253,61 +253,61 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) | |||
253 | int err, res; | 253 | int err, res; |
254 | 254 | ||
255 | if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 255 | if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
256 | return -EINVAL; | 256 | return -EINVAL; |
257 | if (i != fh->type) | 257 | if (i != fh->type) |
258 | return -EINVAL; | 258 | return -EINVAL; |
259 | 259 | ||
260 | res = get_resource(fh, RESOURCE_VIDEO10); | 260 | res = get_resource(fh, RESOURCE_VIDEO10); |
261 | err = videobuf_streamoff(get_queue(fh)); | 261 | err = videobuf_streamoff(get_queue(fh)); |
262 | if (err < 0) | 262 | if (err < 0) |
263 | return err; | 263 | return err; |
264 | res_free(dev, fh, res); | 264 | res_free(dev, fh, res); |
265 | return 0; | 265 | return 0; |
266 | } | 266 | } |
267 | 267 | ||
268 | 268 | ||
269 | static long video_ioctl_upstream10(struct file *file, unsigned int cmd, unsigned long arg) | 269 | static long video_ioctl_upstream10(struct file *file, unsigned int cmd, unsigned long arg) |
270 | { | 270 | { |
271 | struct cx25821_fh *fh = file->private_data; | 271 | struct cx25821_fh *fh = file->private_data; |
272 | struct cx25821_dev *dev = fh->dev; | 272 | struct cx25821_dev *dev = fh->dev; |
273 | int command = 0; | 273 | int command = 0; |
274 | struct upstream_user_struct *data_from_user; | 274 | struct upstream_user_struct *data_from_user; |
275 | |||
276 | 275 | ||
277 | data_from_user = (struct upstream_user_struct *)arg; | 276 | |
278 | 277 | data_from_user = (struct upstream_user_struct *)arg; | |
278 | |||
279 | if( !data_from_user ) | 279 | if( !data_from_user ) |
280 | { | 280 | { |
281 | printk("cx25821 in %s(): Upstream data is INVALID. Returning.\n", __func__); | 281 | printk("cx25821 in %s(): Upstream data is INVALID. Returning.\n", __func__); |
282 | return 0; | 282 | return 0; |
283 | } | 283 | } |
284 | 284 | ||
285 | command = data_from_user->command; | 285 | command = data_from_user->command; |
286 | 286 | ||
287 | if( command != UPSTREAM_START_VIDEO && command != UPSTREAM_STOP_VIDEO ) | 287 | if( command != UPSTREAM_START_VIDEO && command != UPSTREAM_STOP_VIDEO ) |
288 | { | 288 | { |
289 | return 0; | 289 | return 0; |
290 | } | 290 | } |
291 | 291 | ||
292 | dev->input_filename_ch2 = data_from_user->input_filename; | 292 | dev->input_filename_ch2 = data_from_user->input_filename; |
293 | dev->input_audiofilename = data_from_user->input_filename; | 293 | dev->input_audiofilename = data_from_user->input_filename; |
294 | dev->vid_stdname_ch2 = data_from_user->vid_stdname; | 294 | dev->vid_stdname_ch2 = data_from_user->vid_stdname; |
295 | dev->pixel_format_ch2 = data_from_user->pixel_format; | 295 | dev->pixel_format_ch2 = data_from_user->pixel_format; |
296 | dev->channel_select_ch2 = data_from_user->channel_select; | 296 | dev->channel_select_ch2 = data_from_user->channel_select; |
297 | dev->command_ch2 = data_from_user->command; | 297 | dev->command_ch2 = data_from_user->command; |
298 | 298 | ||
299 | 299 | ||
300 | switch(command) | 300 | switch(command) |
301 | { | 301 | { |
302 | case UPSTREAM_START_VIDEO: | 302 | case UPSTREAM_START_VIDEO: |
303 | cx25821_start_upstream_video_ch2(dev, data_from_user); | 303 | cx25821_start_upstream_video_ch2(dev, data_from_user); |
304 | break; | 304 | break; |
305 | 305 | ||
306 | case UPSTREAM_STOP_VIDEO: | 306 | case UPSTREAM_STOP_VIDEO: |
307 | cx25821_stop_upstream_video_ch2(dev); | 307 | cx25821_stop_upstream_video_ch2(dev); |
308 | break; | 308 | break; |
309 | } | 309 | } |
310 | 310 | ||
311 | return 0; | 311 | return 0; |
312 | } | 312 | } |
313 | 313 | ||
@@ -318,18 +318,18 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma | |||
318 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 318 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
319 | int err; | 319 | int err; |
320 | 320 | ||
321 | if (fh) | 321 | if (fh) |
322 | { | 322 | { |
323 | err = v4l2_prio_check(&dev->prio, &fh->prio); | 323 | err = v4l2_prio_check(&dev->prio, &fh->prio); |
324 | if (0 != err) | 324 | if (0 != err) |
325 | return err; | 325 | return err; |
326 | } | 326 | } |
327 | 327 | ||
328 | dprintk(2, "%s()\n", __func__); | 328 | dprintk(2, "%s()\n", __func__); |
329 | err = vidioc_try_fmt_vid_cap(file, priv, f); | 329 | err = vidioc_try_fmt_vid_cap(file, priv, f); |
330 | 330 | ||
331 | if (0 != err) | 331 | if (0 != err) |
332 | return err; | 332 | return err; |
333 | fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); | 333 | fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); |
334 | fh->width = f->fmt.pix.width; | 334 | fh->width = f->fmt.pix.width; |
335 | fh->height = f->fmt.pix.height; | 335 | fh->height = f->fmt.pix.height; |
@@ -366,11 +366,11 @@ static int vidioc_s_ctrl(struct file *file, void *priv, | |||
366 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 366 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
367 | int err; | 367 | int err; |
368 | 368 | ||
369 | if (fh) | 369 | if (fh) |
370 | { | 370 | { |
371 | err = v4l2_prio_check(&dev->prio, &fh->prio); | 371 | err = v4l2_prio_check(&dev->prio, &fh->prio); |
372 | if (0 != err) | 372 | if (0 != err) |
373 | return err; | 373 | return err; |
374 | } | 374 | } |
375 | 375 | ||
376 | return 0; | 376 | return 0; |
@@ -384,7 +384,7 @@ static const struct v4l2_file_operations video_fops = { | |||
384 | .read = video_read, | 384 | .read = video_read, |
385 | .poll = video_poll, | 385 | .poll = video_poll, |
386 | .mmap = video_mmap, | 386 | .mmap = video_mmap, |
387 | .ioctl = video_ioctl_upstream10, | 387 | .ioctl = video_ioctl_upstream10, |
388 | }; | 388 | }; |
389 | 389 | ||
390 | static const struct v4l2_ioctl_ops video_ioctl_ops = { | 390 | static const struct v4l2_ioctl_ops video_ioctl_ops = { |
diff --git a/drivers/staging/cx25821/cx25821-vidups9.c b/drivers/staging/cx25821/cx25821-vidups9.c index 7832fd1603b..947ea5bc8f6 100644 --- a/drivers/staging/cx25821/cx25821-vidups9.c +++ b/drivers/staging/cx25821/cx25821-vidups9.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the Conexant CX25821 PCIe bridge | 2 | * Driver for the Conexant CX25821 PCIe bridge |
3 | * | 3 | * |
4 | * Copyright (C) 2009 Conexant Systems Inc. | 4 | * Copyright (C) 2009 Conexant Systems Inc. |
5 | * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com> | 5 | * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com> |
6 | * Based on Steven Toth <stoth@linuxtv.org> cx23885 driver | 6 | * Based on Steven Toth <stoth@linuxtv.org> cx23885 driver |
7 | * | 7 | * |
@@ -40,37 +40,37 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) | |||
40 | dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]); | 40 | dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]); |
41 | 41 | ||
42 | if (!list_empty(&q->queued)) { | 42 | if (!list_empty(&q->queued)) { |
43 | list_add_tail(&buf->vb.queue, &q->queued); | 43 | list_add_tail(&buf->vb.queue, &q->queued); |
44 | buf->vb.state = VIDEOBUF_QUEUED; | 44 | buf->vb.state = VIDEOBUF_QUEUED; |
45 | dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i); | 45 | dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i); |
46 | 46 | ||
47 | } else if (list_empty(&q->active)) { | 47 | } else if (list_empty(&q->active)) { |
48 | list_add_tail(&buf->vb.queue, &q->active); | 48 | list_add_tail(&buf->vb.queue, &q->active); |
49 | cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH09]); | 49 | cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH09]); |
50 | buf->vb.state = VIDEOBUF_ACTIVE; | 50 | buf->vb.state = VIDEOBUF_ACTIVE; |
51 | buf->count = q->count++; | 51 | buf->count = q->count++; |
52 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); | 52 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); |
53 | dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n", | 53 | dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n", |
54 | buf, buf->vb. i, buf->count, q->count); | 54 | buf, buf->vb. i, buf->count, q->count); |
55 | } else { | 55 | } else { |
56 | prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue); | 56 | prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue); |
57 | if (prev->vb.width == buf->vb.width && | 57 | if (prev->vb.width == buf->vb.width && |
58 | prev->vb.height == buf->vb.height && | 58 | prev->vb.height == buf->vb.height && |
59 | prev->fmt == buf->fmt) { | 59 | prev->fmt == buf->fmt) { |
60 | list_add_tail(&buf->vb.queue, &q->active); | 60 | list_add_tail(&buf->vb.queue, &q->active); |
61 | buf->vb.state = VIDEOBUF_ACTIVE; | 61 | buf->vb.state = VIDEOBUF_ACTIVE; |
62 | buf->count = q->count++; | 62 | buf->count = q->count++; |
63 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); | 63 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); |
64 | 64 | ||
65 | /* 64 bit bits 63-32 */ | 65 | /* 64 bit bits 63-32 */ |
66 | prev->risc.jmp[2] = cpu_to_le32(0); | 66 | prev->risc.jmp[2] = cpu_to_le32(0); |
67 | dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count); | 67 | dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count); |
68 | 68 | ||
69 | } else { | 69 | } else { |
70 | list_add_tail(&buf->vb.queue, &q->queued); | 70 | list_add_tail(&buf->vb.queue, &q->queued); |
71 | buf->vb.state = VIDEOBUF_QUEUED; | 71 | buf->vb.state = VIDEOBUF_QUEUED; |
72 | dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i); | 72 | dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i); |
73 | } | 73 | } |
74 | } | 74 | } |
75 | 75 | ||
76 | if (list_empty(&q->active)) | 76 | if (list_empty(&q->active)) |
@@ -99,18 +99,18 @@ static int video_open(struct file *file) | |||
99 | lock_kernel(); | 99 | lock_kernel(); |
100 | list_for_each(list, &cx25821_devlist) | 100 | list_for_each(list, &cx25821_devlist) |
101 | { | 101 | { |
102 | h = list_entry(list, struct cx25821_dev, devlist); | 102 | h = list_entry(list, struct cx25821_dev, devlist); |
103 | 103 | ||
104 | if (h->video_dev[SRAM_CH09] && h->video_dev[SRAM_CH09]->minor == minor) | 104 | if (h->video_dev[SRAM_CH09] && h->video_dev[SRAM_CH09]->minor == minor) |
105 | { | 105 | { |
106 | dev = h; | 106 | dev = h; |
107 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 107 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
108 | } | 108 | } |
109 | } | 109 | } |
110 | 110 | ||
111 | if (NULL == dev) { | 111 | if (NULL == dev) { |
112 | unlock_kernel(); | 112 | unlock_kernel(); |
113 | return -ENODEV; | 113 | return -ENODEV; |
114 | } | 114 | } |
115 | 115 | ||
116 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); | 116 | printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); |
@@ -118,8 +118,8 @@ static int video_open(struct file *file) | |||
118 | /* allocate + initialize per filehandle data */ | 118 | /* allocate + initialize per filehandle data */ |
119 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); | 119 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); |
120 | if (NULL == fh) { | 120 | if (NULL == fh) { |
121 | unlock_kernel(); | 121 | unlock_kernel(); |
122 | return -ENOMEM; | 122 | return -ENOMEM; |
123 | } | 123 | } |
124 | 124 | ||
125 | file->private_data = fh; | 125 | file->private_data = fh; |
@@ -128,9 +128,9 @@ static int video_open(struct file *file) | |||
128 | fh->width = 720; | 128 | fh->width = 720; |
129 | 129 | ||
130 | if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) | 130 | if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) |
131 | fh->height = 576; | 131 | fh->height = 576; |
132 | else | 132 | else |
133 | fh->height = 480; | 133 | fh->height = 480; |
134 | 134 | ||
135 | dev->channel_opened = 8; | 135 | dev->channel_opened = 8; |
136 | fh->fmt = format_by_fourcc(V4L2_PIX_FMT_YUYV); | 136 | fh->fmt = format_by_fourcc(V4L2_PIX_FMT_YUYV); |
@@ -138,11 +138,11 @@ static int video_open(struct file *file) | |||
138 | v4l2_prio_open(&dev->prio,&fh->prio); | 138 | v4l2_prio_open(&dev->prio,&fh->prio); |
139 | 139 | ||
140 | videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops, | 140 | videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops, |
141 | &dev->pci->dev, &dev->slock, | 141 | &dev->pci->dev, &dev->slock, |
142 | V4L2_BUF_TYPE_VIDEO_CAPTURE, | 142 | V4L2_BUF_TYPE_VIDEO_CAPTURE, |
143 | V4L2_FIELD_INTERLACED, | 143 | V4L2_FIELD_INTERLACED, |
144 | sizeof(struct cx25821_buffer), | 144 | sizeof(struct cx25821_buffer), |
145 | fh); | 145 | fh); |
146 | 146 | ||
147 | dprintk(1, "post videobuf_queue_init()\n"); | 147 | dprintk(1, "post videobuf_queue_init()\n"); |
148 | unlock_kernel(); | 148 | unlock_kernel(); |
@@ -156,15 +156,15 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo | |||
156 | 156 | ||
157 | switch (fh->type) | 157 | switch (fh->type) |
158 | { | 158 | { |
159 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 159 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
160 | if (res_locked(fh->dev, RESOURCE_VIDEO9)) | 160 | if (res_locked(fh->dev, RESOURCE_VIDEO9)) |
161 | return -EBUSY; | 161 | return -EBUSY; |
162 | 162 | ||
163 | return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK); | 163 | return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK); |
164 | 164 | ||
165 | default: | 165 | default: |
166 | BUG(); | 166 | BUG(); |
167 | return 0; | 167 | return 0; |
168 | } | 168 | } |
169 | } | 169 | } |
170 | 170 | ||
@@ -174,21 +174,21 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait | |||
174 | struct cx25821_buffer *buf; | 174 | struct cx25821_buffer *buf; |
175 | 175 | ||
176 | if (res_check(fh, RESOURCE_VIDEO9)) { | 176 | if (res_check(fh, RESOURCE_VIDEO9)) { |
177 | /* streaming capture */ | 177 | /* streaming capture */ |
178 | if (list_empty(&fh->vidq.stream)) | 178 | if (list_empty(&fh->vidq.stream)) |
179 | return POLLERR; | 179 | return POLLERR; |
180 | buf = list_entry(fh->vidq.stream.next, | 180 | buf = list_entry(fh->vidq.stream.next, |
181 | struct cx25821_buffer, vb.stream); | 181 | struct cx25821_buffer, vb.stream); |
182 | } else { | 182 | } else { |
183 | /* read() capture */ | 183 | /* read() capture */ |
184 | buf = (struct cx25821_buffer *)fh->vidq.read_buf; | 184 | buf = (struct cx25821_buffer *)fh->vidq.read_buf; |
185 | if (NULL == buf) | 185 | if (NULL == buf) |
186 | return POLLERR; | 186 | return POLLERR; |
187 | } | 187 | } |
188 | 188 | ||
189 | poll_wait(file, &buf->vb.done, wait); | 189 | poll_wait(file, &buf->vb.done, wait); |
190 | if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR) | 190 | if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR) |
191 | return POLLIN|POLLRDNORM; | 191 | return POLLIN|POLLRDNORM; |
192 | return 0; | 192 | return 0; |
193 | } | 193 | } |
194 | 194 | ||
@@ -199,17 +199,17 @@ static int video_release(struct file *file) | |||
199 | struct cx25821_dev *dev = fh->dev; | 199 | struct cx25821_dev *dev = fh->dev; |
200 | 200 | ||
201 | //stop the risc engine and fifo | 201 | //stop the risc engine and fifo |
202 | //cx_write(channel9->dma_ctl, 0); | 202 | //cx_write(channel9->dma_ctl, 0); |
203 | 203 | ||
204 | /* stop video capture */ | 204 | /* stop video capture */ |
205 | if (res_check(fh, RESOURCE_VIDEO9)) { | 205 | if (res_check(fh, RESOURCE_VIDEO9)) { |
206 | videobuf_queue_cancel(&fh->vidq); | 206 | videobuf_queue_cancel(&fh->vidq); |
207 | res_free(dev, fh, RESOURCE_VIDEO9); | 207 | res_free(dev, fh, RESOURCE_VIDEO9); |
208 | } | 208 | } |
209 | 209 | ||
210 | if (fh->vidq.read_buf) { | 210 | if (fh->vidq.read_buf) { |
211 | buffer_release(&fh->vidq, fh->vidq.read_buf); | 211 | buffer_release(&fh->vidq, fh->vidq.read_buf); |
212 | kfree(fh->vidq.read_buf); | 212 | kfree(fh->vidq.read_buf); |
213 | } | 213 | } |
214 | 214 | ||
215 | videobuf_mmap_free(&fh->vidq); | 215 | videobuf_mmap_free(&fh->vidq); |
@@ -230,17 +230,17 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) | |||
230 | 230 | ||
231 | if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) | 231 | if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) |
232 | { | 232 | { |
233 | return -EINVAL; | 233 | return -EINVAL; |
234 | } | 234 | } |
235 | 235 | ||
236 | if (unlikely(i != fh->type)) | 236 | if (unlikely(i != fh->type)) |
237 | { | 237 | { |
238 | return -EINVAL; | 238 | return -EINVAL; |
239 | } | 239 | } |
240 | 240 | ||
241 | if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO9)))) | 241 | if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO9)))) |
242 | { | 242 | { |
243 | return -EBUSY; | 243 | return -EBUSY; |
244 | } | 244 | } |
245 | 245 | ||
246 | return videobuf_streamon(get_queue(fh)); | 246 | return videobuf_streamon(get_queue(fh)); |
@@ -253,62 +253,62 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) | |||
253 | int err, res; | 253 | int err, res; |
254 | 254 | ||
255 | if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 255 | if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
256 | return -EINVAL; | 256 | return -EINVAL; |
257 | if (i != fh->type) | 257 | if (i != fh->type) |
258 | return -EINVAL; | 258 | return -EINVAL; |
259 | 259 | ||
260 | res = get_resource(fh, RESOURCE_VIDEO9); | 260 | res = get_resource(fh, RESOURCE_VIDEO9); |
261 | err = videobuf_streamoff(get_queue(fh)); | 261 | err = videobuf_streamoff(get_queue(fh)); |
262 | if (err < 0) | 262 | if (err < 0) |
263 | return err; | 263 | return err; |
264 | res_free(dev, fh, res); | 264 | res_free(dev, fh, res); |
265 | return 0; | 265 | return 0; |
266 | } | 266 | } |
267 | 267 | ||
268 | 268 | ||
269 | static long video_ioctl_upstream9(struct file *file, unsigned int cmd, unsigned long arg) | 269 | static long video_ioctl_upstream9(struct file *file, unsigned int cmd, unsigned long arg) |
270 | { | 270 | { |
271 | struct cx25821_fh *fh = file->private_data; | 271 | struct cx25821_fh *fh = file->private_data; |
272 | struct cx25821_dev *dev = fh->dev; | 272 | struct cx25821_dev *dev = fh->dev; |
273 | int command = 0; | 273 | int command = 0; |
274 | struct upstream_user_struct *data_from_user; | 274 | struct upstream_user_struct *data_from_user; |
275 | 275 | ||
276 | 276 | ||
277 | data_from_user = (struct upstream_user_struct *)arg; | 277 | data_from_user = (struct upstream_user_struct *)arg; |
278 | 278 | ||
279 | if( !data_from_user ) | 279 | if( !data_from_user ) |
280 | { | 280 | { |
281 | printk("cx25821 in %s(): Upstream data is INVALID. Returning.\n", __func__); | 281 | printk("cx25821 in %s(): Upstream data is INVALID. Returning.\n", __func__); |
282 | return 0; | 282 | return 0; |
283 | } | 283 | } |
284 | 284 | ||
285 | command = data_from_user->command; | 285 | command = data_from_user->command; |
286 | 286 | ||
287 | if( command != UPSTREAM_START_VIDEO && command != UPSTREAM_STOP_VIDEO ) | 287 | if( command != UPSTREAM_START_VIDEO && command != UPSTREAM_STOP_VIDEO ) |
288 | { | 288 | { |
289 | return 0; | 289 | return 0; |
290 | } | 290 | } |
291 | 291 | ||
292 | 292 | ||
293 | dev->input_filename = data_from_user->input_filename; | 293 | dev->input_filename = data_from_user->input_filename; |
294 | dev->input_audiofilename = data_from_user->input_filename; | 294 | dev->input_audiofilename = data_from_user->input_filename; |
295 | dev->vid_stdname = data_from_user->vid_stdname; | 295 | dev->vid_stdname = data_from_user->vid_stdname; |
296 | dev->pixel_format = data_from_user->pixel_format; | 296 | dev->pixel_format = data_from_user->pixel_format; |
297 | dev->channel_select = data_from_user->channel_select; | 297 | dev->channel_select = data_from_user->channel_select; |
298 | dev->command = data_from_user->command; | 298 | dev->command = data_from_user->command; |
299 | 299 | ||
300 | 300 | ||
301 | switch(command) | 301 | switch(command) |
302 | { | 302 | { |
303 | case UPSTREAM_START_VIDEO: | 303 | case UPSTREAM_START_VIDEO: |
304 | cx25821_start_upstream_video_ch1(dev, data_from_user); | 304 | cx25821_start_upstream_video_ch1(dev, data_from_user); |
305 | break; | 305 | break; |
306 | 306 | ||
307 | case UPSTREAM_STOP_VIDEO: | 307 | case UPSTREAM_STOP_VIDEO: |
308 | cx25821_stop_upstream_video_ch1(dev); | 308 | cx25821_stop_upstream_video_ch1(dev); |
309 | break; | 309 | break; |
310 | } | 310 | } |
311 | 311 | ||
312 | return 0; | 312 | return 0; |
313 | } | 313 | } |
314 | 314 | ||
@@ -319,18 +319,18 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma | |||
319 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 319 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
320 | int err; | 320 | int err; |
321 | 321 | ||
322 | if (fh) | 322 | if (fh) |
323 | { | 323 | { |
324 | err = v4l2_prio_check(&dev->prio, &fh->prio); | 324 | err = v4l2_prio_check(&dev->prio, &fh->prio); |
325 | if (0 != err) | 325 | if (0 != err) |
326 | return err; | 326 | return err; |
327 | } | 327 | } |
328 | 328 | ||
329 | dprintk(2, "%s()\n", __func__); | 329 | dprintk(2, "%s()\n", __func__); |
330 | err = vidioc_try_fmt_vid_cap(file, priv, f); | 330 | err = vidioc_try_fmt_vid_cap(file, priv, f); |
331 | 331 | ||
332 | if (0 != err) | 332 | if (0 != err) |
333 | return err; | 333 | return err; |
334 | fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); | 334 | fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); |
335 | fh->width = f->fmt.pix.width; | 335 | fh->width = f->fmt.pix.width; |
336 | fh->height = f->fmt.pix.height; | 336 | fh->height = f->fmt.pix.height; |
@@ -365,11 +365,11 @@ static int vidioc_s_ctrl(struct file *file, void *priv, | |||
365 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; | 365 | struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; |
366 | struct cx25821_fh *fh = priv; | 366 | struct cx25821_fh *fh = priv; |
367 | int err; | 367 | int err; |
368 | if (fh) | 368 | if (fh) |
369 | { | 369 | { |
370 | err = v4l2_prio_check(&dev->prio, &fh->prio); | 370 | err = v4l2_prio_check(&dev->prio, &fh->prio); |
371 | if (0 != err) | 371 | if (0 != err) |
372 | return err; | 372 | return err; |
373 | } | 373 | } |
374 | 374 | ||
375 | return 0; | 375 | return 0; |
@@ -382,7 +382,7 @@ static const struct v4l2_file_operations video_fops = { | |||
382 | .read = video_read, | 382 | .read = video_read, |
383 | .poll = video_poll, | 383 | .poll = video_poll, |
384 | .mmap = video_mmap, | 384 | .mmap = video_mmap, |
385 | .ioctl = video_ioctl_upstream9, | 385 | .ioctl = video_ioctl_upstream9, |
386 | }; | 386 | }; |
387 | 387 | ||
388 | static const struct v4l2_ioctl_ops video_ioctl_ops = { | 388 | static const struct v4l2_ioctl_ops video_ioctl_ops = { |
diff --git a/drivers/staging/cx25821/cx25821.h b/drivers/staging/cx25821/cx25821.h index 578cdd51ae5..94f16cec1f4 100644 --- a/drivers/staging/cx25821/cx25821.h +++ b/drivers/staging/cx25821/cx25821.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the Conexant CX25821 PCIe bridge | 2 | * Driver for the Conexant CX25821 PCIe bridge |
3 | * | 3 | * |
4 | * Copyright (C) 2009 Conexant Systems Inc. | 4 | * Copyright (C) 2009 Conexant Systems Inc. |
5 | * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com> | 5 | * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com> |
6 | * Based on Steven Toth <stoth@linuxtv.org> cx23885 driver | 6 | * Based on Steven Toth <stoth@linuxtv.org> cx23885 driver |
7 | * | 7 | * |
@@ -35,7 +35,7 @@ | |||
35 | #include <linux/smp_lock.h> | 35 | #include <linux/smp_lock.h> |
36 | 36 | ||
37 | #include <media/v4l2-common.h> | 37 | #include <media/v4l2-common.h> |
38 | #include <media/v4l2-device.h> | 38 | #include <media/v4l2-device.h> |
39 | #include <media/tuner.h> | 39 | #include <media/tuner.h> |
40 | #include <media/tveeprom.h> | 40 | #include <media/tveeprom.h> |
41 | #include <media/videobuf-dma-sg.h> | 41 | #include <media/videobuf-dma-sg.h> |
@@ -62,7 +62,7 @@ | |||
62 | #define FALSE 0 | 62 | #define FALSE 0 |
63 | #define LINE_SIZE_D1 1440 | 63 | #define LINE_SIZE_D1 1440 |
64 | 64 | ||
65 | // Number of decoders and encoders | 65 | // Number of decoders and encoders |
66 | #define MAX_DECODERS 8 | 66 | #define MAX_DECODERS 8 |
67 | #define MAX_ENCODERS 2 | 67 | #define MAX_ENCODERS 2 |
68 | #define QUAD_DECODERS 4 | 68 | #define QUAD_DECODERS 4 |
@@ -91,7 +91,7 @@ | |||
91 | #define UNKNOWN_BOARD 0 | 91 | #define UNKNOWN_BOARD 0 |
92 | #define CX25821_BOARD 1 | 92 | #define CX25821_BOARD 1 |
93 | 93 | ||
94 | /* Currently supported by the driver */ | 94 | /* Currently supported by the driver */ |
95 | #define CX25821_NORMS (\ | 95 | #define CX25821_NORMS (\ |
96 | V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_JP | V4L2_STD_NTSC_M_KR | \ | 96 | V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_JP | V4L2_STD_NTSC_M_KR | \ |
97 | V4L2_STD_PAL_BG | V4L2_STD_PAL_DK | V4L2_STD_PAL_I | \ | 97 | V4L2_STD_PAL_BG | V4L2_STD_PAL_DK | V4L2_STD_PAL_I | \ |
@@ -292,7 +292,7 @@ struct cx25821_dev { | |||
292 | struct cx25821_data timeout_data[MAX_VID_CHANNEL_NUM]; | 292 | struct cx25821_data timeout_data[MAX_VID_CHANNEL_NUM]; |
293 | 293 | ||
294 | /* Analog Audio Upstream */ | 294 | /* Analog Audio Upstream */ |
295 | int _audio_is_running; | 295 | int _audio_is_running; |
296 | int _audiopixel_format; | 296 | int _audiopixel_format; |
297 | int _is_first_audio_frame; | 297 | int _is_first_audio_frame; |
298 | int _audiofile_status; | 298 | int _audiofile_status; |
@@ -311,7 +311,7 @@ struct cx25821_dev { | |||
311 | unsigned int _audiodata_buf_size; | 311 | unsigned int _audiodata_buf_size; |
312 | __le32 * _audiodata_buf_virt_addr; | 312 | __le32 * _audiodata_buf_virt_addr; |
313 | dma_addr_t _audiodata_buf_phys_addr; | 313 | dma_addr_t _audiodata_buf_phys_addr; |
314 | char *_audiofilename; | 314 | char *_audiofilename; |
315 | 315 | ||
316 | /* V4l */ | 316 | /* V4l */ |
317 | u32 freq; | 317 | u32 freq; |
@@ -322,7 +322,7 @@ struct cx25821_dev { | |||
322 | 322 | ||
323 | struct cx25821_dmaqueue vidq[MAX_VID_CHANNEL_NUM]; | 323 | struct cx25821_dmaqueue vidq[MAX_VID_CHANNEL_NUM]; |
324 | spinlock_t slock; | 324 | spinlock_t slock; |
325 | 325 | ||
326 | /* Video Upstream */ | 326 | /* Video Upstream */ |
327 | int _line_size; | 327 | int _line_size; |
328 | int _prog_cnt; | 328 | int _prog_cnt; |
@@ -343,8 +343,8 @@ struct cx25821_dev { | |||
343 | unsigned int _data_buf_size; | 343 | unsigned int _data_buf_size; |
344 | __le32 * _data_buf_virt_addr; | 344 | __le32 * _data_buf_virt_addr; |
345 | dma_addr_t _data_buf_phys_addr; | 345 | dma_addr_t _data_buf_phys_addr; |
346 | char * _filename; | 346 | char * _filename; |
347 | char * _defaultname; | 347 | char * _defaultname; |
348 | 348 | ||
349 | 349 | ||
350 | int _line_size_ch2; | 350 | int _line_size_ch2; |
@@ -366,8 +366,8 @@ struct cx25821_dev { | |||
366 | unsigned int _data_buf_size_ch2; | 366 | unsigned int _data_buf_size_ch2; |
367 | __le32 * _data_buf_virt_addr_ch2; | 367 | __le32 * _data_buf_virt_addr_ch2; |
368 | dma_addr_t _data_buf_phys_addr_ch2; | 368 | dma_addr_t _data_buf_phys_addr_ch2; |
369 | char * _filename_ch2; | 369 | char * _filename_ch2; |
370 | char * _defaultname_ch2; | 370 | char * _defaultname_ch2; |
371 | 371 | ||
372 | /* MPEG Encoder ONLY settings */ | 372 | /* MPEG Encoder ONLY settings */ |
373 | u32 cx23417_mailbox; | 373 | u32 cx23417_mailbox; |
@@ -375,26 +375,26 @@ struct cx25821_dev { | |||
375 | struct video_device *v4l_device; | 375 | struct video_device *v4l_device; |
376 | atomic_t v4l_reader_count; | 376 | atomic_t v4l_reader_count; |
377 | struct cx25821_tvnorm encodernorm; | 377 | struct cx25821_tvnorm encodernorm; |
378 | 378 | ||
379 | u32 upstream_riscbuf_size; | 379 | u32 upstream_riscbuf_size; |
380 | u32 upstream_databuf_size; | 380 | u32 upstream_databuf_size; |
381 | u32 upstream_riscbuf_size_ch2; | 381 | u32 upstream_riscbuf_size_ch2; |
382 | u32 upstream_databuf_size_ch2; | 382 | u32 upstream_databuf_size_ch2; |
383 | u32 audio_upstream_riscbuf_size; | 383 | u32 audio_upstream_riscbuf_size; |
384 | u32 audio_upstream_databuf_size; | 384 | u32 audio_upstream_databuf_size; |
385 | int _isNTSC; | 385 | int _isNTSC; |
386 | int _frame_index; | 386 | int _frame_index; |
387 | int _audioframe_index; | 387 | int _audioframe_index; |
388 | struct workqueue_struct * _irq_queues; | 388 | struct workqueue_struct * _irq_queues; |
389 | struct work_struct _irq_work_entry; | 389 | struct work_struct _irq_work_entry; |
390 | struct workqueue_struct * _irq_queues_ch2; | 390 | struct workqueue_struct * _irq_queues_ch2; |
391 | struct work_struct _irq_work_entry_ch2; | 391 | struct work_struct _irq_work_entry_ch2; |
392 | struct workqueue_struct * _irq_audio_queues; | 392 | struct workqueue_struct * _irq_audio_queues; |
393 | struct work_struct _audio_work_entry; | 393 | struct work_struct _audio_work_entry; |
394 | char *input_filename; | 394 | char *input_filename; |
395 | char *input_filename_ch2; | 395 | char *input_filename_ch2; |
396 | int _frame_index_ch2; | 396 | int _frame_index_ch2; |
397 | int _isNTSC_ch2; | 397 | int _isNTSC_ch2; |
398 | char *vid_stdname_ch2; | 398 | char *vid_stdname_ch2; |
399 | int pixel_format_ch2; | 399 | int pixel_format_ch2; |
400 | int channel_select_ch2; | 400 | int channel_select_ch2; |
@@ -439,7 +439,7 @@ static inline struct cx25821_dev *get_cx25821(struct v4l2_device *v4l2_dev) | |||
439 | 439 | ||
440 | #define cx25821_call_all(dev, o, f, args...) \ | 440 | #define cx25821_call_all(dev, o, f, args...) \ |
441 | v4l2_device_call_all(&dev->v4l2_dev, 0, o, f, ##args) | 441 | v4l2_device_call_all(&dev->v4l2_dev, 0, o, f, ##args) |
442 | 442 | ||
443 | extern struct list_head cx25821_devlist; | 443 | extern struct list_head cx25821_devlist; |
444 | extern struct cx25821_board cx25821_boards[]; | 444 | extern struct cx25821_board cx25821_boards[]; |
445 | extern struct cx25821_subid cx25821_subids[]; | 445 | extern struct cx25821_subid cx25821_subids[]; |
@@ -487,16 +487,16 @@ struct sram_channel { | |||
487 | u32 aud_cfg; | 487 | u32 aud_cfg; |
488 | u32 fld_aud_fifo_en; | 488 | u32 fld_aud_fifo_en; |
489 | u32 fld_aud_risc_en; | 489 | u32 fld_aud_risc_en; |
490 | 490 | ||
491 | //For Upstream Video | 491 | //For Upstream Video |
492 | u32 vid_fmt_ctl; | 492 | u32 vid_fmt_ctl; |
493 | u32 vid_active_ctl1; | 493 | u32 vid_active_ctl1; |
494 | u32 vid_active_ctl2; | 494 | u32 vid_active_ctl2; |
495 | u32 vid_cdt_size; | 495 | u32 vid_cdt_size; |
496 | 496 | ||
497 | u32 vip_ctl; | 497 | u32 vip_ctl; |
498 | u32 pix_frmt; | 498 | u32 pix_frmt; |
499 | u32 jumponly; | 499 | u32 jumponly; |
500 | u32 irq_bit; | 500 | u32 irq_bit; |
501 | }; | 501 | }; |
502 | extern struct sram_channel cx25821_sram_channels[]; | 502 | extern struct sram_channel cx25821_sram_channels[]; |
@@ -529,9 +529,9 @@ extern int cx25821_i2c_write(struct cx25821_i2c *bus, u16 reg_addr, int value); | |||
529 | extern int cx25821_i2c_unregister(struct cx25821_i2c *bus); | 529 | extern int cx25821_i2c_unregister(struct cx25821_i2c *bus); |
530 | extern void cx25821_gpio_init(struct cx25821_dev *dev); | 530 | extern void cx25821_gpio_init(struct cx25821_dev *dev); |
531 | extern void cx25821_set_gpiopin_direction( struct cx25821_dev *dev, | 531 | extern void cx25821_set_gpiopin_direction( struct cx25821_dev *dev, |
532 | int pin_number, | 532 | int pin_number, |
533 | int pin_logic_value); | 533 | int pin_logic_value); |
534 | 534 | ||
535 | extern int medusa_video_init(struct cx25821_dev *dev); | 535 | extern int medusa_video_init(struct cx25821_dev *dev); |
536 | extern int medusa_set_videostandard(struct cx25821_dev *dev); | 536 | extern int medusa_set_videostandard(struct cx25821_dev *dev); |
537 | extern void medusa_set_resolution(struct cx25821_dev *dev, int width, int decoder_select); | 537 | extern void medusa_set_resolution(struct cx25821_dev *dev, int width, int decoder_select); |
@@ -543,18 +543,18 @@ extern int medusa_set_saturation(struct cx25821_dev *dev, int saturation, int d | |||
543 | extern int cx25821_sram_channel_setup(struct cx25821_dev *dev, struct sram_channel *ch, unsigned int bpl, u32 risc); | 543 | extern int cx25821_sram_channel_setup(struct cx25821_dev *dev, struct sram_channel *ch, unsigned int bpl, u32 risc); |
544 | 544 | ||
545 | extern int cx25821_risc_buffer(struct pci_dev *pci, struct btcx_riscmem *risc, | 545 | extern int cx25821_risc_buffer(struct pci_dev *pci, struct btcx_riscmem *risc, |
546 | struct scatterlist *sglist, | 546 | struct scatterlist *sglist, |
547 | unsigned int top_offset, | 547 | unsigned int top_offset, |
548 | unsigned int bottom_offset, | 548 | unsigned int bottom_offset, |
549 | unsigned int bpl, | 549 | unsigned int bpl, |
550 | unsigned int padding, | 550 | unsigned int padding, |
551 | unsigned int lines); | 551 | unsigned int lines); |
552 | extern int cx25821_risc_databuffer_audio(struct pci_dev *pci, | 552 | extern int cx25821_risc_databuffer_audio(struct pci_dev *pci, |
553 | struct btcx_riscmem *risc, | 553 | struct btcx_riscmem *risc, |
554 | struct scatterlist *sglist, | 554 | struct scatterlist *sglist, |
555 | unsigned int bpl, | 555 | unsigned int bpl, |
556 | unsigned int lines, | 556 | unsigned int lines, |
557 | unsigned int lpi); | 557 | unsigned int lpi); |
558 | extern void cx25821_free_buffer(struct videobuf_queue *q, struct cx25821_buffer *buf); | 558 | extern void cx25821_free_buffer(struct videobuf_queue *q, struct cx25821_buffer *buf); |
559 | extern int cx25821_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc,u32 reg, u32 mask, u32 value); | 559 | extern int cx25821_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc,u32 reg, u32 mask, u32 value); |
560 | extern void cx25821_sram_channel_dump(struct cx25821_dev *dev, struct sram_channel *ch); | 560 | extern void cx25821_sram_channel_dump(struct cx25821_dev *dev, struct sram_channel *ch); |
@@ -565,26 +565,26 @@ extern struct cx25821_dev* cx25821_dev_get(struct pci_dev *pci); | |||
565 | extern void cx25821_print_irqbits(char *name, char *tag, char **strings, int len, u32 bits, u32 mask); | 565 | extern void cx25821_print_irqbits(char *name, char *tag, char **strings, int len, u32 bits, u32 mask); |
566 | extern void cx25821_dev_unregister(struct cx25821_dev *dev); | 566 | extern void cx25821_dev_unregister(struct cx25821_dev *dev); |
567 | extern int cx25821_sram_channel_setup_audio(struct cx25821_dev *dev, | 567 | extern int cx25821_sram_channel_setup_audio(struct cx25821_dev *dev, |
568 | struct sram_channel *ch, | 568 | struct sram_channel *ch, |
569 | unsigned int bpl, u32 risc); | 569 | unsigned int bpl, u32 risc); |
570 | 570 | ||
571 | extern int cx25821_vidupstream_init_ch1(struct cx25821_dev *dev, int channel_select, int pixel_format); | 571 | extern int cx25821_vidupstream_init_ch1(struct cx25821_dev *dev, int channel_select, int pixel_format); |
572 | extern int cx25821_vidupstream_init_ch2(struct cx25821_dev *dev, int channel_select, int pixel_format); | 572 | extern int cx25821_vidupstream_init_ch2(struct cx25821_dev *dev, int channel_select, int pixel_format); |
573 | extern int cx25821_audio_upstream_init(struct cx25821_dev *dev, int channel_select); | 573 | extern int cx25821_audio_upstream_init(struct cx25821_dev *dev, int channel_select); |
574 | extern void cx25821_free_mem_upstream_ch1(struct cx25821_dev *dev); | 574 | extern void cx25821_free_mem_upstream_ch1(struct cx25821_dev *dev); |
575 | extern void cx25821_free_mem_upstream_ch2(struct cx25821_dev *dev); | 575 | extern void cx25821_free_mem_upstream_ch2(struct cx25821_dev *dev); |
576 | extern void cx25821_free_mem_upstream_audio(struct cx25821_dev *dev); | 576 | extern void cx25821_free_mem_upstream_audio(struct cx25821_dev *dev); |
577 | extern void cx25821_start_upstream_video_ch1(struct cx25821_dev *dev, struct upstream_user_struct *up_data); | 577 | extern void cx25821_start_upstream_video_ch1(struct cx25821_dev *dev, struct upstream_user_struct *up_data); |
578 | extern void cx25821_start_upstream_video_ch2(struct cx25821_dev *dev, struct upstream_user_struct *up_data); | 578 | extern void cx25821_start_upstream_video_ch2(struct cx25821_dev *dev, struct upstream_user_struct *up_data); |
579 | extern void cx25821_start_upstream_audio(struct cx25821_dev *dev, struct upstream_user_struct *up_data); | 579 | extern void cx25821_start_upstream_audio(struct cx25821_dev *dev, struct upstream_user_struct *up_data); |
580 | extern void cx25821_stop_upstream_video_ch1(struct cx25821_dev *dev); | 580 | extern void cx25821_stop_upstream_video_ch1(struct cx25821_dev *dev); |
581 | extern void cx25821_stop_upstream_video_ch2(struct cx25821_dev *dev); | 581 | extern void cx25821_stop_upstream_video_ch2(struct cx25821_dev *dev); |
582 | extern void cx25821_stop_upstream_audio(struct cx25821_dev *dev); | 582 | extern void cx25821_stop_upstream_audio(struct cx25821_dev *dev); |
583 | extern int cx25821_sram_channel_setup_upstream( struct cx25821_dev *dev, struct sram_channel *ch, unsigned int bpl, u32 risc); | 583 | extern int cx25821_sram_channel_setup_upstream( struct cx25821_dev *dev, struct sram_channel *ch, unsigned int bpl, u32 risc); |
584 | extern void cx25821_set_pixel_format(struct cx25821_dev *dev, int channel, u32 format); | 584 | extern void cx25821_set_pixel_format(struct cx25821_dev *dev, int channel, u32 format); |
585 | extern void cx25821_videoioctl_unregister(struct cx25821_dev *dev); | 585 | extern void cx25821_videoioctl_unregister(struct cx25821_dev *dev); |
586 | extern struct video_device *cx25821_vdev_init(struct cx25821_dev *dev, | 586 | extern struct video_device *cx25821_vdev_init(struct cx25821_dev *dev, |
587 | struct pci_dev *pci, | 587 | struct pci_dev *pci, |
588 | struct video_device *template, | 588 | struct video_device *template, |
589 | char *type); | 589 | char *type); |
590 | #endif | 590 | #endif |