23 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
29 #include <linux/errno.h>
30 #include <linux/kernel.h>
32 #include <linux/module.h>
35 #include <linux/fcntl.h>
36 #include <linux/slab.h>
48 unsigned int bpl,
u32 sync_line,
50 int fifo_enable,
int field_type)
53 int dist_betwn_starts = bpl * 2;
63 for (line = 0; line < lines; line++) {
70 offset += dist_betwn_starts;
81 u32 sync_line,
unsigned int bpl,
83 int fifo_enable,
int field_type)
88 int dist_betwn_starts = bpl * 2;
100 for (line = 0; line < lines; line++) {
107 offset += dist_betwn_starts;
115 if (fifo_enable && line == 3) {
119 *(rp++) = 0x00000001;
128 unsigned int top_offset,
unsigned int bpl,
133 int singlefield_lines = lines >> 1;
134 int odd_num_lines = singlefield_lines;
137 int databuf_offset = 0;
138 int risc_program_size = 0;
140 unsigned int bottom_offset = bpl;
144 odd_num_lines = singlefield_lines + 1;
161 for (frame = 0; frame <
NUM_FRAMES; frame++) {
162 databuf_offset = frame_size *
frame;
164 if (
UNSET != top_offset) {
166 rp = cx25821_risc_field_upstream_ch2(dev, rp,
168 top_offset, 0, bpl, odd_num_lines, fifo_enable,
175 rp = cx25821_risc_field_upstream_ch2(dev, rp,
177 bottom_offset, 0x200, bpl, singlefield_lines,
208 pr_info(
"No video file is currently running so return!\n");
268 char mybuf[line_size];
284 frame_offset = (frame_index_temp > 0) ? frame_size : 0;
288 if (IS_ERR(myfile)) {
289 const int open_errno = -PTR_ERR(myfile);
290 pr_err(
"%s(): ERROR opening file(%s) with errno = %d!\n",
292 return PTR_ERR(myfile);
294 if (!(myfile->
f_op)) {
295 pr_err(
"%s(): File has no file operations registered!\n",
301 if (!myfile->
f_op->read) {
302 pr_err(
"%s(): File has no READ operations registered!\n",
315 vfs_read_retval =
vfs_read(myfile, mybuf, line_size,
318 if (vfs_read_retval > 0 && vfs_read_retval == line_size
321 frame_offset / 4), mybuf,
325 file_offset += vfs_read_retval;
326 frame_offset += vfs_read_retval;
328 if (vfs_read_retval < line_size) {
329 pr_info(
"Done: exit %s() since no more bytes to read from Video file\n",
354 pr_err(
"ERROR %s(): since container_of(work_struct) FAILED!\n",
370 char mybuf[line_size];
372 loff_t offset = (
unsigned long)0;
377 if (IS_ERR(myfile)) {
378 const int open_errno = -PTR_ERR(myfile);
379 pr_err(
"%s(): ERROR opening file(%s) with errno = %d!\n",
381 return PTR_ERR(myfile);
383 if (!(myfile->
f_op)) {
384 pr_err(
"%s(): File has no file operations registered!\n",
390 if (!myfile->
f_op->read) {
391 pr_err(
"%s(): File has no READ operations registered! Returning\n",
405 vfs_read_retval =
vfs_read(myfile, mybuf,
408 if (vfs_read_retval > 0 &&
409 vfs_read_retval == line_size &&
412 _data_buf_virt_addr_ch2
413 + offset / 4), mybuf,
417 offset += vfs_read_retval;
419 if (vfs_read_retval < line_size) {
420 pr_info(
"Done: exit %s() since no more bytes to read from Video file\n",
429 if (vfs_read_retval < line_size)
444 static int cx25821_upstream_buffer_prepare_ch2(
struct cx25821_dev *dev,
466 pr_err(
"FAILED to allocate memory for Risc buffer! Returning\n");
485 pr_err(
"FAILED to allocate memory for data buffer! Returning\n");
500 pr_info(
"Failed creating Video Upstream Risc programs!\n");
517 int odd_risc_prog_size = 0;
533 spin_lock(&dev->
slock);
543 singlefield_lines += 1;
555 risc_phys_jump_addr =
559 rp = cx25821_update_riscprogram_ch2(dev,
562 0x0, singlefield_lines,
572 spin_unlock(&dev->
slock);
576 pr_info(
"EOF Channel 2 Framecount = %d\n",
599 sram_ch = dev->
channels[channel_num].sram_channels;
616 static void cx25821_set_pixelengine_ch2(
struct cx25821_dev *dev,
621 int num_lines, odd_num_lines;
625 value = ((pix_format & 0x3) << 12) | (vip_mode & 0x7);
636 num_lines = (height / 2) & 0x3FF;
637 odd_num_lines = num_lines;
642 value = (num_lines << 16) | odd_num_lines;
684 pr_err(
"%s: can't get upstream IRQ %d\n",
709 int data_frame_size = 0;
710 int risc_buffer_size = 0;
714 pr_info(
"Video Channel is still running so return!\n");
719 sram_ch = dev->
channels[channel_select].sram_channels;
726 pr_err(
"create_singlethread_workqueue() for Video FAILED!\n");
786 retval = cx25821_upstream_buffer_prepare_ch2(dev, sram_ch,
789 pr_err(
"%s: Failed to set up Video upstream buffers!\n",