2 * Driver for the Conexant CX25821 PCIe bridge
4 * Copyright (C) 2009 Conexant Systems Inc.
5 * Authors <hiep.huynh@conexant.com>, <shu.lin@conexant.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
25 #include "cx25821-video.h"
26 #include "cx25821-video-upstream-ch2.h"
29 #include <linux/errno.h>
30 #include <linux/kernel.h>
31 #include <linux/init.h>
32 #include <linux/module.h>
33 #include <linux/syscalls.h>
34 #include <linux/file.h>
35 #include <linux/fcntl.h>
36 #include <linux/slab.h>
37 #include <linux/uaccess.h>
39 MODULE_DESCRIPTION("v4l2 driver module for cx25821 based TV cards");
40 MODULE_AUTHOR("Hiep Huynh <hiep.huynh@conexant.com>");
41 MODULE_LICENSE("GPL");
43 static int _intr_msk
=
44 FLD_VID_SRC_RISC1
| FLD_VID_SRC_UF
| FLD_VID_SRC_SYNC
| FLD_VID_SRC_OPC_ERR
;
46 static __le32
*cx25821_update_riscprogram_ch2(struct cx25821_dev
*dev
,
47 __le32
*rp
, unsigned int offset
,
48 unsigned int bpl
, u32 sync_line
,
50 int fifo_enable
, int field_type
)
53 int dist_betwn_starts
= bpl
* 2;
55 *(rp
++) = cpu_to_le32(RISC_RESYNC
| sync_line
);
57 if (USE_RISC_NOOP_VIDEO
) {
58 for (i
= 0; i
< NUM_NO_OPS
; i
++)
59 *(rp
++) = cpu_to_le32(RISC_NOOP
);
63 for (line
= 0; line
< lines
; line
++) {
64 *(rp
++) = cpu_to_le32(RISC_READ
| RISC_SOL
| RISC_EOL
| bpl
);
65 *(rp
++) = cpu_to_le32(dev
->_data_buf_phys_addr_ch2
+ offset
);
66 *(rp
++) = cpu_to_le32(0); /* bits 63-32 */
68 if ((lines
<= NTSC_FIELD_HEIGHT
)
69 || (line
< (NTSC_FIELD_HEIGHT
- 1))
70 || !(dev
->_isNTSC_ch2
)) {
71 offset
+= dist_betwn_starts
;
78 static __le32
*cx25821_risc_field_upstream_ch2(struct cx25821_dev
*dev
,
80 dma_addr_t databuf_phys_addr
,
82 u32 sync_line
, unsigned int bpl
,
84 int fifo_enable
, int field_type
)
87 struct sram_channel
*sram_ch
=
88 dev
->channels
[dev
->_channel2_upstream_select
].sram_channels
;
89 int dist_betwn_starts
= bpl
* 2;
91 /* sync instruction */
92 if (sync_line
!= NO_SYNC_LINE
)
93 *(rp
++) = cpu_to_le32(RISC_RESYNC
| sync_line
);
95 if (USE_RISC_NOOP_VIDEO
) {
96 for (i
= 0; i
< NUM_NO_OPS
; i
++)
97 *(rp
++) = cpu_to_le32(RISC_NOOP
);
101 for (line
= 0; line
< lines
; line
++) {
102 *(rp
++) = cpu_to_le32(RISC_READ
| RISC_SOL
| RISC_EOL
| bpl
);
103 *(rp
++) = cpu_to_le32(databuf_phys_addr
+ offset
);
104 *(rp
++) = cpu_to_le32(0); /* bits 63-32 */
106 if ((lines
<= NTSC_FIELD_HEIGHT
)
107 || (line
< (NTSC_FIELD_HEIGHT
- 1))
108 || !(dev
->_isNTSC_ch2
)) {
109 offset
+= dist_betwn_starts
;
113 check if we need to enable the FIFO after the first 4 lines
114 For the upstream video channel, the risc engine will enable
117 if (fifo_enable
&& line
== 3) {
118 *(rp
++) = RISC_WRITECR
;
119 *(rp
++) = sram_ch
->dma_ctl
;
120 *(rp
++) = FLD_VID_FIFO_EN
;
121 *(rp
++) = 0x00000001;
128 int cx25821_risc_buffer_upstream_ch2(struct cx25821_dev
*dev
,
130 unsigned int top_offset
, unsigned int bpl
,
135 int singlefield_lines
= lines
>> 1; /*get line count for single field */
136 int odd_num_lines
= singlefield_lines
;
139 int databuf_offset
= 0;
140 int risc_program_size
= 0;
141 int risc_flag
= RISC_CNT_RESET
;
142 unsigned int bottom_offset
= bpl
;
143 dma_addr_t risc_phys_jump_addr
;
145 if (dev
->_isNTSC_ch2
) {
146 odd_num_lines
= singlefield_lines
+ 1;
147 risc_program_size
= FRAME1_VID_PROG_SIZE
;
150 Y411_LINE_SZ
) ? FRAME_SIZE_NTSC_Y411
:
151 FRAME_SIZE_NTSC_Y422
;
153 risc_program_size
= PAL_VID_PROG_SIZE
;
156 Y411_LINE_SZ
) ? FRAME_SIZE_PAL_Y411
: FRAME_SIZE_PAL_Y422
;
159 /* Virtual address of Risc buffer program */
160 rp
= dev
->_dma_virt_addr_ch2
;
162 for (frame
= 0; frame
< NUM_FRAMES
; frame
++) {
163 databuf_offset
= frame_size
* frame
;
165 if (UNSET
!= top_offset
) {
166 fifo_enable
= (frame
== 0) ? FIFO_ENABLE
: FIFO_DISABLE
;
167 rp
= cx25821_risc_field_upstream_ch2(dev
, rp
,
169 _data_buf_phys_addr_ch2
177 fifo_enable
= FIFO_DISABLE
;
180 rp
= cx25821_risc_field_upstream_ch2(dev
, rp
,
182 _data_buf_phys_addr_ch2
+
184 bottom_offset
, 0x200, bpl
,
186 fifo_enable
, EVEN_FIELD
);
189 risc_flag
= RISC_CNT_RESET
;
190 risc_phys_jump_addr
=
191 dev
->_dma_phys_start_addr_ch2
+ risc_program_size
;
193 risc_flag
= RISC_CNT_INC
;
194 risc_phys_jump_addr
= dev
->_dma_phys_start_addr_ch2
;
198 Loop to 2ndFrameRISC or to Start of
199 Risc program & generate IRQ
201 *(rp
++) = cpu_to_le32(RISC_JUMP
| RISC_IRQ1
| risc_flag
);
202 *(rp
++) = cpu_to_le32(risc_phys_jump_addr
);
203 *(rp
++) = cpu_to_le32(0);
209 void cx25821_stop_upstream_video_ch2(struct cx25821_dev
*dev
)
211 struct sram_channel
*sram_ch
=
212 dev
->channels
[VID_UPSTREAM_SRAM_CHANNEL_J
].sram_channels
;
215 if (!dev
->_is_running_ch2
) {
216 pr_info("No video file is currently running so return!\n");
219 /* Disable RISC interrupts */
220 tmp
= cx_read(sram_ch
->int_msk
);
221 cx_write(sram_ch
->int_msk
, tmp
& ~_intr_msk
);
223 /* Turn OFF risc and fifo */
224 tmp
= cx_read(sram_ch
->dma_ctl
);
225 cx_write(sram_ch
->dma_ctl
, tmp
& ~(FLD_VID_FIFO_EN
| FLD_VID_RISC_EN
));
227 /* Clear data buffer memory */
228 if (dev
->_data_buf_virt_addr_ch2
)
229 memset(dev
->_data_buf_virt_addr_ch2
, 0,
230 dev
->_data_buf_size_ch2
);
232 dev
->_is_running_ch2
= 0;
233 dev
->_is_first_frame_ch2
= 0;
234 dev
->_frame_count_ch2
= 0;
235 dev
->_file_status_ch2
= END_OF_FILE
;
237 kfree(dev
->_irq_queues_ch2
);
238 dev
->_irq_queues_ch2
= NULL
;
240 kfree(dev
->_filename_ch2
);
242 tmp
= cx_read(VID_CH_MODE_SEL
);
243 cx_write(VID_CH_MODE_SEL
, tmp
& 0xFFFFFE00);
246 void cx25821_free_mem_upstream_ch2(struct cx25821_dev
*dev
)
248 if (dev
->_is_running_ch2
)
249 cx25821_stop_upstream_video_ch2(dev
);
251 if (dev
->_dma_virt_addr_ch2
) {
252 pci_free_consistent(dev
->pci
, dev
->_risc_size_ch2
,
253 dev
->_dma_virt_addr_ch2
,
254 dev
->_dma_phys_addr_ch2
);
255 dev
->_dma_virt_addr_ch2
= NULL
;
258 if (dev
->_data_buf_virt_addr_ch2
) {
259 pci_free_consistent(dev
->pci
, dev
->_data_buf_size_ch2
,
260 dev
->_data_buf_virt_addr_ch2
,
261 dev
->_data_buf_phys_addr_ch2
);
262 dev
->_data_buf_virt_addr_ch2
= NULL
;
266 int cx25821_get_frame_ch2(struct cx25821_dev
*dev
, struct sram_channel
*sram_ch
)
269 int frame_index_temp
= dev
->_frame_index_ch2
;
272 (dev
->_pixel_format_ch2
==
273 PIXEL_FRMT_411
) ? Y411_LINE_SZ
: Y422_LINE_SZ
;
275 int frame_offset
= 0;
276 ssize_t vfs_read_retval
= 0;
277 char mybuf
[line_size
];
282 if (dev
->_file_status_ch2
== END_OF_FILE
)
285 if (dev
->_isNTSC_ch2
) {
288 Y411_LINE_SZ
) ? FRAME_SIZE_NTSC_Y411
:
289 FRAME_SIZE_NTSC_Y422
;
293 Y411_LINE_SZ
) ? FRAME_SIZE_PAL_Y411
: FRAME_SIZE_PAL_Y422
;
296 frame_offset
= (frame_index_temp
> 0) ? frame_size
: 0;
297 file_offset
= dev
->_frame_count_ch2
* frame_size
;
299 myfile
= filp_open(dev
->_filename_ch2
, O_RDONLY
| O_LARGEFILE
, 0);
300 if (IS_ERR(myfile
)) {
301 const int open_errno
= -PTR_ERR(myfile
);
302 pr_err("%s(): ERROR opening file(%s) with errno = %d!\n",
303 __func__
, dev
->_filename_ch2
, open_errno
);
304 return PTR_ERR(myfile
);
306 if (!(myfile
->f_op
)) {
307 pr_err("%s(): File has no file operations registered!\n",
309 filp_close(myfile
, NULL
);
313 if (!myfile
->f_op
->read
) {
314 pr_err("%s(): File has no READ operations registered!\n",
316 filp_close(myfile
, NULL
);
324 for (i
= 0; i
< dev
->_lines_count_ch2
; i
++) {
328 vfs_read(myfile
, mybuf
, line_size
, &pos
);
330 if (vfs_read_retval
> 0 && vfs_read_retval
== line_size
331 && dev
->_data_buf_virt_addr_ch2
!= NULL
) {
332 memcpy((void *)(dev
->_data_buf_virt_addr_ch2
+
333 frame_offset
/ 4), mybuf
,
337 file_offset
+= vfs_read_retval
;
338 frame_offset
+= vfs_read_retval
;
340 if (vfs_read_retval
< line_size
) {
341 pr_info("Done: exit %s() since no more bytes to read from Video file\n",
348 dev
->_frame_count_ch2
++;
350 dev
->_file_status_ch2
=
351 (vfs_read_retval
== line_size
) ? IN_PROGRESS
: END_OF_FILE
;
354 filp_close(myfile
, NULL
);
360 static void cx25821_vidups_handler_ch2(struct work_struct
*work
)
362 struct cx25821_dev
*dev
=
363 container_of(work
, struct cx25821_dev
, _irq_work_entry_ch2
);
366 pr_err("ERROR %s(): since container_of(work_struct) FAILED!\n",
371 cx25821_get_frame_ch2(dev
,
373 _channel2_upstream_select
].sram_channels
);
376 int cx25821_openfile_ch2(struct cx25821_dev
*dev
, struct sram_channel
*sram_ch
)
381 (dev
->_pixel_format_ch2
==
382 PIXEL_FRMT_411
) ? Y411_LINE_SZ
: Y422_LINE_SZ
;
383 ssize_t vfs_read_retval
= 0;
384 char mybuf
[line_size
];
386 loff_t offset
= (unsigned long)0;
389 myfile
= filp_open(dev
->_filename_ch2
, O_RDONLY
| O_LARGEFILE
, 0);
391 if (IS_ERR(myfile
)) {
392 const int open_errno
= -PTR_ERR(myfile
);
393 pr_err("%s(): ERROR opening file(%s) with errno = %d!\n",
394 __func__
, dev
->_filename_ch2
, open_errno
);
395 return PTR_ERR(myfile
);
397 if (!(myfile
->f_op
)) {
398 pr_err("%s(): File has no file operations registered!\n",
400 filp_close(myfile
, NULL
);
404 if (!myfile
->f_op
->read
) {
405 pr_err("%s(): File has no READ operations registered! Returning\n",
407 filp_close(myfile
, NULL
);
415 for (j
= 0; j
< NUM_FRAMES
; j
++) {
416 for (i
= 0; i
< dev
->_lines_count_ch2
; i
++) {
420 vfs_read(myfile
, mybuf
, line_size
, &pos
);
422 if (vfs_read_retval
> 0
423 && vfs_read_retval
== line_size
424 && dev
->_data_buf_virt_addr_ch2
!= NULL
) {
425 memcpy((void *)(dev
->
426 _data_buf_virt_addr_ch2
427 + offset
/ 4), mybuf
,
431 offset
+= vfs_read_retval
;
433 if (vfs_read_retval
< line_size
) {
434 pr_info("Done: exit %s() since no more bytes to read from Video file\n",
441 dev
->_frame_count_ch2
++;
443 if (vfs_read_retval
< line_size
)
447 dev
->_file_status_ch2
=
448 (vfs_read_retval
== line_size
) ? IN_PROGRESS
: END_OF_FILE
;
452 filp_close(myfile
, NULL
);
458 static int cx25821_upstream_buffer_prepare_ch2(struct cx25821_dev
*dev
,
459 struct sram_channel
*sram_ch
,
464 dma_addr_t data_dma_addr
;
466 if (dev
->_dma_virt_addr_ch2
!= NULL
) {
467 pci_free_consistent(dev
->pci
, dev
->upstream_riscbuf_size_ch2
,
468 dev
->_dma_virt_addr_ch2
,
469 dev
->_dma_phys_addr_ch2
);
472 dev
->_dma_virt_addr_ch2
=
473 pci_alloc_consistent(dev
->pci
, dev
->upstream_riscbuf_size_ch2
,
475 dev
->_dma_virt_start_addr_ch2
= dev
->_dma_virt_addr_ch2
;
476 dev
->_dma_phys_start_addr_ch2
= dma_addr
;
477 dev
->_dma_phys_addr_ch2
= dma_addr
;
478 dev
->_risc_size_ch2
= dev
->upstream_riscbuf_size_ch2
;
480 if (!dev
->_dma_virt_addr_ch2
) {
481 pr_err("FAILED to allocate memory for Risc buffer! Returning\n");
485 /* Iniitize at this address until n bytes to 0 */
486 memset(dev
->_dma_virt_addr_ch2
, 0, dev
->_risc_size_ch2
);
488 if (dev
->_data_buf_virt_addr_ch2
!= NULL
) {
489 pci_free_consistent(dev
->pci
, dev
->upstream_databuf_size_ch2
,
490 dev
->_data_buf_virt_addr_ch2
,
491 dev
->_data_buf_phys_addr_ch2
);
493 /* For Video Data buffer allocation */
494 dev
->_data_buf_virt_addr_ch2
=
495 pci_alloc_consistent(dev
->pci
, dev
->upstream_databuf_size_ch2
,
497 dev
->_data_buf_phys_addr_ch2
= data_dma_addr
;
498 dev
->_data_buf_size_ch2
= dev
->upstream_databuf_size_ch2
;
500 if (!dev
->_data_buf_virt_addr_ch2
) {
501 pr_err("FAILED to allocate memory for data buffer! Returning\n");
505 /* Initialize at this address until n bytes to 0 */
506 memset(dev
->_data_buf_virt_addr_ch2
, 0, dev
->_data_buf_size_ch2
);
508 ret
= cx25821_openfile_ch2(dev
, sram_ch
);
512 /* Creating RISC programs */
514 cx25821_risc_buffer_upstream_ch2(dev
, dev
->pci
, 0, bpl
,
515 dev
->_lines_count_ch2
);
517 pr_info("Failed creating Video Upstream Risc programs!\n");
527 int cx25821_video_upstream_irq_ch2(struct cx25821_dev
*dev
, int chan_num
,
531 struct sram_channel
*channel
= dev
->channels
[chan_num
].sram_channels
;
532 int singlefield_lines
= NTSC_FIELD_HEIGHT
;
533 int line_size_in_bytes
= Y422_LINE_SZ
;
534 int odd_risc_prog_size
= 0;
535 dma_addr_t risc_phys_jump_addr
;
538 if (status
& FLD_VID_SRC_RISC1
) {
539 /* We should only process one program per call */
540 u32 prog_cnt
= cx_read(channel
->gpcnt
);
543 * Since we've identified our IRQ, clear our bits from the
544 * interrupt mask and interrupt status registers
546 int_msk_tmp
= cx_read(channel
->int_msk
);
547 cx_write(channel
->int_msk
, int_msk_tmp
& ~_intr_msk
);
548 cx_write(channel
->int_stat
, _intr_msk
);
550 spin_lock(&dev
->slock
);
552 dev
->_frame_index_ch2
= prog_cnt
;
554 queue_work(dev
->_irq_queues_ch2
, &dev
->_irq_work_entry_ch2
);
556 if (dev
->_is_first_frame_ch2
) {
557 dev
->_is_first_frame_ch2
= 0;
559 if (dev
->_isNTSC_ch2
) {
560 singlefield_lines
+= 1;
561 odd_risc_prog_size
= ODD_FLD_NTSC_PROG_SIZE
;
563 singlefield_lines
= PAL_FIELD_HEIGHT
;
564 odd_risc_prog_size
= ODD_FLD_PAL_PROG_SIZE
;
567 if (dev
->_dma_virt_start_addr_ch2
!= NULL
) {
569 (dev
->_pixel_format_ch2
==
570 PIXEL_FRMT_411
) ? Y411_LINE_SZ
:
572 risc_phys_jump_addr
=
573 dev
->_dma_phys_start_addr_ch2
+
576 rp
= cx25821_update_riscprogram_ch2(dev
,
578 _dma_virt_start_addr_ch2
,
586 /* Jump to Even Risc program of 1st Frame */
587 *(rp
++) = cpu_to_le32(RISC_JUMP
);
588 *(rp
++) = cpu_to_le32(risc_phys_jump_addr
);
589 *(rp
++) = cpu_to_le32(0);
593 spin_unlock(&dev
->slock
);
596 if (dev
->_file_status_ch2
== END_OF_FILE
) {
597 pr_info("EOF Channel 2 Framecount = %d\n",
598 dev
->_frame_count_ch2
);
601 /* ElSE, set the interrupt mask register, re-enable irq. */
602 int_msk_tmp
= cx_read(channel
->int_msk
);
603 cx_write(channel
->int_msk
, int_msk_tmp
|= _intr_msk
);
608 static irqreturn_t
cx25821_upstream_irq_ch2(int irq
, void *dev_id
)
610 struct cx25821_dev
*dev
= dev_id
;
611 u32 msk_stat
, vid_status
;
614 struct sram_channel
*sram_ch
;
619 channel_num
= VID_UPSTREAM_SRAM_CHANNEL_J
;
620 sram_ch
= dev
->channels
[channel_num
].sram_channels
;
622 msk_stat
= cx_read(sram_ch
->int_mstat
);
623 vid_status
= cx_read(sram_ch
->int_stat
);
625 /* Only deal with our interrupt */
628 cx25821_video_upstream_irq_ch2(dev
, channel_num
,
633 cx25821_stop_upstream_video_ch2(dev
);
637 return IRQ_RETVAL(handled
);
640 static void cx25821_set_pixelengine_ch2(struct cx25821_dev
*dev
,
641 struct sram_channel
*ch
, int pix_format
)
643 int width
= WIDTH_D1
;
644 int height
= dev
->_lines_count_ch2
;
645 int num_lines
, odd_num_lines
;
647 int vip_mode
= PIXEL_ENGINE_VIP1
;
649 value
= ((pix_format
& 0x3) << 12) | (vip_mode
& 0x7);
651 value
|= dev
->_isNTSC_ch2
? 0 : 0x10;
652 cx_write(ch
->vid_fmt_ctl
, value
);
655 * set number of active pixels in each line. Default is 720
656 * pixels in both NTSC and PAL format
658 cx_write(ch
->vid_active_ctl1
, width
);
660 num_lines
= (height
/ 2) & 0x3FF;
661 odd_num_lines
= num_lines
;
663 if (dev
->_isNTSC_ch2
)
666 value
= (num_lines
<< 16) | odd_num_lines
;
668 /* set number of active lines in field 0 (top) and field 1 (bottom) */
669 cx_write(ch
->vid_active_ctl2
, value
);
671 cx_write(ch
->vid_cdt_size
, VID_CDT_SIZE
>> 3);
674 int cx25821_start_video_dma_upstream_ch2(struct cx25821_dev
*dev
,
675 struct sram_channel
*sram_ch
)
681 * 656/VIP SRC Upstream Channel I & J and 7 - Host Bus Interface
684 tmp
= cx_read(VID_CH_MODE_SEL
);
685 cx_write(VID_CH_MODE_SEL
, tmp
| 0x1B0001FF);
688 * Set the physical start address of the RISC program in the initial
689 * program counter(IPC) member of the cmds.
691 cx_write(sram_ch
->cmds_start
+ 0, dev
->_dma_phys_addr_ch2
);
692 cx_write(sram_ch
->cmds_start
+ 4, 0); /* Risc IPC High 64 bits 63-32 */
695 cx_write(sram_ch
->gpcnt_ctl
, 3);
697 /* Clear our bits from the interrupt status register. */
698 cx_write(sram_ch
->int_stat
, _intr_msk
);
700 /* Set the interrupt mask register, enable irq. */
701 cx_set(PCI_INT_MSK
, cx_read(PCI_INT_MSK
) | (1 << sram_ch
->irq_bit
));
702 tmp
= cx_read(sram_ch
->int_msk
);
703 cx_write(sram_ch
->int_msk
, tmp
|= _intr_msk
);
706 request_irq(dev
->pci
->irq
, cx25821_upstream_irq_ch2
,
707 IRQF_SHARED
| IRQF_DISABLED
, dev
->name
, dev
);
709 pr_err("%s: can't get upstream IRQ %d\n",
710 dev
->name
, dev
->pci
->irq
);
713 /* Start the DMA engine */
714 tmp
= cx_read(sram_ch
->dma_ctl
);
715 cx_set(sram_ch
->dma_ctl
, tmp
| FLD_VID_RISC_EN
);
717 dev
->_is_running_ch2
= 1;
718 dev
->_is_first_frame_ch2
= 1;
723 cx25821_dev_unregister(dev
);
727 int cx25821_vidupstream_init_ch2(struct cx25821_dev
*dev
, int channel_select
,
730 struct sram_channel
*sram_ch
;
734 int data_frame_size
= 0;
735 int risc_buffer_size
= 0;
738 if (dev
->_is_running_ch2
) {
739 pr_info("Video Channel is still running so return!\n");
743 dev
->_channel2_upstream_select
= channel_select
;
744 sram_ch
= dev
->channels
[channel_select
].sram_channels
;
746 INIT_WORK(&dev
->_irq_work_entry_ch2
, cx25821_vidups_handler_ch2
);
747 dev
->_irq_queues_ch2
=
748 create_singlethread_workqueue("cx25821_workqueue2");
750 if (!dev
->_irq_queues_ch2
) {
751 pr_err("create_singlethread_workqueue() for Video FAILED!\n");
755 * 656/VIP SRC Upstream Channel I & J and 7 -
756 * Host Bus Interface for channel A-C
758 tmp
= cx_read(VID_CH_MODE_SEL
);
759 cx_write(VID_CH_MODE_SEL
, tmp
| 0x1B0001FF);
761 dev
->_is_running_ch2
= 0;
762 dev
->_frame_count_ch2
= 0;
763 dev
->_file_status_ch2
= RESET_STATUS
;
764 dev
->_lines_count_ch2
= dev
->_isNTSC_ch2
? 480 : 576;
765 dev
->_pixel_format_ch2
= pixel_format
;
766 dev
->_line_size_ch2
=
767 (dev
->_pixel_format_ch2
==
768 PIXEL_FRMT_422
) ? (WIDTH_D1
* 2) : (WIDTH_D1
* 3) / 2;
769 data_frame_size
= dev
->_isNTSC_ch2
? NTSC_DATA_BUF_SZ
: PAL_DATA_BUF_SZ
;
771 dev
->_isNTSC_ch2
? NTSC_RISC_BUF_SIZE
: PAL_RISC_BUF_SIZE
;
773 if (dev
->input_filename_ch2
) {
774 str_length
= strlen(dev
->input_filename_ch2
);
775 dev
->_filename_ch2
= kmalloc(str_length
+ 1, GFP_KERNEL
);
777 if (!dev
->_filename_ch2
)
780 memcpy(dev
->_filename_ch2
, dev
->input_filename_ch2
,
783 str_length
= strlen(dev
->_defaultname_ch2
);
784 dev
->_filename_ch2
= kmalloc(str_length
+ 1, GFP_KERNEL
);
786 if (!dev
->_filename_ch2
)
789 memcpy(dev
->_filename_ch2
, dev
->_defaultname_ch2
,
793 /* Default if filename is empty string */
794 if (strcmp(dev
->input_filename_ch2
, "") == 0) {
795 if (dev
->_isNTSC_ch2
) {
797 (dev
->_pixel_format_ch2
==
798 PIXEL_FRMT_411
) ? "/root/vid411.yuv" :
802 (dev
->_pixel_format_ch2
==
803 PIXEL_FRMT_411
) ? "/root/pal411.yuv" :
809 cx25821_sram_channel_setup_upstream(dev
, sram_ch
,
810 dev
->_line_size_ch2
, 0);
812 /* setup fifo + format */
813 cx25821_set_pixelengine_ch2(dev
, sram_ch
, dev
->_pixel_format_ch2
);
815 dev
->upstream_riscbuf_size_ch2
= risc_buffer_size
* 2;
816 dev
->upstream_databuf_size_ch2
= data_frame_size
* 2;
818 /* Allocating buffers and prepare RISC program */
820 cx25821_upstream_buffer_prepare_ch2(dev
, sram_ch
,
821 dev
->_line_size_ch2
);
823 pr_err("%s: Failed to set up Video upstream buffers!\n",
828 cx25821_start_video_dma_upstream_ch2(dev
, sram_ch
);
833 cx25821_dev_unregister(dev
);