Commit 7087d31b authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

[media] cx25821: drop cx25821-video-upstream-ch2.c/h

cx25821-video-upstream_ch2.c/h is practically identical to cx25821-video-upstream.c/h
so add support for ch2 into cx25821-video-upstream.c instead.
After this we can replace the custom ioctls with a proper write() interface.
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent e90878ab
cx25821-y := cx25821-core.o cx25821-cards.o cx25821-i2c.o \ cx25821-y := cx25821-core.o cx25821-cards.o cx25821-i2c.o \
cx25821-gpio.o cx25821-medusa-video.o \ cx25821-gpio.o cx25821-medusa-video.o \
cx25821-video.o cx25821-video-upstream.o \ cx25821-video.o cx25821-video-upstream.o \
cx25821-video-upstream-ch2.o \
cx25821-audio-upstream.o cx25821-audio-upstream.o
obj-$(CONFIG_VIDEO_CX25821) += cx25821.o obj-$(CONFIG_VIDEO_CX25821) += cx25821.o
......
...@@ -963,8 +963,6 @@ void cx25821_dev_unregister(struct cx25821_dev *dev) ...@@ -963,8 +963,6 @@ void cx25821_dev_unregister(struct cx25821_dev *dev)
if (!dev->base_io_addr) if (!dev->base_io_addr)
return; return;
cx25821_free_mem_upstream_ch1(dev);
cx25821_free_mem_upstream_ch2(dev);
cx25821_free_mem_upstream_audio(dev); cx25821_free_mem_upstream_audio(dev);
release_mem_region(dev->base_io_addr, pci_resource_len(dev->pci, 0)); release_mem_region(dev->base_io_addr, pci_resource_len(dev->pci, 0));
...@@ -972,6 +970,8 @@ void cx25821_dev_unregister(struct cx25821_dev *dev) ...@@ -972,6 +970,8 @@ void cx25821_dev_unregister(struct cx25821_dev *dev)
for (i = 0; i < MAX_VID_CHANNEL_NUM - 1; i++) { for (i = 0; i < MAX_VID_CHANNEL_NUM - 1; i++) {
if (i == SRAM_CH08) /* audio channel */ if (i == SRAM_CH08) /* audio channel */
continue; continue;
if (i == SRAM_CH09 || i == SRAM_CH10)
cx25821_free_mem_upstream(&dev->channels[i]);
cx25821_video_unregister(dev, i); cx25821_video_unregister(dev, i);
} }
......
This diff is collapsed.
/*
* Driver for the Conexant CX25821 PCIe bridge
*
* Copyright (C) 2009 Conexant Systems Inc.
* Authors <hiep.huynh@conexant.com>, <shu.lin@conexant.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <linux/mutex.h>
#include <linux/workqueue.h>
#define OPEN_FILE_1 0
#define NUM_PROGS 8
#define NUM_FRAMES 2
#define ODD_FIELD 0
#define EVEN_FIELD 1
#define TOP_OFFSET 0
#define FIFO_DISABLE 0
#define FIFO_ENABLE 1
#define TEST_FRAMES 5
#define END_OF_FILE 0
#define IN_PROGRESS 1
#define RESET_STATUS -1
#define NUM_NO_OPS 5
/* PAL and NTSC line sizes and number of lines. */
#define WIDTH_D1 720
#define NTSC_LINES_PER_FRAME 480
#define PAL_LINES_PER_FRAME 576
#define PAL_LINE_SZ 1440
#define Y422_LINE_SZ 1440
#define Y411_LINE_SZ 1080
#define NTSC_FIELD_HEIGHT 240
#define NTSC_ODD_FLD_LINES 241
#define PAL_FIELD_HEIGHT 288
#define FRAME_SIZE_NTSC_Y422 (NTSC_LINES_PER_FRAME * Y422_LINE_SZ)
#define FRAME_SIZE_NTSC_Y411 (NTSC_LINES_PER_FRAME * Y411_LINE_SZ)
#define FRAME_SIZE_PAL_Y422 (PAL_LINES_PER_FRAME * Y422_LINE_SZ)
#define FRAME_SIZE_PAL_Y411 (PAL_LINES_PER_FRAME * Y411_LINE_SZ)
#define NTSC_DATA_BUF_SZ (Y422_LINE_SZ * NTSC_LINES_PER_FRAME)
#define PAL_DATA_BUF_SZ (Y422_LINE_SZ * PAL_LINES_PER_FRAME)
#define RISC_WRITECR_INSTRUCTION_SIZE 16
#define RISC_SYNC_INSTRUCTION_SIZE 4
#define JUMP_INSTRUCTION_SIZE 12
#define MAXSIZE_NO_OPS 36
#define DWORD_SIZE 4
#define USE_RISC_NOOP_VIDEO 1
#ifdef USE_RISC_NOOP_VIDEO
#define PAL_US_VID_PROG_SIZE \
(PAL_FIELD_HEIGHT * 3 * DWORD_SIZE + \
RISC_WRITECR_INSTRUCTION_SIZE + RISC_SYNC_INSTRUCTION_SIZE + \
NUM_NO_OPS * DWORD_SIZE)
#define PAL_RISC_BUF_SIZE (2 * PAL_US_VID_PROG_SIZE)
#define PAL_VID_PROG_SIZE \
((PAL_FIELD_HEIGHT * 2) * 3 * DWORD_SIZE + \
2 * RISC_SYNC_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + \
JUMP_INSTRUCTION_SIZE + 2 * NUM_NO_OPS * DWORD_SIZE)
#define ODD_FLD_PAL_PROG_SIZE \
(PAL_FIELD_HEIGHT * 3 * DWORD_SIZE + \
RISC_SYNC_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + \
NUM_NO_OPS * DWORD_SIZE)
#define NTSC_US_VID_PROG_SIZE \
((NTSC_ODD_FLD_LINES + 1) * 3 * DWORD_SIZE + \
RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE + \
NUM_NO_OPS * DWORD_SIZE)
#define NTSC_RISC_BUF_SIZE \
(2 * (RISC_SYNC_INSTRUCTION_SIZE + NTSC_US_VID_PROG_SIZE))
#define FRAME1_VID_PROG_SIZE \
((NTSC_ODD_FLD_LINES + NTSC_FIELD_HEIGHT) * \
3 * DWORD_SIZE + 2 * RISC_SYNC_INSTRUCTION_SIZE + \
RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE + \
2 * NUM_NO_OPS * DWORD_SIZE)
#define ODD_FLD_NTSC_PROG_SIZE \
(NTSC_ODD_FLD_LINES * 3 * DWORD_SIZE + \
RISC_SYNC_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + \
NUM_NO_OPS * DWORD_SIZE)
#endif
#ifndef USE_RISC_NOOP_VIDEO
#define PAL_US_VID_PROG_SIZE \
((PAL_FIELD_HEIGHT + 1) * 3 * DWORD_SIZE + \
RISC_WRITECR_INSTRUCTION_SIZE)
#define PAL_RISC_BUF_SIZE \
(2 * (RISC_SYNC_INSTRUCTION_SIZE + PAL_US_VID_PROG_SIZE))
#define PAL_VID_PROG_SIZE \
((PAL_FIELD_HEIGHT * 2) * 3 * DWORD_SIZE + \
2 * RISC_SYNC_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + \
JUMP_INSTRUCTION_SIZE)
#define ODD_FLD_PAL_PROG_SIZE \
(PAL_FIELD_HEIGHT * 3 * DWORD_SIZE + \
RISC_SYNC_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE)
#define ODD_FLD_NTSC_PROG_SIZE \
(NTSC_ODD_FLD_LINES * 3 * DWORD_SIZE + \
RISC_SYNC_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE)
#define NTSC_US_VID_PROG_SIZE \
((NTSC_ODD_FLD_LINES + 1) * 3 * DWORD_SIZE + \
RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE)
#define NTSC_RISC_BUF_SIZE \
(2 * (RISC_SYNC_INSTRUCTION_SIZE + NTSC_US_VID_PROG_SIZE))
#define FRAME1_VID_PROG_SIZE \
((NTSC_ODD_FLD_LINES + NTSC_FIELD_HEIGHT) * \
3 * DWORD_SIZE + 2 * RISC_SYNC_INSTRUCTION_SIZE + \
RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE)
#endif
...@@ -893,6 +893,20 @@ static int vidioc_s_fmt_vid_out(struct file *file, void *priv, ...@@ -893,6 +893,20 @@ static int vidioc_s_fmt_vid_out(struct file *file, void *priv,
return 0; return 0;
} }
static int video_out_release(struct file *file)
{
struct cx25821_channel *chan = video_drvdata(file);
struct cx25821_video_out_data *out = chan->out;
struct cx25821_dev *dev = chan->dev;
mutex_lock(&dev->lock);
if ((chan->id == SRAM_CH09 || chan->id == SRAM_CH10) && out->_is_running)
cx25821_stop_upstream_video(chan);
mutex_unlock(&dev->lock);
return v4l2_fh_release(file);
}
static const struct v4l2_ctrl_ops cx25821_ctrl_ops = { static const struct v4l2_ctrl_ops cx25821_ctrl_ops = {
.s_ctrl = cx25821_s_ctrl, .s_ctrl = cx25821_s_ctrl,
}; };
...@@ -941,7 +955,7 @@ static const struct video_device cx25821_video_device = { ...@@ -941,7 +955,7 @@ static const struct video_device cx25821_video_device = {
static const struct v4l2_file_operations video_out_fops = { static const struct v4l2_file_operations video_out_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = v4l2_fh_open, .open = v4l2_fh_open,
.release = v4l2_fh_release, .release = video_out_release,
.unlocked_ioctl = video_ioctl2, .unlocked_ioctl = video_ioctl2,
}; };
...@@ -1017,6 +1031,9 @@ int cx25821_video_register(struct cx25821_dev *dev) ...@@ -1017,6 +1031,9 @@ int cx25821_video_register(struct cx25821_dev *dev)
err = v4l2_ctrl_handler_setup(hdl); err = v4l2_ctrl_handler_setup(hdl);
if (err) if (err)
goto fail_unreg; goto fail_unreg;
} else {
chan->out = &dev->vid_out_data[i - SRAM_CH09];
chan->out->chan = chan;
} }
cx25821_risc_stopper(dev->pci, &chan->dma_vidq.stopper, cx25821_risc_stopper(dev->pci, &chan->dma_vidq.stopper,
......
...@@ -172,6 +172,42 @@ struct cx25821_data { ...@@ -172,6 +172,42 @@ struct cx25821_data {
struct cx25821_dev; struct cx25821_dev;
struct cx25821_channel;
struct cx25821_video_out_data {
struct cx25821_channel *chan;
int _line_size;
int _prog_cnt;
int _pixel_format;
int _is_first_frame;
int _is_running;
int _file_status;
int _lines_count;
int _frame_count;
unsigned int _risc_size;
__le32 *_dma_virt_start_addr;
__le32 *_dma_virt_addr;
dma_addr_t _dma_phys_addr;
dma_addr_t _dma_phys_start_addr;
unsigned int _data_buf_size;
__le32 *_data_buf_virt_addr;
dma_addr_t _data_buf_phys_addr;
u32 upstream_riscbuf_size;
u32 upstream_databuf_size;
struct workqueue_struct *_irq_queues;
struct work_struct _irq_work_entry;
int is_60hz;
int _frame_index;
char *input_filename;
char *vid_stdname;
int pixel_format;
char *_filename;
char *_defaultname;
};
struct cx25821_channel { struct cx25821_channel {
unsigned id; unsigned id;
struct cx25821_dev *dev; struct cx25821_dev *dev;
...@@ -191,6 +227,9 @@ struct cx25821_channel { ...@@ -191,6 +227,9 @@ struct cx25821_channel {
int pixel_formats; int pixel_formats;
int use_cif_resolution; int use_cif_resolution;
int cif_width; int cif_width;
/* video output data for the video output channel */
struct cx25821_video_out_data *out;
}; };
struct snd_card; struct snd_card;
...@@ -250,83 +289,18 @@ struct cx25821_dev { ...@@ -250,83 +289,18 @@ struct cx25821_dev {
__le32 *_audiodata_buf_virt_addr; __le32 *_audiodata_buf_virt_addr;
dma_addr_t _audiodata_buf_phys_addr; dma_addr_t _audiodata_buf_phys_addr;
char *_audiofilename; char *_audiofilename;
/* V4l */
spinlock_t slock;
/* Video Upstream */
int _line_size;
int _prog_cnt;
int _pixel_format;
int _is_first_frame;
int _is_running;
int _file_status;
int _lines_count;
int _frame_count;
int _channel_upstream_select;
unsigned int _risc_size;
__le32 *_dma_virt_start_addr;
__le32 *_dma_virt_addr;
dma_addr_t _dma_phys_addr;
dma_addr_t _dma_phys_start_addr;
unsigned int _data_buf_size;
__le32 *_data_buf_virt_addr;
dma_addr_t _data_buf_phys_addr;
char *_filename;
char *_defaultname;
int _line_size_ch2;
int _prog_cnt_ch2;
int _pixel_format_ch2;
int _is_first_frame_ch2;
int _is_running_ch2;
int _file_status_ch2;
int _lines_count_ch2;
int _frame_count_ch2;
int _channel2_upstream_select;
unsigned int _risc_size_ch2;
__le32 *_dma_virt_start_addr_ch2;
__le32 *_dma_virt_addr_ch2;
dma_addr_t _dma_phys_addr_ch2;
dma_addr_t _dma_phys_start_addr_ch2;
unsigned int _data_buf_size_ch2;
__le32 *_data_buf_virt_addr_ch2;
dma_addr_t _data_buf_phys_addr_ch2;
char *_filename_ch2;
char *_defaultname_ch2;
u32 upstream_riscbuf_size;
u32 upstream_databuf_size;
u32 upstream_riscbuf_size_ch2;
u32 upstream_databuf_size_ch2;
u32 audio_upstream_riscbuf_size; u32 audio_upstream_riscbuf_size;
u32 audio_upstream_databuf_size; u32 audio_upstream_databuf_size;
int _isNTSC;
int _frame_index;
int _audioframe_index; int _audioframe_index;
struct workqueue_struct *_irq_queues;
struct work_struct _irq_work_entry;
struct workqueue_struct *_irq_queues_ch2;
struct work_struct _irq_work_entry_ch2;
struct workqueue_struct *_irq_audio_queues; struct workqueue_struct *_irq_audio_queues;
struct work_struct _audio_work_entry; struct work_struct _audio_work_entry;
char *input_filename;
char *input_filename_ch2;
int _frame_index_ch2;
int _isNTSC_ch2;
char *vid_stdname_ch2;
int pixel_format_ch2;
int channel_select_ch2;
int command_ch2;
char *input_audiofilename; char *input_audiofilename;
char *vid_stdname;
int pixel_format; /* V4l */
int channel_select; spinlock_t slock;
int command;
/* Video Upstream */
struct cx25821_video_out_data vid_out_data[2];
}; };
static inline struct cx25821_dev *get_cx25821(struct v4l2_device *v4l2_dev) static inline struct cx25821_dev *get_cx25821(struct v4l2_device *v4l2_dev)
...@@ -463,17 +437,12 @@ extern int cx25821_sram_channel_setup_audio(struct cx25821_dev *dev, ...@@ -463,17 +437,12 @@ extern int cx25821_sram_channel_setup_audio(struct cx25821_dev *dev,
const struct sram_channel *ch, const struct sram_channel *ch,
unsigned int bpl, u32 risc); unsigned int bpl, u32 risc);
extern int cx25821_vidupstream_init_ch1(struct cx25821_dev *dev, extern int cx25821_vidupstream_init(struct cx25821_channel *chan, int pixel_format);
int channel_select, int pixel_format);
extern int cx25821_vidupstream_init_ch2(struct cx25821_dev *dev,
int channel_select, int pixel_format);
extern int cx25821_audio_upstream_init(struct cx25821_dev *dev, extern int cx25821_audio_upstream_init(struct cx25821_dev *dev,
int channel_select); int channel_select);
extern void cx25821_free_mem_upstream_ch1(struct cx25821_dev *dev); extern void cx25821_free_mem_upstream(struct cx25821_channel *chan);
extern void cx25821_free_mem_upstream_ch2(struct cx25821_dev *dev);
extern void cx25821_free_mem_upstream_audio(struct cx25821_dev *dev); extern void cx25821_free_mem_upstream_audio(struct cx25821_dev *dev);
extern void cx25821_stop_upstream_video_ch1(struct cx25821_dev *dev); extern void cx25821_stop_upstream_video(struct cx25821_channel *chan);
extern void cx25821_stop_upstream_video_ch2(struct cx25821_dev *dev);
extern void cx25821_stop_upstream_audio(struct cx25821_dev *dev); extern void cx25821_stop_upstream_audio(struct cx25821_dev *dev);
extern int cx25821_sram_channel_setup_upstream(struct cx25821_dev *dev, extern int cx25821_sram_channel_setup_upstream(struct cx25821_dev *dev,
const struct sram_channel *ch, const struct sram_channel *ch,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment