int cx25821_vidupstream_init_ch1(struct cx25821_dev *dev, int channel_select, int pixel_format) { struct sram_channel *sram_ch; u32 tmp; int retval = 0; int err = 0; int data_frame_size = 0; int risc_buffer_size = 0; int str_length = 0; if (dev->_is_running) { pr_info("Video Channel is still running so return!\n"); return 0; } dev->_channel_upstream_select = channel_select; sram_ch = dev->channels[channel_select].sram_channels; INIT_WORK(&dev->_irq_work_entry, cx25821_vidups_handler); dev->_irq_queues = create_singlethread_workqueue("cx25821_workqueue"); if (!dev->_irq_queues) { pr_err("create_singlethread_workqueue() for Video FAILED!\n"); return -ENOMEM; } /* 656/VIP SRC Upstream Channel I & J and 7 - Host Bus Interface for * channel A-C */ tmp = cx_read(VID_CH_MODE_SEL); cx_write(VID_CH_MODE_SEL, tmp | 0x1B0001FF); dev->_is_running = 0; dev->_frame_count = 0; dev->_file_status = RESET_STATUS; dev->_lines_count = dev->_isNTSC ? 480 : 576; dev->_pixel_format = pixel_format; dev->_line_size = (dev->_pixel_format == PIXEL_FRMT_422) ? (WIDTH_D1 * 2) : (WIDTH_D1 * 3) / 2; data_frame_size = dev->_isNTSC ? NTSC_DATA_BUF_SZ : PAL_DATA_BUF_SZ; risc_buffer_size = dev->_isNTSC ? NTSC_RISC_BUF_SIZE : PAL_RISC_BUF_SIZE; if (dev->input_filename) { str_length = strlen(dev->input_filename); dev->_filename = kmemdup(dev->input_filename, str_length + 1, GFP_KERNEL); if (!dev->_filename) goto error; } else { str_length = strlen(dev->_defaultname); dev->_filename = kmemdup(dev->_defaultname, str_length + 1, GFP_KERNEL); if (!dev->_filename) goto error; } /* Default if filename is empty string */ if (strcmp(dev->_filename, "") == 0) { if (dev->_isNTSC) { dev->_filename = (dev->_pixel_format == PIXEL_FRMT_411) ? "/root/vid411.yuv" : "/root/vidtest.yuv"; } else { dev->_filename = (dev->_pixel_format == PIXEL_FRMT_411) ? "/root/pal411.yuv" : "/root/pal422.yuv"; } } dev->_is_running = 0; dev->_frame_count = 0; dev->_file_status = RESET_STATUS; dev->_lines_count = dev->_isNTSC ? 480 : 576; dev->_pixel_format = pixel_format; dev->_line_size = (dev->_pixel_format == PIXEL_FRMT_422) ? (WIDTH_D1 * 2) : (WIDTH_D1 * 3) / 2; retval = cx25821_sram_channel_setup_upstream(dev, sram_ch, dev->_line_size, 0); /* setup fifo + format */ cx25821_set_pixelengine(dev, sram_ch, dev->_pixel_format); dev->upstream_riscbuf_size = risc_buffer_size * 2; dev->upstream_databuf_size = data_frame_size * 2; /* Allocating buffers and prepare RISC program */ retval = cx25821_upstream_buffer_prepare(dev, sram_ch, dev->_line_size); if (retval < 0) { pr_err("%s: Failed to set up Video upstream buffers!\n", dev->name); goto error; } cx25821_start_video_dma_upstream(dev, sram_ch); return 0; error: cx25821_dev_unregister(dev); return err; }
int cx25821_vidupstream_init(struct cx25821_channel *chan, int pixel_format) { struct cx25821_video_out_data *out = chan->out; struct cx25821_dev *dev = chan->dev; const struct sram_channel *sram_ch; u32 tmp; int err = 0; int data_frame_size = 0; int risc_buffer_size = 0; if (out->_is_running) { pr_info("Video Channel is still running so return!\n"); return 0; } sram_ch = chan->sram_channels; out->is_60hz = dev->tvnorm & V4L2_STD_525_60; /* 656/VIP SRC Upstream Channel I & J and 7 - Host Bus Interface for * channel A-C */ tmp = cx_read(VID_CH_MODE_SEL); cx_write(VID_CH_MODE_SEL, tmp | 0x1B0001FF); out->_is_running = 0; out->_frame_count = 0; out->_file_status = RESET_STATUS; out->_lines_count = out->is_60hz ? 480 : 576; out->_pixel_format = pixel_format; out->_line_size = (out->_pixel_format == PIXEL_FRMT_422) ? (WIDTH_D1 * 2) : (WIDTH_D1 * 3) / 2; data_frame_size = out->is_60hz ? NTSC_DATA_BUF_SZ : PAL_DATA_BUF_SZ; risc_buffer_size = out->is_60hz ? NTSC_RISC_BUF_SIZE : PAL_RISC_BUF_SIZE; out->_is_running = 0; out->_frame_count = 0; out->_file_status = RESET_STATUS; out->_lines_count = out->is_60hz ? 480 : 576; out->_pixel_format = pixel_format; out->_line_size = (out->_pixel_format == PIXEL_FRMT_422) ? (WIDTH_D1 * 2) : (WIDTH_D1 * 3) / 2; out->curpos = 0; init_waitqueue_head(&out->waitq); err = cx25821_sram_channel_setup_upstream(dev, sram_ch, out->_line_size, 0); /* setup fifo + format */ cx25821_set_pixelengine(chan, sram_ch, out->_pixel_format); out->upstream_riscbuf_size = risc_buffer_size * 2; out->upstream_databuf_size = data_frame_size * 2; /* Allocating buffers and prepare RISC program */ err = cx25821_upstream_buffer_prepare(chan, sram_ch, out->_line_size); if (err < 0) { pr_err("%s: Failed to set up Video upstream buffers!\n", dev->name); goto error; } cx25821_start_video_dma_upstream(chan, sram_ch); return 0; error: cx25821_dev_unregister(dev); return err; }