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>
This commit is contained in:
Mauro Carvalho Chehab 2009-09-13 11:25:45 -03:00
parent 466a1c15b5
commit bb4c9a74b8
29 changed files with 3806 additions and 3807 deletions

View File

@ -72,7 +72,7 @@ struct cx25821_audio_dev {
unsigned long iobase; unsigned long iobase;
spinlock_t reg_lock; spinlock_t reg_lock;
atomic_t count; atomic_t count;
unsigned int dma_size; unsigned int dma_size;
unsigned int period_size; unsigned int period_size;

View File

@ -45,8 +45,8 @@ static int _intr_msk = FLD_AUD_SRC_RISCI1 | FLD_AUD_SRC_OF | FLD_AUD_SRC_SYNC |
int cx25821_sram_channel_setup_upstream_audio(struct cx25821_dev *dev, int cx25821_sram_channel_setup_upstream_audio(struct cx25821_dev *dev,
struct sram_channel *ch, struct sram_channel *ch,
unsigned int bpl, u32 risc) unsigned int bpl, u32 risc)
{ {
unsigned int i, lines; unsigned int i, lines;
u32 cdt; u32 cdt;
@ -66,7 +66,7 @@ int cx25821_sram_channel_setup_upstream_audio(struct cx25821_dev *dev,
if (lines > 3) if (lines > 3)
{ {
lines = 3; lines = 3;
} }
BUG_ON(lines < 2); BUG_ON(lines < 2);
@ -105,8 +105,8 @@ int cx25821_sram_channel_setup_upstream_audio(struct cx25821_dev *dev,
static __le32 *cx25821_risc_field_upstream_audio( struct cx25821_dev *dev, __le32 *rp, static __le32 *cx25821_risc_field_upstream_audio( struct cx25821_dev *dev, __le32 *rp,
dma_addr_t databuf_phys_addr, dma_addr_t databuf_phys_addr,
unsigned int bpl, int fifo_enable) unsigned int bpl, int fifo_enable)
{ {
unsigned int line; unsigned int line;
struct sram_channel *sram_ch = &dev->sram_channels[dev->_audio_upstream_channel_select]; struct sram_channel *sram_ch = &dev->sram_channels[dev->_audio_upstream_channel_select];
@ -117,28 +117,28 @@ static __le32 *cx25821_risc_field_upstream_audio( struct cx25821_dev *dev, __le3
for (line = 0; line < LINES_PER_AUDIO_BUFFER; line++) for (line = 0; line < LINES_PER_AUDIO_BUFFER; line++)
{ {
*(rp++) = cpu_to_le32(RISC_READ|RISC_SOL|RISC_EOL|bpl); *(rp++) = cpu_to_le32(RISC_READ|RISC_SOL|RISC_EOL|bpl);
*(rp++) = cpu_to_le32(databuf_phys_addr + offset); *(rp++) = cpu_to_le32(databuf_phys_addr + offset);
*(rp++) = cpu_to_le32(0); /* bits 63-32 */ *(rp++) = cpu_to_le32(0); /* bits 63-32 */
// Check if we need to enable the FIFO after the first 3 lines // Check if we need to enable the FIFO after the first 3 lines
// For the upstream audio channel, the risc engine will enable the FIFO. // For the upstream audio channel, the risc engine will enable the FIFO.
if ( fifo_enable && line == 2 ) if ( fifo_enable && line == 2 )
{ {
*(rp++) = RISC_WRITECR; *(rp++) = RISC_WRITECR;
*(rp++) = sram_ch->dma_ctl; *(rp++) = sram_ch->dma_ctl;
*(rp++) = sram_ch->fld_aud_fifo_en; *(rp++) = sram_ch->fld_aud_fifo_en;
*(rp++) = 0x00000020; *(rp++) = 0x00000020;
} }
offset += AUDIO_LINE_SIZE; offset += AUDIO_LINE_SIZE;
} }
return rp; return rp;
} }
int cx25821_risc_buffer_upstream_audio( struct cx25821_dev *dev, int cx25821_risc_buffer_upstream_audio( struct cx25821_dev *dev,
struct pci_dev *pci, struct pci_dev *pci,
unsigned int bpl, unsigned int lines) unsigned int bpl, unsigned int lines)
{ {
__le32 *rp; __le32 *rp;
int fifo_enable = 0; int fifo_enable = 0;
@ -158,48 +158,48 @@ int cx25821_risc_buffer_upstream_audio( struct cx25821_dev *dev,
for( frame = 0; frame < NUM_AUDIO_FRAMES; frame++ ) for( frame = 0; frame < NUM_AUDIO_FRAMES; frame++ )
{ {
databuf_offset = frame_size * frame; databuf_offset = frame_size * frame;
if( frame == 0 ) if( frame == 0 )
{ {
fifo_enable = 1; fifo_enable = 1;
risc_flag = RISC_CNT_RESET; risc_flag = RISC_CNT_RESET;
} }
else else
{ {
fifo_enable = 0; fifo_enable = 0;
risc_flag = RISC_CNT_INC; risc_flag = RISC_CNT_INC;
} }
//Calculate physical jump address //Calculate physical jump address
if( (frame+1) == NUM_AUDIO_FRAMES ) if( (frame+1) == NUM_AUDIO_FRAMES )
{ {
risc_phys_jump_addr = dev->_risc_phys_start_addr + RISC_SYNC_INSTRUCTION_SIZE; risc_phys_jump_addr = dev->_risc_phys_start_addr + RISC_SYNC_INSTRUCTION_SIZE;
} }
else else
{ {
risc_phys_jump_addr = dev->_risc_phys_start_addr + RISC_SYNC_INSTRUCTION_SIZE + AUDIO_RISC_DMA_BUF_SIZE*(frame+1); risc_phys_jump_addr = dev->_risc_phys_start_addr + RISC_SYNC_INSTRUCTION_SIZE + AUDIO_RISC_DMA_BUF_SIZE*(frame+1);
} }
rp = cx25821_risc_field_upstream_audio(dev, rp, dev->_audiodata_buf_phys_addr+databuf_offset, bpl, fifo_enable); rp = cx25821_risc_field_upstream_audio(dev, rp, dev->_audiodata_buf_phys_addr+databuf_offset, bpl, fifo_enable);
if( USE_RISC_NOOP_AUDIO ) if( USE_RISC_NOOP_AUDIO )
{ {
for( i = 0; i < NUM_NO_OPS; i++ ) for( i = 0; i < NUM_NO_OPS; i++ )
{ {
*(rp++) = cpu_to_le32(RISC_NOOP); *(rp++) = cpu_to_le32(RISC_NOOP);
} }
} }
// Loop to (Nth)FrameRISC or to Start of Risc program & generate IRQ // Loop to (Nth)FrameRISC or to Start of Risc program & generate IRQ
*(rp++) = cpu_to_le32(RISC_JUMP|RISC_IRQ1|risc_flag); *(rp++) = cpu_to_le32(RISC_JUMP|RISC_IRQ1|risc_flag);
*(rp++) = cpu_to_le32(risc_phys_jump_addr); *(rp++) = cpu_to_le32(risc_phys_jump_addr);
*(rp++) = cpu_to_le32(0); *(rp++) = cpu_to_le32(0);
//Recalculate virtual address based on frame index //Recalculate virtual address based on frame index
rp = dev->_risc_virt_addr + RISC_SYNC_INSTRUCTION_SIZE/4 + (AUDIO_RISC_DMA_BUF_SIZE*(frame+1)/4 ) ; rp = dev->_risc_virt_addr + RISC_SYNC_INSTRUCTION_SIZE/4 + (AUDIO_RISC_DMA_BUF_SIZE*(frame+1)/4 ) ;
} }
return 0; return 0;
@ -228,8 +228,8 @@ void cx25821_stop_upstream_audio(struct cx25821_dev *dev)
if( !dev->_audio_is_running ) if( !dev->_audio_is_running )
{ {
printk("cx25821: No audio file is currently running so return!\n"); printk("cx25821: No audio file is currently running so return!\n");
return; return;
} }
//Disable RISC interrupts //Disable RISC interrupts
@ -241,7 +241,7 @@ void cx25821_stop_upstream_audio(struct cx25821_dev *dev)
//Clear data buffer memory //Clear data buffer memory
if( dev->_audiodata_buf_virt_addr ) if( dev->_audiodata_buf_virt_addr )
memset( dev->_audiodata_buf_virt_addr, 0, dev->_audiodata_buf_size ); memset( dev->_audiodata_buf_virt_addr, 0, dev->_audiodata_buf_size );
dev->_audio_is_running = 0; dev->_audio_is_running = 0;
dev->_is_first_audio_frame = 0; dev->_is_first_audio_frame = 0;
@ -250,12 +250,12 @@ void cx25821_stop_upstream_audio(struct cx25821_dev *dev)
if( dev->_irq_audio_queues ) if( dev->_irq_audio_queues )
{ {
kfree(dev->_irq_audio_queues); kfree(dev->_irq_audio_queues);
dev->_irq_audio_queues = NULL; dev->_irq_audio_queues = NULL;
} }
if( dev->_audiofilename != NULL ) if( dev->_audiofilename != NULL )
kfree(dev->_audiofilename); kfree(dev->_audiofilename);
} }
@ -263,7 +263,7 @@ void cx25821_free_mem_upstream_audio(struct cx25821_dev *dev)
{ {
if( dev->_audio_is_running ) if( dev->_audio_is_running )
{ {
cx25821_stop_upstream_audio(dev); cx25821_stop_upstream_audio(dev);
} }
cx25821_free_memory_audio(dev); cx25821_free_memory_audio(dev);
@ -286,69 +286,69 @@ int cx25821_get_audio_data(struct cx25821_dev *dev, struct sram_channel *sram_ch
if( dev->_audiofile_status == END_OF_FILE ) if( dev->_audiofile_status == END_OF_FILE )
return 0; return 0;
myfile = filp_open( dev->_audiofilename, O_RDONLY | O_LARGEFILE, 0 ); myfile = filp_open( dev->_audiofilename, O_RDONLY | O_LARGEFILE, 0 );
if (IS_ERR(myfile)) if (IS_ERR(myfile))
{ {
const int open_errno = -PTR_ERR(myfile); const int open_errno = -PTR_ERR(myfile);
printk("%s(): ERROR opening file(%s) with errno = %d! \n", __func__, dev->_audiofilename, open_errno); printk("%s(): ERROR opening file(%s) with errno = %d! \n", __func__, dev->_audiofilename, open_errno);
return PTR_ERR(myfile); return PTR_ERR(myfile);
} }
else else
{ {
if( !(myfile->f_op) ) if( !(myfile->f_op) )
{ {
printk("%s: File has no file operations registered!\n", __func__); printk("%s: File has no file operations registered!\n", __func__);
filp_close(myfile, NULL); filp_close(myfile, NULL);
return -EIO; return -EIO;
} }
if( !myfile->f_op->read ) if( !myfile->f_op->read )
{ {
printk("%s: File has no READ operations registered! \n", __func__); printk("%s: File has no READ operations registered! \n", __func__);
filp_close(myfile, NULL); filp_close(myfile, NULL);
return -EIO; return -EIO;
} }
pos = myfile->f_pos; pos = myfile->f_pos;
old_fs = get_fs(); old_fs = get_fs();
set_fs(KERNEL_DS); set_fs(KERNEL_DS);
for( i = 0; i < dev->_audio_lines_count; i++ ) for( i = 0; i < dev->_audio_lines_count; i++ )
{ {
pos = file_offset; pos = file_offset;
vfs_read_retval = vfs_read(myfile, mybuf, line_size, &pos); vfs_read_retval = vfs_read(myfile, mybuf, line_size, &pos);
if( vfs_read_retval > 0 && vfs_read_retval == line_size && dev->_audiodata_buf_virt_addr != NULL ) if( vfs_read_retval > 0 && vfs_read_retval == line_size && dev->_audiodata_buf_virt_addr != NULL )
{ {
memcpy( (void*)(dev->_audiodata_buf_virt_addr+frame_offset/4), mybuf, vfs_read_retval); memcpy( (void*)(dev->_audiodata_buf_virt_addr+frame_offset/4), mybuf, vfs_read_retval);
} }
file_offset += vfs_read_retval; file_offset += vfs_read_retval;
frame_offset += vfs_read_retval; frame_offset += vfs_read_retval;
if( vfs_read_retval < line_size ) if( vfs_read_retval < line_size )
{ {
printk(KERN_INFO "Done: exit %s() since no more bytes to read from Audio file.\n", __func__ ); printk(KERN_INFO "Done: exit %s() since no more bytes to read from Audio file.\n", __func__ );
break; break;
} }
} }
if( i > 0 ) if( i > 0 )
dev->_audioframe_count++; dev->_audioframe_count++;
dev->_audiofile_status = (vfs_read_retval == line_size) ? IN_PROGRESS : END_OF_FILE; dev->_audiofile_status = (vfs_read_retval == line_size) ? IN_PROGRESS : END_OF_FILE;
set_fs(old_fs); set_fs(old_fs);
filp_close(myfile, NULL); filp_close(myfile, NULL);
} }
return 0; return 0;
@ -360,8 +360,8 @@ static void cx25821_audioups_handler(struct work_struct *work)
if( !dev ) if( !dev )
{ {
printk("ERROR %s(): since container_of(work_struct) FAILED! \n", __func__ ); printk("ERROR %s(): since container_of(work_struct) FAILED! \n", __func__ );
return; return;
} }
cx25821_get_audio_data( dev, &dev->sram_channels[dev->_audio_upstream_channel_select] ); cx25821_get_audio_data( dev, &dev->sram_channels[dev->_audio_upstream_channel_select] );
@ -384,79 +384,79 @@ int cx25821_openfile_audio(struct cx25821_dev *dev, struct sram_channel *sram_ch
if (IS_ERR(myfile)) if (IS_ERR(myfile))
{ {
const int open_errno = -PTR_ERR(myfile); const int open_errno = -PTR_ERR(myfile);
printk("%s(): ERROR opening file(%s) with errno = %d! \n", __func__, dev->_audiofilename, open_errno); printk("%s(): ERROR opening file(%s) with errno = %d! \n", __func__, dev->_audiofilename, open_errno);
return PTR_ERR(myfile); return PTR_ERR(myfile);
} }
else else
{ {
if( !(myfile->f_op) ) if( !(myfile->f_op) )
{ {
printk("%s: File has no file operations registered! \n", __func__); printk("%s: File has no file operations registered! \n", __func__);
filp_close(myfile, NULL); filp_close(myfile, NULL);
return -EIO; return -EIO;
} }
if( !myfile->f_op->read ) if( !myfile->f_op->read )
{ {
printk("%s: File has no READ operations registered! \n", __func__); printk("%s: File has no READ operations registered! \n", __func__);
filp_close(myfile, NULL); filp_close(myfile, NULL);
return -EIO; return -EIO;
} }
pos = myfile->f_pos; pos = myfile->f_pos;
old_fs = get_fs(); old_fs = get_fs();
set_fs(KERNEL_DS); set_fs(KERNEL_DS);
for( j = 0; j < NUM_AUDIO_FRAMES; j++ ) for( j = 0; j < NUM_AUDIO_FRAMES; j++ )
{ {
for( i = 0; i < dev->_audio_lines_count; i++ ) for( i = 0; i < dev->_audio_lines_count; i++ )
{ {
pos = offset; pos = offset;
vfs_read_retval = vfs_read(myfile, mybuf, line_size, &pos); vfs_read_retval = vfs_read(myfile, mybuf, line_size, &pos);
if( vfs_read_retval > 0 && vfs_read_retval == line_size && dev->_audiodata_buf_virt_addr != NULL ) if( vfs_read_retval > 0 && vfs_read_retval == line_size && dev->_audiodata_buf_virt_addr != NULL )
{ {
memcpy( (void*)(dev->_audiodata_buf_virt_addr+offset/4), mybuf, vfs_read_retval); memcpy( (void*)(dev->_audiodata_buf_virt_addr+offset/4), mybuf, vfs_read_retval);
} }
offset += vfs_read_retval; offset += vfs_read_retval;
if( vfs_read_retval < line_size ) if( vfs_read_retval < line_size )
{ {
printk(KERN_INFO "Done: exit %s() since no more bytes to read from Audio file.\n", __func__ ); printk(KERN_INFO "Done: exit %s() since no more bytes to read from Audio file.\n", __func__ );
break; break;
} }
} }
if( i > 0 ) if( i > 0 )
{ {
dev->_audioframe_count++; dev->_audioframe_count++;
} }
if( vfs_read_retval < line_size ) if( vfs_read_retval < line_size )
{ {
break; break;
} }
} }
dev->_audiofile_status = (vfs_read_retval == line_size) ? IN_PROGRESS : END_OF_FILE; dev->_audiofile_status = (vfs_read_retval == line_size) ? IN_PROGRESS : END_OF_FILE;
set_fs(old_fs); set_fs(old_fs);
myfile->f_pos = 0; myfile->f_pos = 0;
filp_close(myfile, NULL); filp_close(myfile, NULL);
} }
return 0; return 0;
} }
static int cx25821_audio_upstream_buffer_prepare(struct cx25821_dev *dev, static int cx25821_audio_upstream_buffer_prepare(struct cx25821_dev *dev,
struct sram_channel *sram_ch, struct sram_channel *sram_ch,
int bpl) int bpl)
{ {
int ret = 0; int ret = 0;
dma_addr_t dma_addr; dma_addr_t dma_addr;
@ -474,7 +474,7 @@ static int cx25821_audio_upstream_buffer_prepare(struct cx25821_dev *dev,
if (!dev->_risc_virt_addr) if (!dev->_risc_virt_addr)
{ {
printk("cx25821 ERROR: pci_alloc_consistent() FAILED to allocate memory for RISC program! Returning.\n"); printk("cx25821 ERROR: pci_alloc_consistent() FAILED to allocate memory for RISC program! Returning.\n");
return -ENOMEM; return -ENOMEM;
} }
@ -489,7 +489,7 @@ static int cx25821_audio_upstream_buffer_prepare(struct cx25821_dev *dev,
if (!dev->_audiodata_buf_virt_addr) if (!dev->_audiodata_buf_virt_addr)
{ {
printk("cx25821 ERROR: pci_alloc_consistent() FAILED to allocate memory for data buffer! Returning. \n"); printk("cx25821 ERROR: pci_alloc_consistent() FAILED to allocate memory for data buffer! Returning. \n");
return -ENOMEM; return -ENOMEM;
} }
@ -499,7 +499,7 @@ static int cx25821_audio_upstream_buffer_prepare(struct cx25821_dev *dev,
ret = cx25821_openfile_audio(dev, sram_ch); ret = cx25821_openfile_audio(dev, sram_ch);
if( ret < 0 ) if( ret < 0 )
return ret; return ret;
//Creating RISC programs //Creating RISC programs
@ -528,80 +528,80 @@ int cx25821_audio_upstream_irq(struct cx25821_dev *dev, int chan_num, u32 status
if (status & FLD_AUD_SRC_RISCI1) if (status & FLD_AUD_SRC_RISCI1)
{ {
//Get interrupt_index of the program that interrupted //Get interrupt_index of the program that interrupted
u32 prog_cnt = cx_read( channel->gpcnt ); u32 prog_cnt = cx_read( channel->gpcnt );
//Since we've identified our IRQ, clear our bits from the interrupt mask and interrupt status registers //Since we've identified our IRQ, clear our bits from the interrupt mask and interrupt status registers
cx_write(channel->int_msk, 0); cx_write(channel->int_msk, 0);
cx_write(channel->int_stat, cx_read(channel->int_stat) ); cx_write(channel->int_stat, cx_read(channel->int_stat) );
spin_lock(&dev->slock); spin_lock(&dev->slock);
while(prog_cnt != dev->_last_index_irq) while(prog_cnt != dev->_last_index_irq)
{ {
//Update _last_index_irq //Update _last_index_irq
if(dev->_last_index_irq < (NUMBER_OF_PROGRAMS-1)) if(dev->_last_index_irq < (NUMBER_OF_PROGRAMS-1))
{ {
dev->_last_index_irq++; dev->_last_index_irq++;
} }
else else
{ {
dev->_last_index_irq = 0; dev->_last_index_irq = 0;
} }
dev->_audioframe_index = dev->_last_index_irq; dev->_audioframe_index = dev->_last_index_irq;
queue_work(dev->_irq_audio_queues, &dev->_audio_work_entry); queue_work(dev->_irq_audio_queues, &dev->_audio_work_entry);
} }
if ( dev->_is_first_audio_frame ) if ( dev->_is_first_audio_frame )
{ {
dev->_is_first_audio_frame = 0; dev->_is_first_audio_frame = 0;
if( dev->_risc_virt_start_addr != NULL ) if( dev->_risc_virt_start_addr != NULL )
{ {
risc_phys_jump_addr = dev->_risc_phys_start_addr + RISC_SYNC_INSTRUCTION_SIZE + AUDIO_RISC_DMA_BUF_SIZE; risc_phys_jump_addr = dev->_risc_phys_start_addr + RISC_SYNC_INSTRUCTION_SIZE + AUDIO_RISC_DMA_BUF_SIZE;
rp = cx25821_risc_field_upstream_audio(dev, dev->_risc_virt_start_addr+1, dev->_audiodata_buf_phys_addr, AUDIO_LINE_SIZE, FIFO_DISABLE); rp = cx25821_risc_field_upstream_audio(dev, dev->_risc_virt_start_addr+1, dev->_audiodata_buf_phys_addr, AUDIO_LINE_SIZE, FIFO_DISABLE);
if( USE_RISC_NOOP_AUDIO ) if( USE_RISC_NOOP_AUDIO )
{ {
for( i = 0; i < NUM_NO_OPS; i++ ) for( i = 0; i < NUM_NO_OPS; i++ )
{ {
*(rp++) = cpu_to_le32(RISC_NOOP); *(rp++) = cpu_to_le32(RISC_NOOP);
} }
} }
// Jump to 2nd Audio Frame // Jump to 2nd Audio Frame
*(rp++) = cpu_to_le32(RISC_JUMP | RISC_IRQ1 | RISC_CNT_RESET); *(rp++) = cpu_to_le32(RISC_JUMP | RISC_IRQ1 | RISC_CNT_RESET);
*(rp++) = cpu_to_le32(risc_phys_jump_addr); *(rp++) = cpu_to_le32(risc_phys_jump_addr);
*(rp++) = cpu_to_le32(0); *(rp++) = cpu_to_le32(0);
} }
} }
spin_unlock(&dev->slock); spin_unlock(&dev->slock);
} }
else else
{ {
if(status & FLD_AUD_SRC_OF) if(status & FLD_AUD_SRC_OF)
printk("%s: Audio Received Overflow Error Interrupt!\n", __func__); printk("%s: Audio Received Overflow Error Interrupt!\n", __func__);
if(status & FLD_AUD_SRC_SYNC) if(status & FLD_AUD_SRC_SYNC)
printk("%s: Audio Received Sync Error Interrupt!\n", __func__); printk("%s: Audio Received Sync Error Interrupt!\n", __func__);
if(status & FLD_AUD_SRC_OPC_ERR) if(status & FLD_AUD_SRC_OPC_ERR)
printk("%s: Audio Received OpCode Error Interrupt!\n", __func__); printk("%s: Audio Received OpCode Error Interrupt!\n", __func__);
// Read and write back the interrupt status register to clear our bits // Read and write back the interrupt status register to clear our bits
cx_write(channel->int_stat, cx_read(channel->int_stat) ); cx_write(channel->int_stat, cx_read(channel->int_stat) );
} }
if( dev->_audiofile_status == END_OF_FILE ) if( dev->_audiofile_status == END_OF_FILE )
{ {
printk("cx25821: EOF Channel Audio Framecount = %d\n", dev->_audioframe_count ); printk("cx25821: EOF Channel Audio Framecount = %d\n", dev->_audioframe_count );
return -1; return -1;
} }
//ElSE, set the interrupt mask register, re-enable irq. //ElSE, set the interrupt mask register, re-enable irq.
@ -620,7 +620,7 @@ static irqreturn_t cx25821_upstream_irq_audio(int irq, void *dev_id)
if( !dev ) if( !dev )
return -1; return -1;
sram_ch = &dev->sram_channels[dev->_audio_upstream_channel_select]; sram_ch = &dev->sram_channels[dev->_audio_upstream_channel_select];
@ -631,17 +631,17 @@ static irqreturn_t cx25821_upstream_irq_audio(int irq, void *dev_id)
// Only deal with our interrupt // Only deal with our interrupt
if(audio_status) if(audio_status)
{ {
handled = cx25821_audio_upstream_irq(dev, dev->_audio_upstream_channel_select, audio_status); handled = cx25821_audio_upstream_irq(dev, dev->_audio_upstream_channel_select, audio_status);
} }
if( handled < 0 ) if( handled < 0 )
{ {
cx25821_stop_upstream_audio(dev); cx25821_stop_upstream_audio(dev);
} }
else else
{ {
handled += handled; handled += handled;
} }
return IRQ_RETVAL(handled); return IRQ_RETVAL(handled);
@ -655,16 +655,16 @@ static void cx25821_wait_fifo_enable(struct cx25821_dev *dev, struct sram_channe
do do
{ {
//Wait 10 microsecond before checking to see if the FIFO is turned ON. //Wait 10 microsecond before checking to see if the FIFO is turned ON.
udelay(10); udelay(10);
tmp = cx_read( sram_ch->dma_ctl ); tmp = cx_read( sram_ch->dma_ctl );
if(count++ > 1000) //10 millisecond timeout if(count++ > 1000) //10 millisecond timeout
{ {
printk("cx25821 ERROR: %s() fifo is NOT turned on. Timeout!\n", __func__); printk("cx25821 ERROR: %s() fifo is NOT turned on. Timeout!\n", __func__);
return; return;
} }
} while( !(tmp & sram_ch->fld_aud_fifo_en) ); } while( !(tmp & sram_ch->fld_aud_fifo_en) );
@ -672,7 +672,7 @@ static void cx25821_wait_fifo_enable(struct cx25821_dev *dev, struct sram_channe
int cx25821_start_audio_dma_upstream(struct cx25821_dev *dev, int cx25821_start_audio_dma_upstream(struct cx25821_dev *dev,
struct sram_channel *sram_ch) struct sram_channel *sram_ch)
{ {
u32 tmp = 0; u32 tmp = 0;
int err = 0; int err = 0;
@ -744,8 +744,8 @@ int cx25821_audio_upstream_init(struct cx25821_dev *dev, int channel_select)
if( dev->_audio_is_running ) if( dev->_audio_is_running )
{ {
printk("Audio Channel is still running so return!\n"); printk("Audio Channel is still running so return!\n");
return 0; return 0;
} }
dev->_audio_upstream_channel_select = channel_select; dev->_audio_upstream_channel_select = channel_select;
@ -757,7 +757,7 @@ int cx25821_audio_upstream_init(struct cx25821_dev *dev, int channel_select)
if(!dev->_irq_audio_queues) if(!dev->_irq_audio_queues)
{ {
printk("cx25821 ERROR: create_singlethread_workqueue() for Audio FAILED!\n"); printk("cx25821 ERROR: create_singlethread_workqueue() for Audio FAILED!\n");
return -ENOMEM; return -ENOMEM;
} }
@ -772,29 +772,29 @@ int cx25821_audio_upstream_init(struct cx25821_dev *dev, int channel_select)
if( dev->input_audiofilename ) if( dev->input_audiofilename )
{ {
str_length = strlen(dev->input_audiofilename); str_length = strlen(dev->input_audiofilename);
dev->_audiofilename = (char *) kmalloc(str_length + 1, GFP_KERNEL); dev->_audiofilename = (char *) kmalloc(str_length + 1, GFP_KERNEL);
if( !dev->_audiofilename ) if( !dev->_audiofilename )
goto error; goto error;
memcpy(dev->_audiofilename, dev->input_audiofilename, str_length + 1); memcpy(dev->_audiofilename, dev->input_audiofilename, str_length + 1);
//Default if filename is empty string //Default if filename is empty string
if( strcmp(dev->input_audiofilename,"") == 0) if( strcmp(dev->input_audiofilename,"") == 0)
{ {
dev->_audiofilename = "/root/audioGOOD.wav"; dev->_audiofilename = "/root/audioGOOD.wav";
} }
} }
else else
{ {
str_length = strlen(_defaultAudioName); str_length = strlen(_defaultAudioName);
dev->_audiofilename = (char *) kmalloc(str_length + 1, GFP_KERNEL); dev->_audiofilename = (char *) kmalloc(str_length + 1, GFP_KERNEL);
if( !dev->_audiofilename ) if( !dev->_audiofilename )
goto error; goto error;
memcpy(dev->_audiofilename, _defaultAudioName, str_length + 1); memcpy(dev->_audiofilename, _defaultAudioName, str_length + 1);
} }
@ -822,4 +822,3 @@ int cx25821_audio_upstream_init(struct cx25821_dev *dev, int channel_select)
return err; return err;
} }

View File

@ -40,37 +40,37 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]); dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]);
if (!list_empty(&q->queued)) { if (!list_empty(&q->queued)) {
list_add_tail(&buf->vb.queue, &q->queued); list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED; buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i); dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i);
} else if (list_empty(&q->active)) { } else if (list_empty(&q->active)) {
list_add_tail(&buf->vb.queue, &q->active); list_add_tail(&buf->vb.queue, &q->active);
cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH11]); cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH11]);
buf->vb.state = VIDEOBUF_ACTIVE; buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++; buf->count = q->count++;
mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n", dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n",
buf, buf->vb. i, buf->count, q->count); buf, buf->vb. i, buf->count, q->count);
} else { } else {
prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue); prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue);
if (prev->vb.width == buf->vb.width && if (prev->vb.width == buf->vb.width &&
prev->vb.height == buf->vb.height && prev->vb.height == buf->vb.height &&
prev->fmt == buf->fmt) { prev->fmt == buf->fmt) {
list_add_tail(&buf->vb.queue, &q->active); list_add_tail(&buf->vb.queue, &q->active);
buf->vb.state = VIDEOBUF_ACTIVE; buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++; buf->count = q->count++;
prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
/* 64 bit bits 63-32 */ /* 64 bit bits 63-32 */
prev->risc.jmp[2] = cpu_to_le32(0); prev->risc.jmp[2] = cpu_to_le32(0);
dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count); dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count);
} else { } else {
list_add_tail(&buf->vb.queue, &q->queued); list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED; buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i); dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i);
} }
} }
if (list_empty(&q->active)) if (list_empty(&q->active))
@ -99,18 +99,18 @@ static int video_open(struct file *file)
lock_kernel(); lock_kernel();
list_for_each(list, &cx25821_devlist) list_for_each(list, &cx25821_devlist)
{ {
h = list_entry(list, struct cx25821_dev, devlist); h = list_entry(list, struct cx25821_dev, devlist);
if (h->video_dev[SRAM_CH11] && h->video_dev[SRAM_CH11]->minor == minor) if (h->video_dev[SRAM_CH11] && h->video_dev[SRAM_CH11]->minor == minor)
{ {
dev = h; dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE; type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
} }
} }
if (NULL == dev) { if (NULL == dev) {
unlock_kernel(); unlock_kernel();
return -ENODEV; return -ENODEV;
} }
printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
@ -118,8 +118,8 @@ static int video_open(struct file *file)
/* allocate + initialize per filehandle data */ /* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL); fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) { if (NULL == fh) {
unlock_kernel(); unlock_kernel();
return -ENOMEM; return -ENOMEM;
} }
file->private_data = fh; file->private_data = fh;
@ -128,9 +128,9 @@ static int video_open(struct file *file)
fh->width = 720; fh->width = 720;
if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK)
fh->height = 576; fh->height = 576;
else else
fh->height = 480; fh->height = 480;
dev->channel_opened = 10; dev->channel_opened = 10;
fh->fmt = format_by_fourcc(V4L2_PIX_FMT_YUYV); fh->fmt = format_by_fourcc(V4L2_PIX_FMT_YUYV);
@ -138,11 +138,11 @@ static int video_open(struct file *file)
v4l2_prio_open(&dev->prio,&fh->prio); v4l2_prio_open(&dev->prio,&fh->prio);
videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops, videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops,
&dev->pci->dev, &dev->slock, &dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED, V4L2_FIELD_INTERLACED,
sizeof(struct cx25821_buffer), sizeof(struct cx25821_buffer),
fh); fh);
dprintk(1, "post videobuf_queue_init()\n"); dprintk(1, "post videobuf_queue_init()\n");
unlock_kernel(); unlock_kernel();
@ -156,15 +156,15 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo
switch (fh->type) switch (fh->type)
{ {
case V4L2_BUF_TYPE_VIDEO_CAPTURE: case V4L2_BUF_TYPE_VIDEO_CAPTURE:
if (res_locked(fh->dev, RESOURCE_VIDEO11)) if (res_locked(fh->dev, RESOURCE_VIDEO11))
return -EBUSY; return -EBUSY;
return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK); return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK);
default: default:
BUG(); BUG();
return 0; return 0;
} }
} }
@ -174,21 +174,21 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait
struct cx25821_buffer *buf; struct cx25821_buffer *buf;
if (res_check(fh, RESOURCE_VIDEO11)) { if (res_check(fh, RESOURCE_VIDEO11)) {
/* streaming capture */ /* streaming capture */
if (list_empty(&fh->vidq.stream)) if (list_empty(&fh->vidq.stream))
return POLLERR; return POLLERR;
buf = list_entry(fh->vidq.stream.next, buf = list_entry(fh->vidq.stream.next,
struct cx25821_buffer, vb.stream); struct cx25821_buffer, vb.stream);
} else { } else {
/* read() capture */ /* read() capture */
buf = (struct cx25821_buffer *)fh->vidq.read_buf; buf = (struct cx25821_buffer *)fh->vidq.read_buf;
if (NULL == buf) if (NULL == buf)
return POLLERR; return POLLERR;
} }
poll_wait(file, &buf->vb.done, wait); poll_wait(file, &buf->vb.done, wait);
if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR) if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR)
return POLLIN|POLLRDNORM; return POLLIN|POLLRDNORM;
return 0; return 0;
} }
@ -203,13 +203,13 @@ static int video_release(struct file *file)
/* stop video capture */ /* stop video capture */
if (res_check(fh, RESOURCE_VIDEO11)) { if (res_check(fh, RESOURCE_VIDEO11)) {
videobuf_queue_cancel(&fh->vidq); videobuf_queue_cancel(&fh->vidq);
res_free(dev, fh, RESOURCE_VIDEO11); res_free(dev, fh, RESOURCE_VIDEO11);
} }
if (fh->vidq.read_buf) { if (fh->vidq.read_buf) {
buffer_release(&fh->vidq, fh->vidq.read_buf); buffer_release(&fh->vidq, fh->vidq.read_buf);
kfree(fh->vidq.read_buf); kfree(fh->vidq.read_buf);
} }
videobuf_mmap_free(&fh->vidq); videobuf_mmap_free(&fh->vidq);
@ -230,17 +230,17 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE))
{ {
return -EINVAL; return -EINVAL;
} }
if (unlikely(i != fh->type)) if (unlikely(i != fh->type))
{ {
return -EINVAL; return -EINVAL;
} }
if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO11)))) if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO11))))
{ {
return -EBUSY; return -EBUSY;
} }
return videobuf_streamon(get_queue(fh)); return videobuf_streamon(get_queue(fh));
@ -253,14 +253,14 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
int err, res; int err, res;
if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL; return -EINVAL;
if (i != fh->type) if (i != fh->type)
return -EINVAL; return -EINVAL;
res = get_resource(fh, RESOURCE_VIDEO11); res = get_resource(fh, RESOURCE_VIDEO11);
err = videobuf_streamoff(get_queue(fh)); err = videobuf_streamoff(get_queue(fh));
if (err < 0) if (err < 0)
return err; return err;
res_free(dev, fh, res); res_free(dev, fh, res);
return 0; return 0;
} }
@ -274,16 +274,16 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
if (fh) if (fh)
{ {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
dprintk(2, "%s()\n", __func__); dprintk(2, "%s()\n", __func__);
err = vidioc_try_fmt_vid_cap(file, priv, f); err = vidioc_try_fmt_vid_cap(file, priv, f);
if (0 != err) if (0 != err)
return err; return err;
fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat);
fh->width = f->fmt.pix.width; fh->width = f->fmt.pix.width;
fh->height = f->fmt.pix.height; fh->height = f->fmt.pix.height;
@ -305,15 +305,15 @@ static long video_ioctl_upstream11(struct file *file, unsigned int cmd, unsigned
if( !data_from_user ) if( !data_from_user )
{ {
printk("cx25821 in %s(): Upstream data is INVALID. Returning.\n", __func__); printk("cx25821 in %s(): Upstream data is INVALID. Returning.\n", __func__);
return 0; return 0;
} }
command = data_from_user->command; command = data_from_user->command;
if( command != UPSTREAM_START_AUDIO && command != UPSTREAM_STOP_AUDIO ) if( command != UPSTREAM_START_AUDIO && command != UPSTREAM_STOP_AUDIO )
{ {
return 0; return 0;
} }
@ -327,13 +327,13 @@ static long video_ioctl_upstream11(struct file *file, unsigned int cmd, unsigned
switch(command) switch(command)
{ {
case UPSTREAM_START_AUDIO: case UPSTREAM_START_AUDIO:
cx25821_start_upstream_audio(dev, data_from_user); cx25821_start_upstream_audio(dev, data_from_user);
break; break;
case UPSTREAM_STOP_AUDIO: case UPSTREAM_STOP_AUDIO:
cx25821_stop_upstream_audio(dev); cx25821_stop_upstream_audio(dev);
break; break;
} }
return 0; return 0;
@ -368,9 +368,9 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
if (fh) if (fh)
{ {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
return 0; return 0;
} }

View File

@ -43,7 +43,7 @@ struct cx25821_board cx25821_boards[] = {
.name = "CX25821", .name = "CX25821",
.portb = CX25821_RAW, .portb = CX25821_RAW,
.portc = CX25821_264, .portc = CX25821_264,
.input[0].type = CX25821_VMUX_COMPOSITE, .input[0].type = CX25821_VMUX_COMPOSITE,
}, },
}; };

File diff suppressed because it is too large Load Diff

View File

@ -25,8 +25,8 @@
/********************* GPIO stuffs *********************/ /********************* GPIO stuffs *********************/
void cx25821_set_gpiopin_direction( struct cx25821_dev *dev, void cx25821_set_gpiopin_direction( struct cx25821_dev *dev,
int pin_number, int pin_number,
int pin_logic_value) int pin_logic_value)
{ {
int bit = pin_number; int bit = pin_number;
u32 gpio_oe_reg = GPIO_LO_OE; u32 gpio_oe_reg = GPIO_LO_OE;
@ -35,7 +35,7 @@ void cx25821_set_gpiopin_direction( struct cx25821_dev *dev,
// Check for valid pinNumber // Check for valid pinNumber
if ( pin_number >= 47 ) if ( pin_number >= 47 )
return; return;
if ( pin_number > 31 ) if ( pin_number > 31 )
@ -49,19 +49,19 @@ void cx25821_set_gpiopin_direction( struct cx25821_dev *dev,
if (pin_logic_value == 1) if (pin_logic_value == 1)
{ {
value = gpio_register | Set_GPIO_Bit(bit) ; value = gpio_register | Set_GPIO_Bit(bit) ;
} }
else else
{ {
value = gpio_register & Clear_GPIO_Bit(bit) ; value = gpio_register & Clear_GPIO_Bit(bit) ;
} }
cx_write( gpio_oe_reg, value ); cx_write( gpio_oe_reg, value );
} }
static void cx25821_set_gpiopin_logicvalue( struct cx25821_dev *dev, static void cx25821_set_gpiopin_logicvalue( struct cx25821_dev *dev,
int pin_number, int pin_number,
int pin_logic_value) int pin_logic_value)
{ {
int bit = pin_number; int bit = pin_number;
u32 gpio_reg = GPIO_LO; u32 gpio_reg = GPIO_LO;
@ -70,7 +70,7 @@ static void cx25821_set_gpiopin_logicvalue( struct cx25821_dev *dev,
// Check for valid pinNumber // Check for valid pinNumber
if (pin_number >= 47) if (pin_number >= 47)
return; return;
cx25821_set_gpiopin_direction(dev, pin_number, 0); // change to output direction cx25821_set_gpiopin_direction(dev, pin_number, 0); // change to output direction
@ -86,11 +86,11 @@ static void cx25821_set_gpiopin_logicvalue( struct cx25821_dev *dev,
if (pin_logic_value == 0) if (pin_logic_value == 0)
{ {
value &= Clear_GPIO_Bit(bit); value &= Clear_GPIO_Bit(bit);
} }
else else
{ {
value |= Set_GPIO_Bit(bit); value |= Set_GPIO_Bit(bit);
} }
cx_write( gpio_reg, value); cx_write( gpio_reg, value);
@ -107,7 +107,7 @@ void cx25821_gpio_init(struct cx25821_dev *dev)
{ {
case CX25821_BOARD_CONEXANT_ATHENA10: case CX25821_BOARD_CONEXANT_ATHENA10:
default: default:
//set GPIO 5 to select the path for Medusa/Athena //set GPIO 5 to select the path for Medusa/Athena
cx25821_set_gpiopin_logicvalue(dev, 5, 1); cx25821_set_gpiopin_logicvalue(dev, 5, 1);
mdelay(20); mdelay(20);
break; break;

View File

@ -90,7 +90,7 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap, const struct i2c_msg *msg
/* Deal with i2c probe functions with zero payload */ /* Deal with i2c probe functions with zero payload */
if (msg->len == 0) if (msg->len == 0)
{ {
cx_write(bus->reg_addr, msg->addr << 25); cx_write(bus->reg_addr, msg->addr << 25);
cx_write(bus->reg_ctrl, bus->i2c_period | (1 << 2)); cx_write(bus->reg_ctrl, bus->i2c_period | (1 << 2));
if (!i2c_wait_done(i2c_adap)) if (!i2c_wait_done(i2c_adap))
@ -377,17 +377,17 @@ int cx25821_i2c_read(struct cx25821_i2c *bus, u16 reg_addr, int *value)
u8 buf[4] = {0,0,0,0}; u8 buf[4] = {0,0,0,0};
struct i2c_msg msgs[2]={ struct i2c_msg msgs[2]={
{ {
.addr = client->addr, .addr = client->addr,
.flags = 0, .flags = 0,
.len = 2, .len = 2,
.buf = addr, .buf = addr,
}, { }, {
.addr = client->addr, .addr = client->addr,
.flags = I2C_M_RD, .flags = I2C_M_RD,
.len = 4, .len = 4,
.buf = buf, .buf = buf,
} }
}; };
@ -412,12 +412,12 @@ int cx25821_i2c_write(struct cx25821_i2c *bus, u16 reg_addr, int value)
u8 buf[6] = {0, 0, 0, 0, 0, 0}; u8 buf[6] = {0, 0, 0, 0, 0, 0};
struct i2c_msg msgs[1]={ struct i2c_msg msgs[1]={
{ {
.addr = client->addr, .addr = client->addr,
.flags = 0, .flags = 0,
.len = 6, .len = 6,
.buf = buf, .buf = buf,
} }
}; };

View File

@ -41,49 +41,49 @@ static void medusa_enable_bluefield_output(struct cx25821_dev *dev, int channel,
switch (channel) switch (channel)
{ {
default: default:
case VDEC_A: case VDEC_A:
break; break;
case VDEC_B: case VDEC_B:
out_ctrl = VDEC_B_OUT_CTRL1; out_ctrl = VDEC_B_OUT_CTRL1;
out_ctrl_ns = VDEC_B_OUT_CTRL_NS; out_ctrl_ns = VDEC_B_OUT_CTRL_NS;
break; break;
case VDEC_C: case VDEC_C:
out_ctrl = VDEC_C_OUT_CTRL1; out_ctrl = VDEC_C_OUT_CTRL1;
out_ctrl_ns = VDEC_C_OUT_CTRL_NS; out_ctrl_ns = VDEC_C_OUT_CTRL_NS;
break; break;
case VDEC_D: case VDEC_D:
out_ctrl = VDEC_D_OUT_CTRL1; out_ctrl = VDEC_D_OUT_CTRL1;
out_ctrl_ns = VDEC_D_OUT_CTRL_NS; out_ctrl_ns = VDEC_D_OUT_CTRL_NS;
break; break;
case VDEC_E: case VDEC_E:
out_ctrl = VDEC_E_OUT_CTRL1; out_ctrl = VDEC_E_OUT_CTRL1;
out_ctrl_ns = VDEC_E_OUT_CTRL_NS; out_ctrl_ns = VDEC_E_OUT_CTRL_NS;
return; return;
case VDEC_F: case VDEC_F:
out_ctrl = VDEC_F_OUT_CTRL1; out_ctrl = VDEC_F_OUT_CTRL1;
out_ctrl_ns = VDEC_F_OUT_CTRL_NS; out_ctrl_ns = VDEC_F_OUT_CTRL_NS;
return; return;
case VDEC_G: case VDEC_G:
out_ctrl = VDEC_G_OUT_CTRL1; out_ctrl = VDEC_G_OUT_CTRL1;
out_ctrl_ns = VDEC_G_OUT_CTRL_NS; out_ctrl_ns = VDEC_G_OUT_CTRL_NS;
return; return;
case VDEC_H: case VDEC_H:
out_ctrl = VDEC_H_OUT_CTRL1; out_ctrl = VDEC_H_OUT_CTRL1;
out_ctrl_ns = VDEC_H_OUT_CTRL_NS; out_ctrl_ns = VDEC_H_OUT_CTRL_NS;
return; return;
} }
value = cx25821_i2c_read(&dev->i2c_bus[0], out_ctrl, &tmp); value = cx25821_i2c_read(&dev->i2c_bus[0], out_ctrl, &tmp);
value &= 0xFFFFFF7F; // clear BLUE_FIELD_EN value &= 0xFFFFFF7F; // clear BLUE_FIELD_EN
if (enable) if (enable)
value |= 0x00000080; // set BLUE_FIELD_EN value |= 0x00000080; // set BLUE_FIELD_EN
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], out_ctrl, value); ret_val = cx25821_i2c_write(&dev->i2c_bus[0], out_ctrl, value);
value = cx25821_i2c_read(&dev->i2c_bus[0], out_ctrl_ns, &tmp); value = cx25821_i2c_read(&dev->i2c_bus[0], out_ctrl_ns, &tmp);
value &= 0xFFFFFF7F; value &= 0xFFFFFF7F;
if (enable) if (enable)
value |= 0x00000080; // set BLUE_FIELD_EN value |= 0x00000080; // set BLUE_FIELD_EN
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], out_ctrl_ns, value); ret_val = cx25821_i2c_write(&dev->i2c_bus[0], out_ctrl_ns, value);
} }
@ -100,90 +100,90 @@ static int medusa_initialize_ntsc(struct cx25821_dev *dev)
for (i=0; i < MAX_DECODERS; i++) for (i=0; i < MAX_DECODERS; i++)
{ {
// set video format NTSC-M // set video format NTSC-M
value = cx25821_i2c_read(&dev->i2c_bus[0], MODE_CTRL+(0x200*i), &tmp); value = cx25821_i2c_read(&dev->i2c_bus[0], MODE_CTRL+(0x200*i), &tmp);
value &= 0xFFFFFFF0; value &= 0xFFFFFFF0;
value |= 0x10001; // enable the fast locking mode bit[16] value |= 0x10001; // enable the fast locking mode bit[16]
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], MODE_CTRL+(0x200*i), value); ret_val = cx25821_i2c_write(&dev->i2c_bus[0], MODE_CTRL+(0x200*i), value);
// resolution NTSC 720x480 // resolution NTSC 720x480
value = cx25821_i2c_read(&dev->i2c_bus[0], HORIZ_TIM_CTRL+(0x200*i), &tmp); value = cx25821_i2c_read(&dev->i2c_bus[0], HORIZ_TIM_CTRL+(0x200*i), &tmp);
value &= 0x00C00C00; value &= 0x00C00C00;
value |= 0x612D0074; value |= 0x612D0074;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], HORIZ_TIM_CTRL+(0x200*i), value); ret_val = cx25821_i2c_write(&dev->i2c_bus[0], HORIZ_TIM_CTRL+(0x200*i), value);
value = cx25821_i2c_read(&dev->i2c_bus[0], VERT_TIM_CTRL+(0x200*i), &tmp); value = cx25821_i2c_read(&dev->i2c_bus[0], VERT_TIM_CTRL+(0x200*i), &tmp);
value &= 0x00C00C00; value &= 0x00C00C00;
value |= 0x1C1E001A; // vblank_cnt + 2 to get camera ID value |= 0x1C1E001A; // vblank_cnt + 2 to get camera ID
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], VERT_TIM_CTRL+(0x200*i), value); ret_val = cx25821_i2c_write(&dev->i2c_bus[0], VERT_TIM_CTRL+(0x200*i), value);
// chroma subcarrier step size // chroma subcarrier step size
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], SC_STEP_SIZE+(0x200*i), 0x43E00000); ret_val = cx25821_i2c_write(&dev->i2c_bus[0], SC_STEP_SIZE+(0x200*i), 0x43E00000);
// enable VIP optional active // enable VIP optional active
value = cx25821_i2c_read(&dev->i2c_bus[0], OUT_CTRL_NS+(0x200*i), &tmp); value = cx25821_i2c_read(&dev->i2c_bus[0], OUT_CTRL_NS+(0x200*i), &tmp);
value &= 0xFFFBFFFF; value &= 0xFFFBFFFF;
value |= 0x00040000; value |= 0x00040000;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], OUT_CTRL_NS+(0x200*i), value); ret_val = cx25821_i2c_write(&dev->i2c_bus[0], OUT_CTRL_NS+(0x200*i), value);
// enable VIP optional active (VIP_OPT_AL) for direct output. // enable VIP optional active (VIP_OPT_AL) for direct output.
value = cx25821_i2c_read(&dev->i2c_bus[0], OUT_CTRL1+(0x200*i), &tmp); value = cx25821_i2c_read(&dev->i2c_bus[0], OUT_CTRL1+(0x200*i), &tmp);
value &= 0xFFFBFFFF; value &= 0xFFFBFFFF;
value |= 0x00040000; value |= 0x00040000;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], OUT_CTRL1+(0x200*i), value); ret_val = cx25821_i2c_write(&dev->i2c_bus[0], OUT_CTRL1+(0x200*i), value);
// clear VPRES_VERT_EN bit, fixes the chroma run away problem // clear VPRES_VERT_EN bit, fixes the chroma run away problem
// when the input switching rate < 16 fields // when the input switching rate < 16 fields
// //
value = cx25821_i2c_read(&dev->i2c_bus[0], MISC_TIM_CTRL+(0x200*i), &tmp); value = cx25821_i2c_read(&dev->i2c_bus[0], MISC_TIM_CTRL+(0x200*i), &tmp);
value = setBitAtPos(value, 14); // disable special play detection value = setBitAtPos(value, 14); // disable special play detection
value = clearBitAtPos(value, 15); value = clearBitAtPos(value, 15);
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], MISC_TIM_CTRL+(0x200*i), value); ret_val = cx25821_i2c_write(&dev->i2c_bus[0], MISC_TIM_CTRL+(0x200*i), value);
// set vbi_gate_en to 0 // set vbi_gate_en to 0
value = cx25821_i2c_read(&dev->i2c_bus[0], DFE_CTRL1+(0x200*i), &tmp); value = cx25821_i2c_read(&dev->i2c_bus[0], DFE_CTRL1+(0x200*i), &tmp);
value = clearBitAtPos(value, 29); value = clearBitAtPos(value, 29);
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DFE_CTRL1+(0x200*i), value); ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DFE_CTRL1+(0x200*i), value);
// Enable the generation of blue field output if no video // Enable the generation of blue field output if no video
medusa_enable_bluefield_output(dev, i, 1); medusa_enable_bluefield_output(dev, i, 1);
} }
for (i=0; i < MAX_ENCODERS; i++) for (i=0; i < MAX_ENCODERS; i++)
{ {
// NTSC hclock // NTSC hclock
value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_1+(0x100*i), &tmp); value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_1+(0x100*i), &tmp);
value &= 0xF000FC00; value &= 0xF000FC00;
value |= 0x06B402D0; value |= 0x06B402D0;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_1+(0x100*i), value); ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_1+(0x100*i), value);
// burst begin and burst end // burst begin and burst end
value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_2+(0x100*i), &tmp); value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_2+(0x100*i), &tmp);
value &= 0xFF000000; value &= 0xFF000000;
value |= 0x007E9054; value |= 0x007E9054;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_2+(0x100*i), value); ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_2+(0x100*i), value);
value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_3+(0x100*i), &tmp); value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_3+(0x100*i), &tmp);
value &= 0xFC00FE00; value &= 0xFC00FE00;
value |= 0x00EC00F0; value |= 0x00EC00F0;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_3+(0x100*i), value); ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_3+(0x100*i), value);
// set NTSC vblank, no phase alternation, 7.5 IRE pedestal // set NTSC vblank, no phase alternation, 7.5 IRE pedestal
value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_4+(0x100*i), &tmp); value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_4+(0x100*i), &tmp);
value &= 0x00FCFFFF; value &= 0x00FCFFFF;
value |= 0x13020000; value |= 0x13020000;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_4+(0x100*i), value); ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_4+(0x100*i), value);
value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_5+(0x100*i), &tmp); value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_5+(0x100*i), &tmp);
value &= 0xFFFF0000; value &= 0xFFFF0000;
value |= 0x0000E575; value |= 0x0000E575;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_5+(0x100*i), value); ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_5+(0x100*i), value);
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_6+(0x100*i), 0x009A89C1); ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_6+(0x100*i), 0x009A89C1);
// Subcarrier Increment // Subcarrier Increment
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_7+(0x100*i), 0x21F07C1F); ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_7+(0x100*i), 0x21F07C1F);
} }
@ -238,95 +238,95 @@ static int medusa_initialize_pal(struct cx25821_dev *dev)
for (i=0; i < MAX_DECODERS; i++) for (i=0; i < MAX_DECODERS; i++)
{ {
// set video format PAL-BDGHI // set video format PAL-BDGHI
value = cx25821_i2c_read(&dev->i2c_bus[0], MODE_CTRL+(0x200*i), &tmp); value = cx25821_i2c_read(&dev->i2c_bus[0], MODE_CTRL+(0x200*i), &tmp);
value &= 0xFFFFFFF0; value &= 0xFFFFFFF0;
value |= 0x10004; // enable the fast locking mode bit[16] value |= 0x10004; // enable the fast locking mode bit[16]
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], MODE_CTRL+(0x200*i), value); ret_val = cx25821_i2c_write(&dev->i2c_bus[0], MODE_CTRL+(0x200*i), value);
// resolution PAL 720x576 // resolution PAL 720x576
value = cx25821_i2c_read(&dev->i2c_bus[0], HORIZ_TIM_CTRL+(0x200*i), &tmp); value = cx25821_i2c_read(&dev->i2c_bus[0], HORIZ_TIM_CTRL+(0x200*i), &tmp);
value &= 0x00C00C00; value &= 0x00C00C00;
value |= 0x632D007D; value |= 0x632D007D;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], HORIZ_TIM_CTRL+(0x200*i), value); ret_val = cx25821_i2c_write(&dev->i2c_bus[0], HORIZ_TIM_CTRL+(0x200*i), value);
// vblank656_cnt=x26, vactive_cnt=240h, vblank_cnt=x24 // vblank656_cnt=x26, vactive_cnt=240h, vblank_cnt=x24
value = cx25821_i2c_read(&dev->i2c_bus[0], VERT_TIM_CTRL+(0x200*i), &tmp); value = cx25821_i2c_read(&dev->i2c_bus[0], VERT_TIM_CTRL+(0x200*i), &tmp);
value &= 0x00C00C00; value &= 0x00C00C00;
value |= 0x28240026; // vblank_cnt + 2 to get camera ID value |= 0x28240026; // vblank_cnt + 2 to get camera ID
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], VERT_TIM_CTRL+(0x200*i), value); ret_val = cx25821_i2c_write(&dev->i2c_bus[0], VERT_TIM_CTRL+(0x200*i), value);
// chroma subcarrier step size // chroma subcarrier step size
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], SC_STEP_SIZE+(0x200*i), 0x5411E2D0); ret_val = cx25821_i2c_write(&dev->i2c_bus[0], SC_STEP_SIZE+(0x200*i), 0x5411E2D0);
// enable VIP optional active // enable VIP optional active
value = cx25821_i2c_read(&dev->i2c_bus[0], OUT_CTRL_NS+(0x200*i), &tmp); value = cx25821_i2c_read(&dev->i2c_bus[0], OUT_CTRL_NS+(0x200*i), &tmp);
value &= 0xFFFBFFFF; value &= 0xFFFBFFFF;
value |= 0x00040000; value |= 0x00040000;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], OUT_CTRL_NS+(0x200*i), value); ret_val = cx25821_i2c_write(&dev->i2c_bus[0], OUT_CTRL_NS+(0x200*i), value);
// enable VIP optional active (VIP_OPT_AL) for direct output. // enable VIP optional active (VIP_OPT_AL) for direct output.
value = cx25821_i2c_read(&dev->i2c_bus[0], OUT_CTRL1+(0x200*i), &tmp); value = cx25821_i2c_read(&dev->i2c_bus[0], OUT_CTRL1+(0x200*i), &tmp);
value &= 0xFFFBFFFF; value &= 0xFFFBFFFF;
value |= 0x00040000; value |= 0x00040000;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], OUT_CTRL1+(0x200*i), value); ret_val = cx25821_i2c_write(&dev->i2c_bus[0], OUT_CTRL1+(0x200*i), value);
// clear VPRES_VERT_EN bit, fixes the chroma run away problem // clear VPRES_VERT_EN bit, fixes the chroma run away problem
// when the input switching rate < 16 fields // when the input switching rate < 16 fields
value = cx25821_i2c_read(&dev->i2c_bus[0], MISC_TIM_CTRL+(0x200*i), &tmp); value = cx25821_i2c_read(&dev->i2c_bus[0], MISC_TIM_CTRL+(0x200*i), &tmp);
value = setBitAtPos(value, 14); // disable special play detection value = setBitAtPos(value, 14); // disable special play detection
value = clearBitAtPos(value, 15); value = clearBitAtPos(value, 15);
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], MISC_TIM_CTRL+(0x200*i), value); ret_val = cx25821_i2c_write(&dev->i2c_bus[0], MISC_TIM_CTRL+(0x200*i), value);
// set vbi_gate_en to 0 // set vbi_gate_en to 0
value = cx25821_i2c_read(&dev->i2c_bus[0], DFE_CTRL1+(0x200*i), &tmp); value = cx25821_i2c_read(&dev->i2c_bus[0], DFE_CTRL1+(0x200*i), &tmp);
value = clearBitAtPos(value, 29); value = clearBitAtPos(value, 29);
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DFE_CTRL1+(0x200*i), value); ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DFE_CTRL1+(0x200*i), value);
medusa_PALCombInit(dev, i); medusa_PALCombInit(dev, i);
// Enable the generation of blue field output if no video // Enable the generation of blue field output if no video
medusa_enable_bluefield_output(dev, i, 1); medusa_enable_bluefield_output(dev, i, 1);
} }
for (i=0; i < MAX_ENCODERS; i++) for (i=0; i < MAX_ENCODERS; i++)
{ {
// PAL hclock // PAL hclock
value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_1+(0x100*i), &tmp); value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_1+(0x100*i), &tmp);
value &= 0xF000FC00; value &= 0xF000FC00;
value |= 0x06C002D0; value |= 0x06C002D0;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_1+(0x100*i), value); ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_1+(0x100*i), value);
// burst begin and burst end // burst begin and burst end
value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_2+(0x100*i), &tmp); value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_2+(0x100*i), &tmp);
value &= 0xFF000000; value &= 0xFF000000;
value |= 0x007E9754; value |= 0x007E9754;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_2+(0x100*i), value); ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_2+(0x100*i), value);
// hblank and vactive // hblank and vactive
value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_3+(0x100*i), &tmp); value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_3+(0x100*i), &tmp);
value &= 0xFC00FE00; value &= 0xFC00FE00;
value |= 0x00FC0120; value |= 0x00FC0120;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_3+(0x100*i), value); ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_3+(0x100*i), value);
// set PAL vblank, phase alternation, 0 IRE pedestal // set PAL vblank, phase alternation, 0 IRE pedestal
value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_4+(0x100*i), &tmp); value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_4+(0x100*i), &tmp);
value &= 0x00FCFFFF; value &= 0x00FCFFFF;
value |= 0x14010000; value |= 0x14010000;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_4+(0x100*i), value); ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_4+(0x100*i), value);
value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_5+(0x100*i), &tmp); value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_5+(0x100*i), &tmp);
value &= 0xFFFF0000; value &= 0xFFFF0000;
value |= 0x0000F078; value |= 0x0000F078;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_5+(0x100*i), value); ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_5+(0x100*i), value);
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_6+(0x100*i), 0x00A493CF); ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_6+(0x100*i), 0x00A493CF);
// Subcarrier Increment // Subcarrier Increment
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_7+(0x100*i), 0x2A098ACB); ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_7+(0x100*i), 0x2A098ACB);
} }
@ -353,11 +353,11 @@ int medusa_set_videostandard(struct cx25821_dev *dev)
if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK)
{ {
status = medusa_initialize_pal(dev); status = medusa_initialize_pal(dev);
} }
else else
{ {
status = medusa_initialize_ntsc(dev); status = medusa_initialize_ntsc(dev);
} }
// Enable DENC_A output // Enable DENC_A output
@ -388,55 +388,55 @@ void medusa_set_resolution(struct cx25821_dev *dev, int width, int decoder_selec
// validate the width - cannot be negative // validate the width - cannot be negative
if (width > MAX_WIDTH) if (width > MAX_WIDTH)
{ {
printk("cx25821 %s() : width %d > MAX_WIDTH %d ! resetting to MAX_WIDTH \n", __func__, width, MAX_WIDTH); printk("cx25821 %s() : width %d > MAX_WIDTH %d ! resetting to MAX_WIDTH \n", __func__, width, MAX_WIDTH);
width = MAX_WIDTH; width = MAX_WIDTH;
} }
if( decoder_select <= 7 && decoder_select >= 0 ) if( decoder_select <= 7 && decoder_select >= 0 )
{ {
decoder = decoder_select; decoder = decoder_select;
decoder_count = decoder_select + 1; decoder_count = decoder_select + 1;
} }
else else
{ {
decoder = 0; decoder = 0;
decoder_count = _num_decoders; decoder_count = _num_decoders;
} }
switch( width ) switch( width )
{ {
case 320: case 320:
hscale = 0x13E34B; hscale = 0x13E34B;
vscale = 0x0; vscale = 0x0;
break; break;
case 352: case 352:
hscale = 0x10A273; hscale = 0x10A273;
vscale = 0x0; vscale = 0x0;
break; break;
case 176: case 176:
hscale = 0x3115B2; hscale = 0x3115B2;
vscale = 0x1E00; vscale = 0x1E00;
break; break;
case 160: case 160:
hscale = 0x378D84; hscale = 0x378D84;
vscale = 0x1E00; vscale = 0x1E00;
break; break;
default: //720 default: //720
hscale = 0x0; hscale = 0x0;
vscale = 0x0; vscale = 0x0;
break; break;
} }
for( ; decoder < decoder_count; decoder++) for( ; decoder < decoder_count; decoder++)
{ {
// write scaling values for each decoder // write scaling values for each decoder
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], HSCALE_CTRL+(0x200*decoder), hscale); ret_val = cx25821_i2c_write(&dev->i2c_bus[0], HSCALE_CTRL+(0x200*decoder), hscale);
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], VSCALE_CTRL+(0x200*decoder), vscale); ret_val = cx25821_i2c_write(&dev->i2c_bus[0], VSCALE_CTRL+(0x200*decoder), vscale);
} }
mutex_unlock(&dev->lock); mutex_unlock(&dev->lock);
@ -454,26 +454,26 @@ static void medusa_set_decoderduration(struct cx25821_dev *dev, int decoder, int
// no support // no support
if (decoder < VDEC_A && decoder > VDEC_H) if (decoder < VDEC_A && decoder > VDEC_H)
{ {
mutex_unlock(&dev->lock); mutex_unlock(&dev->lock);
return; return;
} }
switch (decoder) switch (decoder)
{ {
default: default:
break; break;
case VDEC_C: case VDEC_C:
case VDEC_D: case VDEC_D:
disp_cnt_reg = DISP_CD_CNT; disp_cnt_reg = DISP_CD_CNT;
break; break;
case VDEC_E: case VDEC_E:
case VDEC_F: case VDEC_F:
disp_cnt_reg = DISP_EF_CNT; disp_cnt_reg = DISP_EF_CNT;
break; break;
case VDEC_G: case VDEC_G:
case VDEC_H: case VDEC_H:
disp_cnt_reg = DISP_GH_CNT; disp_cnt_reg = DISP_GH_CNT;
break; break;
} }
_display_field_cnt[decoder] = duration; _display_field_cnt[decoder] = duration;
@ -483,13 +483,13 @@ static void medusa_set_decoderduration(struct cx25821_dev *dev, int decoder, int
if (!(decoder % 2)) // EVEN decoder if (!(decoder % 2)) // EVEN decoder
{ {
fld_cnt &= 0xFFFF0000; fld_cnt &= 0xFFFF0000;
fld_cnt |= duration; fld_cnt |= duration;
} }
else else
{ {
fld_cnt &= 0x0000FFFF; fld_cnt &= 0x0000FFFF;
fld_cnt |= ((u32)duration) << 16; fld_cnt |= ((u32)duration) << 16;
} }
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], disp_cnt_reg, fld_cnt); ret_val = cx25821_i2c_write(&dev->i2c_bus[0], disp_cnt_reg, fld_cnt);
@ -514,7 +514,7 @@ static int mapM(
if((srcMin == srcMax) || (srcVal < srcMin) || (srcVal > srcMax)) if((srcMin == srcMax) || (srcVal < srcMin) || (srcVal > srcMax))
{ {
return -1; return -1;
} }
// This is the overall expression used: // This is the overall expression used:
@ -527,7 +527,7 @@ static int mapM(
if(2 * ( numerator % denominator ) >= denominator) if(2 * ( numerator % denominator ) >= denominator)
{ {
quotient++; quotient++;
} }
*dstVal = quotient + dstMin; *dstVal = quotient + dstMin;
@ -540,12 +540,12 @@ static unsigned long convert_to_twos(long numeric, unsigned long bits_len)
unsigned char temp; unsigned char temp;
if (numeric >= 0) if (numeric >= 0)
return numeric; return numeric;
else else
{ {
temp = ~(abs(numeric) & 0xFF); temp = ~(abs(numeric) & 0xFF);
temp += 1; temp += 1;
return temp; return temp;
} }
} }
///////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////
@ -558,8 +558,8 @@ int medusa_set_brightness(struct cx25821_dev *dev, int brightness, int decoder)
mutex_lock(&dev->lock); mutex_lock(&dev->lock);
if((brightness > VIDEO_PROCAMP_MAX) || (brightness < VIDEO_PROCAMP_MIN)) if((brightness > VIDEO_PROCAMP_MAX) || (brightness < VIDEO_PROCAMP_MIN))
{ {
mutex_unlock(&dev->lock); mutex_unlock(&dev->lock);
return -1; return -1;
} }
ret_val = mapM(VIDEO_PROCAMP_MIN, VIDEO_PROCAMP_MAX, brightness, SIGNED_BYTE_MIN, SIGNED_BYTE_MAX, &value); ret_val = mapM(VIDEO_PROCAMP_MIN, VIDEO_PROCAMP_MAX, brightness, SIGNED_BYTE_MIN, SIGNED_BYTE_MAX, &value);
value = convert_to_twos(value, 8); value = convert_to_twos(value, 8);
@ -581,8 +581,8 @@ int medusa_set_contrast(struct cx25821_dev *dev, int contrast, int decoder)
if((contrast > VIDEO_PROCAMP_MAX) || (contrast < VIDEO_PROCAMP_MIN)) if((contrast > VIDEO_PROCAMP_MAX) || (contrast < VIDEO_PROCAMP_MIN))
{ {
mutex_unlock(&dev->lock); mutex_unlock(&dev->lock);
return -1; return -1;
} }
ret_val = mapM(VIDEO_PROCAMP_MIN, VIDEO_PROCAMP_MAX, contrast, UNSIGNED_BYTE_MIN, UNSIGNED_BYTE_MAX, &value); ret_val = mapM(VIDEO_PROCAMP_MIN, VIDEO_PROCAMP_MAX, contrast, UNSIGNED_BYTE_MIN, UNSIGNED_BYTE_MAX, &value);
@ -605,8 +605,8 @@ int medusa_set_hue(struct cx25821_dev *dev, int hue, int decoder)
if((hue > VIDEO_PROCAMP_MAX) || (hue < VIDEO_PROCAMP_MIN)) if((hue > VIDEO_PROCAMP_MAX) || (hue < VIDEO_PROCAMP_MIN))
{ {
mutex_unlock(&dev->lock); mutex_unlock(&dev->lock);
return -1; return -1;
} }
ret_val = mapM(VIDEO_PROCAMP_MIN, VIDEO_PROCAMP_MAX, hue, SIGNED_BYTE_MIN, SIGNED_BYTE_MAX, &value); ret_val = mapM(VIDEO_PROCAMP_MIN, VIDEO_PROCAMP_MAX, hue, SIGNED_BYTE_MIN, SIGNED_BYTE_MAX, &value);
@ -633,8 +633,8 @@ int medusa_set_saturation(struct cx25821_dev *dev, int saturation, int decoder)
if((saturation > VIDEO_PROCAMP_MAX) || (saturation < VIDEO_PROCAMP_MIN)) if((saturation > VIDEO_PROCAMP_MAX) || (saturation < VIDEO_PROCAMP_MIN))
{ {
mutex_unlock(&dev->lock); mutex_unlock(&dev->lock);
return -1; return -1;
} }
ret_val = mapM(VIDEO_PROCAMP_MIN, VIDEO_PROCAMP_MAX, saturation, UNSIGNED_BYTE_MIN, UNSIGNED_BYTE_MAX, &value); ret_val = mapM(VIDEO_PROCAMP_MIN, VIDEO_PROCAMP_MAX, saturation, UNSIGNED_BYTE_MIN, UNSIGNED_BYTE_MAX, &value);
@ -673,8 +673,8 @@ int medusa_video_init(struct cx25821_dev *dev)
if (ret_val < 0) if (ret_val < 0)
{ {
mutex_unlock(&dev->lock); mutex_unlock(&dev->lock);
return -EINVAL; return -EINVAL;
} }
// Turn off Master source switch enable // Turn off Master source switch enable
@ -684,15 +684,15 @@ int medusa_video_init(struct cx25821_dev *dev)
if (ret_val < 0) if (ret_val < 0)
{ {
mutex_unlock(&dev->lock); mutex_unlock(&dev->lock);
return -EINVAL; return -EINVAL;
} }
mutex_unlock(&dev->lock); mutex_unlock(&dev->lock);
for (i=0; i < _num_decoders; i++) for (i=0; i < _num_decoders; i++)
{ {
medusa_set_decoderduration(dev, i, _display_field_cnt[i]); medusa_set_decoderduration(dev, i, _display_field_cnt[i]);
} }
mutex_lock(&dev->lock); mutex_lock(&dev->lock);
@ -705,8 +705,8 @@ int medusa_video_init(struct cx25821_dev *dev)
if (ret_val < 0) if (ret_val < 0)
{ {
mutex_unlock(&dev->lock); mutex_unlock(&dev->lock);
return -EINVAL; return -EINVAL;
} }
// enable input is VIP/656 // enable input is VIP/656
@ -716,8 +716,8 @@ int medusa_video_init(struct cx25821_dev *dev)
if (ret_val < 0) if (ret_val < 0)
{ {
mutex_unlock(&dev->lock); mutex_unlock(&dev->lock);
return -EINVAL; return -EINVAL;
} }
// select AFE clock to output mode // select AFE clock to output mode
@ -727,8 +727,8 @@ int medusa_video_init(struct cx25821_dev *dev)
if (ret_val < 0) if (ret_val < 0)
{ {
mutex_unlock(&dev->lock); mutex_unlock(&dev->lock);
return -EINVAL; return -EINVAL;
} }
// Turn on all of the data out and control output pins. // Turn on all of the data out and control output pins.
@ -736,21 +736,21 @@ int medusa_video_init(struct cx25821_dev *dev)
value &= 0xFEF0FE00; value &= 0xFEF0FE00;
if (_num_decoders == MAX_DECODERS) if (_num_decoders == MAX_DECODERS)
{ {
// Note: The octal board does not support control pins(bit16-19). // Note: The octal board does not support control pins(bit16-19).
// These bits are ignored in the octal board. // These bits are ignored in the octal board.
value |= 0x010001F8; // disable VDEC A-C port, default to Mobilygen Interface value |= 0x010001F8; // disable VDEC A-C port, default to Mobilygen Interface
} }
else else
{ {
value |= 0x010F0108; // disable VDEC A-C port, default to Mobilygen Interface value |= 0x010F0108; // disable VDEC A-C port, default to Mobilygen Interface
} }
value |= 7; value |= 7;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], PIN_OE_CTRL, value); ret_val = cx25821_i2c_write(&dev->i2c_bus[0], PIN_OE_CTRL, value);
if (ret_val < 0) if (ret_val < 0)
{ {
mutex_unlock(&dev->lock); mutex_unlock(&dev->lock);
return -EINVAL; return -EINVAL;
} }
mutex_unlock(&dev->lock); mutex_unlock(&dev->lock);
@ -761,8 +761,8 @@ int medusa_video_init(struct cx25821_dev *dev)
if (ret_val < 0) if (ret_val < 0)
{ {
mutex_unlock(&dev->lock); mutex_unlock(&dev->lock);
return -EINVAL; return -EINVAL;
} }
return 1; return 1;

View File

@ -1481,7 +1481,7 @@
//***************************************************************************** //*****************************************************************************
#define I2C1_ADDR 0x180000 // I2C #1 address #define I2C1_ADDR 0x180000 // I2C #1 address
#define FLD_I2C_DADDR 0xfe000000 // RW [31:25] I2C Device Address #define FLD_I2C_DADDR 0xfe000000 // RW [31:25] I2C Device Address
// RO [24] reserved // RO [24] reserved
//***************************************************************************** //*****************************************************************************
#define FLD_I2C_SADDR 0x00FFFFFF // RW [23:0] I2C Sub-address #define FLD_I2C_SADDR 0x00FFFFFF // RW [23:0] I2C Sub-address
@ -1494,15 +1494,15 @@
#define FLD_I2C_PERIOD 0xFF000000 // RW [31:24] #define FLD_I2C_PERIOD 0xFF000000 // RW [31:24]
#define FLD_I2C_SCL_IN 0x00200000 // RW [21] #define FLD_I2C_SCL_IN 0x00200000 // RW [21]
#define FLD_I2C_SDA_IN 0x00100000 // RW [20] #define FLD_I2C_SDA_IN 0x00100000 // RW [20]
// RO [19:18] reserved // RO [19:18] reserved
#define FLD_I2C_SCL_OUT 0x00020000 // RW [17] #define FLD_I2C_SCL_OUT 0x00020000 // RW [17]
#define FLD_I2C_SDA_OUT 0x00010000 // RW [16] #define FLD_I2C_SDA_OUT 0x00010000 // RW [16]
// RO [15] reserved // RO [15] reserved
#define FLD_I2C_DATA_LEN 0x00007000 // RW [14:12] #define FLD_I2C_DATA_LEN 0x00007000 // RW [14:12]
#define FLD_I2C_SADDR_INC 0x00000800 // RW [11] #define FLD_I2C_SADDR_INC 0x00000800 // RW [11]
// RO [10:9] reserved // RO [10:9] reserved
#define FLD_I2C_SADDR_LEN 0x00000300 // RW [9:8] #define FLD_I2C_SADDR_LEN 0x00000300 // RW [9:8]
// RO [7:6] reserved // RO [7:6] reserved
#define FLD_I2C_SOFT 0x00000020 // RW [5] #define FLD_I2C_SOFT 0x00000020 // RW [5]
#define FLD_I2C_NOSTOP 0x00000010 // RW [4] #define FLD_I2C_NOSTOP 0x00000010 // RW [4]
#define FLD_I2C_EXTEND 0x00000008 // RW [3] #define FLD_I2C_EXTEND 0x00000008 // RW [3]

View File

@ -44,8 +44,8 @@ static int _intr_msk = FLD_VID_SRC_RISC1 | FLD_VID_SRC_UF | FLD_VID_SRC_SYNC | F
static __le32 *cx25821_update_riscprogram_ch2( struct cx25821_dev *dev, static __le32 *cx25821_update_riscprogram_ch2( struct cx25821_dev *dev,
__le32 *rp, unsigned int offset, unsigned int bpl, __le32 *rp, unsigned int offset, unsigned int bpl,
u32 sync_line, unsigned int lines, int fifo_enable, int field_type) u32 sync_line, unsigned int lines, int fifo_enable, int field_type)
{ {
unsigned int line, i; unsigned int line, i;
int dist_betwn_starts = bpl * 2; int dist_betwn_starts = bpl * 2;
@ -56,33 +56,33 @@ static __le32 *cx25821_update_riscprogram_ch2( struct cx25821_dev *dev,
if( USE_RISC_NOOP_VIDEO ) if( USE_RISC_NOOP_VIDEO )
{ {
for( i = 0; i < NUM_NO_OPS; i++ ) for( i = 0; i < NUM_NO_OPS; i++ )
{ {
*(rp++) = cpu_to_le32(RISC_NOOP); *(rp++) = cpu_to_le32(RISC_NOOP);
} }
} }
/* scan lines */ /* scan lines */
for (line = 0; line < lines; line++) for (line = 0; line < lines; line++)
{ {
*(rp++) = cpu_to_le32(RISC_READ|RISC_SOL|RISC_EOL|bpl); *(rp++) = cpu_to_le32(RISC_READ|RISC_SOL|RISC_EOL|bpl);
*(rp++) = cpu_to_le32(dev->_data_buf_phys_addr_ch2+offset); *(rp++) = cpu_to_le32(dev->_data_buf_phys_addr_ch2+offset);
*(rp++) = cpu_to_le32(0); /* bits 63-32 */ *(rp++) = cpu_to_le32(0); /* bits 63-32 */
if ( (lines <= NTSC_FIELD_HEIGHT) || (line < (NTSC_FIELD_HEIGHT-1)) || !(dev->_isNTSC_ch2) ) if ( (lines <= NTSC_FIELD_HEIGHT) || (line < (NTSC_FIELD_HEIGHT-1)) || !(dev->_isNTSC_ch2) )
{ {
offset += dist_betwn_starts; offset += dist_betwn_starts;
} }
} }
return rp; return rp;
} }
static __le32 *cx25821_risc_field_upstream_ch2( struct cx25821_dev *dev, static __le32 *cx25821_risc_field_upstream_ch2( struct cx25821_dev *dev,
__le32 *rp, __le32 *rp,
dma_addr_t databuf_phys_addr, dma_addr_t databuf_phys_addr,
unsigned int offset, u32 sync_line, unsigned int bpl, unsigned int offset, u32 sync_line, unsigned int bpl,
unsigned int lines, int fifo_enable, int field_type) unsigned int lines, int fifo_enable, int field_type)
{ {
unsigned int line, i; unsigned int line, i;
struct sram_channel *sram_ch = &dev->sram_channels[dev->_channel2_upstream_select]; struct sram_channel *sram_ch = &dev->sram_channels[dev->_channel2_upstream_select];
@ -92,49 +92,49 @@ static __le32 *cx25821_risc_field_upstream_ch2( struct cx25821_dev *dev,
/* sync instruction */ /* sync instruction */
if (sync_line != NO_SYNC_LINE) if (sync_line != NO_SYNC_LINE)
{ {
*(rp++) = cpu_to_le32(RISC_RESYNC | sync_line); *(rp++) = cpu_to_le32(RISC_RESYNC | sync_line);
} }
if( USE_RISC_NOOP_VIDEO ) if( USE_RISC_NOOP_VIDEO )
{ {
for( i = 0; i < NUM_NO_OPS; i++ ) for( i = 0; i < NUM_NO_OPS; i++ )
{ {
*(rp++) = cpu_to_le32(RISC_NOOP); *(rp++) = cpu_to_le32(RISC_NOOP);
} }
} }
/* scan lines */ /* scan lines */
for (line = 0; line < lines; line++) for (line = 0; line < lines; line++)
{ {
*(rp++) = cpu_to_le32(RISC_READ|RISC_SOL|RISC_EOL|bpl); *(rp++) = cpu_to_le32(RISC_READ|RISC_SOL|RISC_EOL|bpl);
*(rp++) = cpu_to_le32(databuf_phys_addr+offset); *(rp++) = cpu_to_le32(databuf_phys_addr+offset);
*(rp++) = cpu_to_le32(0); /* bits 63-32 */ *(rp++) = cpu_to_le32(0); /* bits 63-32 */
if ( (lines <= NTSC_FIELD_HEIGHT) || (line < (NTSC_FIELD_HEIGHT-1)) || !(dev->_isNTSC_ch2) ) if ( (lines <= NTSC_FIELD_HEIGHT) || (line < (NTSC_FIELD_HEIGHT-1)) || !(dev->_isNTSC_ch2) )
{ {
offset += dist_betwn_starts; offset += dist_betwn_starts;
} }
// check if we need to enable the FIFO after the first 4 lines // check if we need to enable the FIFO after the first 4 lines
// For the upstream video channel, the risc engine will enable the FIFO. // For the upstream video channel, the risc engine will enable the FIFO.
if ( fifo_enable && line == 3 ) if ( fifo_enable && line == 3 )
{ {
*(rp++) = RISC_WRITECR; *(rp++) = RISC_WRITECR;
*(rp++) = sram_ch->dma_ctl; *(rp++) = sram_ch->dma_ctl;
*(rp++) = FLD_VID_FIFO_EN; *(rp++) = FLD_VID_FIFO_EN;
*(rp++) = 0x00000001; *(rp++) = 0x00000001;
} }
} }
return rp; return rp;
} }
int cx25821_risc_buffer_upstream_ch2( struct cx25821_dev *dev, struct pci_dev *pci, int cx25821_risc_buffer_upstream_ch2( struct cx25821_dev *dev, struct pci_dev *pci,
unsigned int top_offset, unsigned int top_offset,
unsigned int bpl, unsigned int lines) unsigned int bpl, unsigned int lines)
{ {
__le32 *rp; __le32 *rp;
int fifo_enable = 0; int fifo_enable = 0;
@ -151,14 +151,14 @@ int cx25821_risc_buffer_upstream_ch2( struct cx25821_dev *dev, struct pci_dev *p
if( dev->_isNTSC_ch2 ) if( dev->_isNTSC_ch2 )
{ {
odd_num_lines = singlefield_lines + 1; odd_num_lines = singlefield_lines + 1;
risc_program_size = FRAME1_VID_PROG_SIZE; risc_program_size = FRAME1_VID_PROG_SIZE;
frame_size = (bpl == Y411_LINE_SZ) ? FRAME_SIZE_NTSC_Y411 : FRAME_SIZE_NTSC_Y422; frame_size = (bpl == Y411_LINE_SZ) ? FRAME_SIZE_NTSC_Y411 : FRAME_SIZE_NTSC_Y422;
} }
else else
{ {
risc_program_size = PAL_VID_PROG_SIZE; risc_program_size = PAL_VID_PROG_SIZE;
frame_size = (bpl == Y411_LINE_SZ) ? FRAME_SIZE_PAL_Y411 : FRAME_SIZE_PAL_Y422; frame_size = (bpl == Y411_LINE_SZ) ? FRAME_SIZE_PAL_Y411 : FRAME_SIZE_PAL_Y422;
} }
@ -167,38 +167,38 @@ int cx25821_risc_buffer_upstream_ch2( struct cx25821_dev *dev, struct pci_dev *p
for( frame = 0; frame < NUM_FRAMES; frame++ ) for( frame = 0; frame < NUM_FRAMES; frame++ )
{ {
databuf_offset = frame_size * frame; databuf_offset = frame_size * frame;
if (UNSET != top_offset) if (UNSET != top_offset)
{ {
fifo_enable = (frame == 0) ? FIFO_ENABLE : FIFO_DISABLE; fifo_enable = (frame == 0) ? FIFO_ENABLE : FIFO_DISABLE;
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); 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);
} }
fifo_enable = FIFO_DISABLE; fifo_enable = FIFO_DISABLE;
//Even field //Even field
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); 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);
if( frame == 0 ) if( frame == 0 )
{ {
risc_flag = RISC_CNT_RESET; risc_flag = RISC_CNT_RESET;
risc_phys_jump_addr = dev->_dma_phys_start_addr_ch2 + risc_program_size; risc_phys_jump_addr = dev->_dma_phys_start_addr_ch2 + risc_program_size;
} }
else else
{ {
risc_flag = RISC_CNT_INC; risc_flag = RISC_CNT_INC;
risc_phys_jump_addr = dev->_dma_phys_start_addr_ch2; risc_phys_jump_addr = dev->_dma_phys_start_addr_ch2;
} }
// Loop to 2ndFrameRISC or to Start of Risc program & generate IRQ // Loop to 2ndFrameRISC or to Start of Risc program & generate IRQ
*(rp++) = cpu_to_le32(RISC_JUMP|RISC_IRQ1|risc_flag); *(rp++) = cpu_to_le32(RISC_JUMP|RISC_IRQ1|risc_flag);
*(rp++) = cpu_to_le32(risc_phys_jump_addr); *(rp++) = cpu_to_le32(risc_phys_jump_addr);
*(rp++) = cpu_to_le32(0); *(rp++) = cpu_to_le32(0);
} }
return 0; return 0;
@ -212,8 +212,8 @@ void cx25821_stop_upstream_video_ch2(struct cx25821_dev *dev)
if( !dev->_is_running_ch2 ) if( !dev->_is_running_ch2 )
{ {
printk("cx25821: No video file is currently running so return!\n"); printk("cx25821: No video file is currently running so return!\n");
return; return;
} }
//Disable RISC interrupts //Disable RISC interrupts
@ -226,7 +226,7 @@ void cx25821_stop_upstream_video_ch2(struct cx25821_dev *dev)
//Clear data buffer memory //Clear data buffer memory
if( dev->_data_buf_virt_addr_ch2 ) if( dev->_data_buf_virt_addr_ch2 )
memset( dev->_data_buf_virt_addr_ch2, 0, dev->_data_buf_size_ch2 ); memset( dev->_data_buf_virt_addr_ch2, 0, dev->_data_buf_size_ch2 );
dev->_is_running_ch2 = 0; dev->_is_running_ch2 = 0;
dev->_is_first_frame_ch2 = 0; dev->_is_first_frame_ch2 = 0;
@ -235,12 +235,12 @@ void cx25821_stop_upstream_video_ch2(struct cx25821_dev *dev)
if( dev->_irq_queues_ch2 ) if( dev->_irq_queues_ch2 )
{ {
kfree(dev->_irq_queues_ch2); kfree(dev->_irq_queues_ch2);
dev->_irq_queues_ch2 = NULL; dev->_irq_queues_ch2 = NULL;
} }
if( dev->_filename_ch2 != NULL ) if( dev->_filename_ch2 != NULL )
kfree(dev->_filename_ch2); kfree(dev->_filename_ch2);
tmp = cx_read( VID_CH_MODE_SEL ); tmp = cx_read( VID_CH_MODE_SEL );
cx_write( VID_CH_MODE_SEL, tmp & 0xFFFFFE00); cx_write( VID_CH_MODE_SEL, tmp & 0xFFFFFE00);
@ -250,19 +250,19 @@ void cx25821_free_mem_upstream_ch2(struct cx25821_dev *dev)
{ {
if( dev->_is_running_ch2 ) if( dev->_is_running_ch2 )
{ {
cx25821_stop_upstream_video_ch2(dev); cx25821_stop_upstream_video_ch2(dev);
} }
if (dev->_dma_virt_addr_ch2) if (dev->_dma_virt_addr_ch2)
{ {
pci_free_consistent(dev->pci, dev->_risc_size_ch2, dev->_dma_virt_addr_ch2, dev->_dma_phys_addr_ch2); pci_free_consistent(dev->pci, dev->_risc_size_ch2, dev->_dma_virt_addr_ch2, dev->_dma_phys_addr_ch2);
dev->_dma_virt_addr_ch2 = NULL; dev->_dma_virt_addr_ch2 = NULL;
} }
if (dev->_data_buf_virt_addr_ch2) if (dev->_data_buf_virt_addr_ch2)
{ {
pci_free_consistent(dev->pci, dev->_data_buf_size_ch2, dev->_data_buf_virt_addr_ch2, dev->_data_buf_phys_addr_ch2); pci_free_consistent(dev->pci, dev->_data_buf_size_ch2, dev->_data_buf_virt_addr_ch2, dev->_data_buf_phys_addr_ch2);
dev->_data_buf_virt_addr_ch2 = NULL; dev->_data_buf_virt_addr_ch2 = NULL;
} }
} }
@ -283,15 +283,15 @@ int cx25821_get_frame_ch2(struct cx25821_dev *dev, struct sram_channel *sram_ch
if( dev->_file_status_ch2 == END_OF_FILE ) if( dev->_file_status_ch2 == END_OF_FILE )
return 0; return 0;
if( dev->_isNTSC_ch2 ) if( dev->_isNTSC_ch2 )
{ {
frame_size = (line_size == Y411_LINE_SZ) ? FRAME_SIZE_NTSC_Y411 : FRAME_SIZE_NTSC_Y422; frame_size = (line_size == Y411_LINE_SZ) ? FRAME_SIZE_NTSC_Y411 : FRAME_SIZE_NTSC_Y422;
} }
else else
{ {
frame_size = (line_size == Y411_LINE_SZ) ? FRAME_SIZE_PAL_Y411 : FRAME_SIZE_PAL_Y422; frame_size = (line_size == Y411_LINE_SZ) ? FRAME_SIZE_PAL_Y411 : FRAME_SIZE_PAL_Y422;
} }
frame_offset = (frame_index_temp > 0) ? frame_size : 0; frame_offset = (frame_index_temp > 0) ? frame_size : 0;
@ -303,61 +303,61 @@ int cx25821_get_frame_ch2(struct cx25821_dev *dev, struct sram_channel *sram_ch
if (IS_ERR(myfile)) if (IS_ERR(myfile))
{ {
const int open_errno = -PTR_ERR(myfile); const int open_errno = -PTR_ERR(myfile);
printk("%s(): ERROR opening file(%s) with errno = %d! \n", __func__, dev->_filename_ch2, open_errno); printk("%s(): ERROR opening file(%s) with errno = %d! \n", __func__, dev->_filename_ch2, open_errno);
return PTR_ERR(myfile); return PTR_ERR(myfile);
} }
else else
{ {
if( !(myfile->f_op) ) if( !(myfile->f_op) )
{ {
printk("%s: File has no file operations registered!", __func__); printk("%s: File has no file operations registered!", __func__);
filp_close(myfile, NULL); filp_close(myfile, NULL);
return -EIO; return -EIO;
} }
if( !myfile->f_op->read ) if( !myfile->f_op->read )
{ {
printk("%s: File has no READ operations registered!", __func__); printk("%s: File has no READ operations registered!", __func__);
filp_close(myfile, NULL); filp_close(myfile, NULL);
return -EIO; return -EIO;
} }
pos = myfile->f_pos; pos = myfile->f_pos;
old_fs = get_fs(); old_fs = get_fs();
set_fs(KERNEL_DS); set_fs(KERNEL_DS);
for( i = 0; i < dev->_lines_count_ch2; i++ ) for( i = 0; i < dev->_lines_count_ch2; i++ )
{ {
pos = file_offset; pos = file_offset;
vfs_read_retval = vfs_read(myfile, mybuf, line_size, &pos); vfs_read_retval = vfs_read(myfile, mybuf, line_size, &pos);
if( vfs_read_retval > 0 && vfs_read_retval == line_size && dev->_data_buf_virt_addr_ch2 != NULL ) if( vfs_read_retval > 0 && vfs_read_retval == line_size && dev->_data_buf_virt_addr_ch2 != NULL )
{ {
memcpy( (void*)(dev->_data_buf_virt_addr_ch2+frame_offset/4), mybuf, vfs_read_retval); memcpy( (void*)(dev->_data_buf_virt_addr_ch2+frame_offset/4), mybuf, vfs_read_retval);
} }
file_offset += vfs_read_retval; file_offset += vfs_read_retval;
frame_offset += vfs_read_retval; frame_offset += vfs_read_retval;
if( vfs_read_retval < line_size ) if( vfs_read_retval < line_size )
{ {
printk(KERN_INFO "Done: exit %s() since no more bytes to read from Video file.\n", __func__ ); printk(KERN_INFO "Done: exit %s() since no more bytes to read from Video file.\n", __func__ );
break; break;
} }
} }
if( i > 0 ) if( i > 0 )
dev->_frame_count_ch2++; dev->_frame_count_ch2++;
dev->_file_status_ch2 = (vfs_read_retval == line_size) ? IN_PROGRESS : END_OF_FILE; dev->_file_status_ch2 = (vfs_read_retval == line_size) ? IN_PROGRESS : END_OF_FILE;
set_fs(old_fs); set_fs(old_fs);
filp_close(myfile, NULL); filp_close(myfile, NULL);
} }
return 0; return 0;
@ -369,8 +369,8 @@ static void cx25821_vidups_handler_ch2(struct work_struct *work)
if( !dev ) if( !dev )
{ {
printk("ERROR %s(): since container_of(work_struct) FAILED! \n", __func__ ); printk("ERROR %s(): since container_of(work_struct) FAILED! \n", __func__ );
return; return;
} }
cx25821_get_frame_ch2( dev, &dev->sram_channels[dev->_channel2_upstream_select] ); cx25821_get_frame_ch2( dev, &dev->sram_channels[dev->_channel2_upstream_select] );
@ -394,69 +394,69 @@ int cx25821_openfile_ch2(struct cx25821_dev *dev, struct sram_channel *sram_ch)
if (IS_ERR(myfile)) if (IS_ERR(myfile))
{ {
const int open_errno = -PTR_ERR(myfile); const int open_errno = -PTR_ERR(myfile);
printk("%s(): ERROR opening file(%s) with errno = %d! \n", __func__, dev->_filename_ch2, open_errno); printk("%s(): ERROR opening file(%s) with errno = %d! \n", __func__, dev->_filename_ch2, open_errno);
return PTR_ERR(myfile); return PTR_ERR(myfile);
} }
else else
{ {
if( !(myfile->f_op) ) if( !(myfile->f_op) )
{ {
printk("%s: File has no file operations registered!", __func__); printk("%s: File has no file operations registered!", __func__);
filp_close(myfile, NULL); filp_close(myfile, NULL);
return -EIO; return -EIO;
} }
if( !myfile->f_op->read ) if( !myfile->f_op->read )
{ {
printk("%s: File has no READ operations registered! Returning.", __func__); printk("%s: File has no READ operations registered! Returning.", __func__);
filp_close(myfile, NULL); filp_close(myfile, NULL);
return -EIO; return -EIO;
} }
pos = myfile->f_pos; pos = myfile->f_pos;
old_fs = get_fs(); old_fs = get_fs();
set_fs(KERNEL_DS); set_fs(KERNEL_DS);
for( j = 0; j < NUM_FRAMES; j++ ) for( j = 0; j < NUM_FRAMES; j++ )
{ {
for( i = 0; i < dev->_lines_count_ch2; i++ ) for( i = 0; i < dev->_lines_count_ch2; i++ )
{ {
pos = offset; pos = offset;
vfs_read_retval = vfs_read(myfile, mybuf, line_size, &pos); vfs_read_retval = vfs_read(myfile, mybuf, line_size, &pos);
if( vfs_read_retval > 0 && vfs_read_retval == line_size && dev->_data_buf_virt_addr_ch2 != NULL ) if( vfs_read_retval > 0 && vfs_read_retval == line_size && dev->_data_buf_virt_addr_ch2 != NULL )
{ {
memcpy( (void*)(dev->_data_buf_virt_addr_ch2+offset/4), mybuf, vfs_read_retval); memcpy( (void*)(dev->_data_buf_virt_addr_ch2+offset/4), mybuf, vfs_read_retval);
} }
offset += vfs_read_retval; offset += vfs_read_retval;
if( vfs_read_retval < line_size ) if( vfs_read_retval < line_size )
{ {
printk(KERN_INFO "Done: exit %s() since no more bytes to read from Video file.\n", __func__ ); printk(KERN_INFO "Done: exit %s() since no more bytes to read from Video file.\n", __func__ );
break; break;
} }
} }
if( i > 0 ) if( i > 0 )
dev->_frame_count_ch2++; dev->_frame_count_ch2++;
if( vfs_read_retval < line_size ) if( vfs_read_retval < line_size )
{ {
break; break;
} }
} }
dev->_file_status_ch2 = (vfs_read_retval == line_size) ? IN_PROGRESS : END_OF_FILE; dev->_file_status_ch2 = (vfs_read_retval == line_size) ? IN_PROGRESS : END_OF_FILE;
set_fs(old_fs); set_fs(old_fs);
myfile->f_pos = 0; myfile->f_pos = 0;
filp_close(myfile, NULL); filp_close(myfile, NULL);
} }
return 0; return 0;
@ -464,8 +464,8 @@ int cx25821_openfile_ch2(struct cx25821_dev *dev, struct sram_channel *sram_ch)
static int cx25821_upstream_buffer_prepare_ch2(struct cx25821_dev *dev, static int cx25821_upstream_buffer_prepare_ch2(struct cx25821_dev *dev,
struct sram_channel *sram_ch, struct sram_channel *sram_ch,
int bpl) int bpl)
{ {
int ret = 0; int ret = 0;
dma_addr_t dma_addr; dma_addr_t dma_addr;
@ -474,7 +474,7 @@ static int cx25821_upstream_buffer_prepare_ch2(struct cx25821_dev *dev,
if( dev->_dma_virt_addr_ch2 != NULL ) if( dev->_dma_virt_addr_ch2 != NULL )
{ {
pci_free_consistent(dev->pci, dev->upstream_riscbuf_size_ch2, dev->_dma_virt_addr_ch2, dev->_dma_phys_addr_ch2); pci_free_consistent(dev->pci, dev->upstream_riscbuf_size_ch2, dev->_dma_virt_addr_ch2, dev->_dma_phys_addr_ch2);
} }
dev->_dma_virt_addr_ch2 = pci_alloc_consistent(dev->pci, dev->upstream_riscbuf_size_ch2, &dma_addr); 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,
if (!dev->_dma_virt_addr_ch2) if (!dev->_dma_virt_addr_ch2)
{ {
printk("cx25821: FAILED to allocate memory for Risc buffer! Returning.\n"); printk("cx25821: FAILED to allocate memory for Risc buffer! Returning.\n");
return -ENOMEM; return -ENOMEM;
} }
@ -497,7 +497,7 @@ static int cx25821_upstream_buffer_prepare_ch2(struct cx25821_dev *dev,
if( dev->_data_buf_virt_addr_ch2 != NULL ) if( dev->_data_buf_virt_addr_ch2 != NULL )
{ {
pci_free_consistent(dev->pci, dev->upstream_databuf_size_ch2, dev->_data_buf_virt_addr_ch2, dev->_data_buf_phys_addr_ch2); pci_free_consistent(dev->pci, dev->upstream_databuf_size_ch2, dev->_data_buf_virt_addr_ch2, dev->_data_buf_phys_addr_ch2);
} }
//For Video Data buffer allocation //For Video Data buffer allocation
@ -507,8 +507,8 @@ static int cx25821_upstream_buffer_prepare_ch2(struct cx25821_dev *dev,
if (!dev->_data_buf_virt_addr_ch2) if (!dev->_data_buf_virt_addr_ch2)
{ {
printk("cx25821: FAILED to allocate memory for data buffer! Returning.\n"); printk("cx25821: FAILED to allocate memory for data buffer! Returning.\n");
return -ENOMEM; return -ENOMEM;
} }
@ -518,15 +518,15 @@ static int cx25821_upstream_buffer_prepare_ch2(struct cx25821_dev *dev,
ret = cx25821_openfile_ch2(dev, sram_ch); ret = cx25821_openfile_ch2(dev, sram_ch);
if( ret < 0 ) if( ret < 0 )
return ret; return ret;
//Creating RISC programs //Creating RISC programs
ret = cx25821_risc_buffer_upstream_ch2(dev, dev->pci, 0, bpl, dev->_lines_count_ch2 ); ret = cx25821_risc_buffer_upstream_ch2(dev, dev->pci, 0, bpl, dev->_lines_count_ch2 );
if (ret < 0) if (ret < 0)
{ {
printk(KERN_INFO "cx25821: Failed creating Video Upstream Risc programs! \n"); printk(KERN_INFO "cx25821: Failed creating Video Upstream Risc programs! \n");
goto error; goto error;
} }
return 0; return 0;
@ -549,59 +549,59 @@ int cx25821_video_upstream_irq_ch2(struct cx25821_dev *dev, int chan_num, u32 st
if (status & FLD_VID_SRC_RISC1) if (status & FLD_VID_SRC_RISC1)
{ {
// We should only process one program per call // We should only process one program per call
u32 prog_cnt = cx_read( channel->gpcnt ); u32 prog_cnt = cx_read( channel->gpcnt );
//Since we've identified our IRQ, clear our bits from the interrupt mask and interrupt status registers //Since we've identified our IRQ, clear our bits from the interrupt mask and interrupt status registers
int_msk_tmp = cx_read(channel->int_msk); int_msk_tmp = cx_read(channel->int_msk);
cx_write(channel->int_msk, int_msk_tmp & ~_intr_msk); cx_write(channel->int_msk, int_msk_tmp & ~_intr_msk);
cx_write( channel->int_stat, _intr_msk ); cx_write( channel->int_stat, _intr_msk );
spin_lock(&dev->slock); spin_lock(&dev->slock);
dev->_frame_index_ch2 = prog_cnt; dev->_frame_index_ch2 = prog_cnt;
queue_work(dev->_irq_queues_ch2, &dev->_irq_work_entry_ch2); queue_work(dev->_irq_queues_ch2, &dev->_irq_work_entry_ch2);
if ( dev->_is_first_frame_ch2 ) if ( dev->_is_first_frame_ch2 )
{ {
dev->_is_first_frame_ch2 = 0; dev->_is_first_frame_ch2 = 0;
if( dev->_isNTSC_ch2 ) if( dev->_isNTSC_ch2 )
{ {
singlefield_lines += 1; singlefield_lines += 1;
odd_risc_prog_size = ODD_FLD_NTSC_PROG_SIZE; odd_risc_prog_size = ODD_FLD_NTSC_PROG_SIZE;
} }
else else
{ {
singlefield_lines = PAL_FIELD_HEIGHT; singlefield_lines = PAL_FIELD_HEIGHT;
odd_risc_prog_size = ODD_FLD_PAL_PROG_SIZE; odd_risc_prog_size = ODD_FLD_PAL_PROG_SIZE;
} }
if( dev->_dma_virt_start_addr_ch2 != NULL ) if( dev->_dma_virt_start_addr_ch2 != NULL )
{ {
line_size_in_bytes = (dev->_pixel_format_ch2 == PIXEL_FRMT_411) ? Y411_LINE_SZ : Y422_LINE_SZ; line_size_in_bytes = (dev->_pixel_format_ch2 == PIXEL_FRMT_411) ? Y411_LINE_SZ : Y422_LINE_SZ;
risc_phys_jump_addr = dev->_dma_phys_start_addr_ch2 + odd_risc_prog_size; risc_phys_jump_addr = dev->_dma_phys_start_addr_ch2 + odd_risc_prog_size;
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); 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);
// Jump to Even Risc program of 1st Frame // Jump to Even Risc program of 1st Frame
*(rp++) = cpu_to_le32(RISC_JUMP); *(rp++) = cpu_to_le32(RISC_JUMP);
*(rp++) = cpu_to_le32(risc_phys_jump_addr); *(rp++) = cpu_to_le32(risc_phys_jump_addr);
*(rp++) = cpu_to_le32(0); *(rp++) = cpu_to_le32(0);
} }
} }
spin_unlock(&dev->slock); spin_unlock(&dev->slock);
} }
if( dev->_file_status_ch2 == END_OF_FILE ) if( dev->_file_status_ch2 == END_OF_FILE )
{ {
printk("cx25821: EOF Channel 2 Framecount = %d\n", dev->_frame_count_ch2 ); printk("cx25821: EOF Channel 2 Framecount = %d\n", dev->_frame_count_ch2 );
return -1; return -1;
} }
//ElSE, set the interrupt mask register, re-enable irq. //ElSE, set the interrupt mask register, re-enable irq.
@ -621,7 +621,7 @@ static irqreturn_t cx25821_upstream_irq_ch2(int irq, void *dev_id)
if( !dev ) if( !dev )
return -1; return -1;
channel_num = VID_UPSTREAM_SRAM_CHANNEL_J; channel_num = VID_UPSTREAM_SRAM_CHANNEL_J;
@ -633,17 +633,17 @@ static irqreturn_t cx25821_upstream_irq_ch2(int irq, void *dev_id)
// Only deal with our interrupt // Only deal with our interrupt
if(vid_status) if(vid_status)
{ {
handled = cx25821_video_upstream_irq_ch2(dev, channel_num, vid_status); handled = cx25821_video_upstream_irq_ch2(dev, channel_num, vid_status);
} }
if( handled < 0 ) if( handled < 0 )
{ {
cx25821_stop_upstream_video_ch2(dev); cx25821_stop_upstream_video_ch2(dev);
} }
else else
{ {
handled += handled; handled += handled;
} }
return IRQ_RETVAL(handled); return IRQ_RETVAL(handled);
@ -672,7 +672,7 @@ static void cx25821_set_pixelengine_ch2(struct cx25821_dev *dev, struct sram_cha
if(dev->_isNTSC_ch2) if(dev->_isNTSC_ch2)
{ {
odd_num_lines += 1; odd_num_lines += 1;
} }
value = (num_lines << 16) | odd_num_lines; value = (num_lines << 16) | odd_num_lines;
@ -685,7 +685,7 @@ static void cx25821_set_pixelengine_ch2(struct cx25821_dev *dev, struct sram_cha
int cx25821_start_video_dma_upstream_ch2(struct cx25821_dev *dev, int cx25821_start_video_dma_upstream_ch2(struct cx25821_dev *dev,
struct sram_channel *sram_ch) struct sram_channel *sram_ch)
{ {
u32 tmp = 0; u32 tmp = 0;
int err = 0; int err = 0;
@ -716,8 +716,8 @@ int cx25821_start_video_dma_upstream_ch2(struct cx25821_dev *dev,
err = request_irq(dev->pci->irq, cx25821_upstream_irq_ch2, IRQF_SHARED | IRQF_DISABLED, dev->name, dev); err = request_irq(dev->pci->irq, cx25821_upstream_irq_ch2, IRQF_SHARED | IRQF_DISABLED, dev->name, dev);
if (err < 0) if (err < 0)
{ {
printk(KERN_ERR "%s: can't get upstream IRQ %d\n", dev->name, dev->pci->irq); printk(KERN_ERR "%s: can't get upstream IRQ %d\n", dev->name, dev->pci->irq);
goto fail_irq; goto fail_irq;
} }
// Start the DMA engine // Start the DMA engine
@ -748,8 +748,8 @@ int cx25821_vidupstream_init_ch2(struct cx25821_dev *dev, int channel_select, in
if( dev->_is_running_ch2 ) if( dev->_is_running_ch2 )
{ {
printk("Video Channel is still running so return!\n"); printk("Video Channel is still running so return!\n");
return 0; return 0;
} }
dev->_channel2_upstream_select = channel_select; dev->_channel2_upstream_select = channel_select;
@ -761,8 +761,8 @@ int cx25821_vidupstream_init_ch2(struct cx25821_dev *dev, int channel_select, in
if(!dev->_irq_queues_ch2) if(!dev->_irq_queues_ch2)
{ {
printk("cx25821: create_singlethread_workqueue() for Video FAILED!\n"); printk("cx25821: create_singlethread_workqueue() for Video FAILED!\n");
return -ENOMEM; return -ENOMEM;
} }
// 656/VIP SRC Upstream Channel I & J and 7 - Host Bus Interface for channel A-C // 656/VIP SRC Upstream Channel I & J and 7 - Host Bus Interface for channel A-C
@ -782,37 +782,37 @@ int cx25821_vidupstream_init_ch2(struct cx25821_dev *dev, int channel_select, in
if( dev->input_filename_ch2 ) if( dev->input_filename_ch2 )
{ {
str_length = strlen(dev->input_filename_ch2); str_length = strlen(dev->input_filename_ch2);
dev->_filename_ch2 = (char *) kmalloc(str_length + 1, GFP_KERNEL); dev->_filename_ch2 = (char *) kmalloc(str_length + 1, GFP_KERNEL);
if( !dev->_filename_ch2 ) if( !dev->_filename_ch2 )
goto error; goto error;
memcpy(dev->_filename_ch2, dev->input_filename_ch2, str_length + 1); memcpy(dev->_filename_ch2, dev->input_filename_ch2, str_length + 1);
} }
else else
{ {
str_length = strlen(dev->_defaultname_ch2); str_length = strlen(dev->_defaultname_ch2);
dev->_filename_ch2 = (char *) kmalloc(str_length + 1, GFP_KERNEL); dev->_filename_ch2 = (char *) kmalloc(str_length + 1, GFP_KERNEL);
if( !dev->_filename_ch2 ) if( !dev->_filename_ch2 )
goto error; goto error;
memcpy(dev->_filename_ch2, dev->_defaultname_ch2, str_length + 1); memcpy(dev->_filename_ch2, dev->_defaultname_ch2, str_length + 1);
} }
//Default if filename is empty string //Default if filename is empty string
if( strcmp(dev->input_filename_ch2,"") == 0) if( strcmp(dev->input_filename_ch2,"") == 0)
{ {
if( dev->_isNTSC_ch2 ) if( dev->_isNTSC_ch2 )
{ {
dev->_filename_ch2 = (dev->_pixel_format_ch2 == PIXEL_FRMT_411) ? "/root/vid411.yuv" : "/root/vidtest.yuv"; dev->_filename_ch2 = (dev->_pixel_format_ch2 == PIXEL_FRMT_411) ? "/root/vid411.yuv" : "/root/vidtest.yuv";
} }
else else
{ {
dev->_filename_ch2 = (dev->_pixel_format_ch2 == PIXEL_FRMT_411) ? "/root/pal411.yuv" : "/root/pal422.yuv"; dev->_filename_ch2 = (dev->_pixel_format_ch2 == PIXEL_FRMT_411) ? "/root/pal411.yuv" : "/root/pal422.yuv";
} }
} }
@ -830,8 +830,8 @@ int cx25821_vidupstream_init_ch2(struct cx25821_dev *dev, int channel_select, in
retval = cx25821_upstream_buffer_prepare_ch2(dev, sram_ch, dev->_line_size_ch2); retval = cx25821_upstream_buffer_prepare_ch2(dev, sram_ch, dev->_line_size_ch2);
if (retval < 0) if (retval < 0)
{ {
printk(KERN_ERR "%s: Failed to set up Video upstream buffers!\n", dev->name); printk(KERN_ERR "%s: Failed to set up Video upstream buffers!\n", dev->name);
goto error; goto error;
} }

View File

@ -71,25 +71,25 @@
#ifdef USE_RISC_NOOP_VIDEO #ifdef USE_RISC_NOOP_VIDEO
#define PAL_US_VID_PROG_SIZE ((PAL_FIELD_HEIGHT) * 3 * DWORD_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + \ #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) RISC_SYNC_INSTRUCTION_SIZE + NUM_NO_OPS*DWORD_SIZE)
#define PAL_RISC_BUF_SIZE (2 * PAL_US_VID_PROG_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 + \ #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) 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 + \ #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) 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 + \ #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) JUMP_INSTRUCTION_SIZE + NUM_NO_OPS*DWORD_SIZE)
#define NTSC_RISC_BUF_SIZE (2 * (RISC_SYNC_INSTRUCTION_SIZE + NTSC_US_VID_PROG_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 + \ #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) 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 + \ #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) RISC_WRITECR_INSTRUCTION_SIZE + NUM_NO_OPS*DWORD_SIZE)
#endif #endif
@ -97,11 +97,11 @@
#define PAL_US_VID_PROG_SIZE ((PAL_FIELD_HEIGHT + 1) * 3 * DWORD_SIZE + RISC_WRITECR_INSTRUCTION_SIZE ) #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_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 + \ #define PAL_VID_PROG_SIZE ((PAL_FIELD_HEIGHT*2) * 3 * DWORD_SIZE + 2*RISC_SYNC_INSTRUCTION_SIZE + \
RISC_WRITECR_INSTRUCTION_SIZE + JUMP_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_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 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_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 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 + \ #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 ) RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE )
#endif #endif

View File

@ -43,19 +43,19 @@ MODULE_LICENSE("GPL");
static int _intr_msk = FLD_VID_SRC_RISC1 | FLD_VID_SRC_UF | FLD_VID_SRC_SYNC | FLD_VID_SRC_OPC_ERR; static int _intr_msk = FLD_VID_SRC_RISC1 | FLD_VID_SRC_UF | FLD_VID_SRC_SYNC | FLD_VID_SRC_OPC_ERR;
int cx25821_sram_channel_setup_upstream(struct cx25821_dev *dev, int cx25821_sram_channel_setup_upstream(struct cx25821_dev *dev,
struct sram_channel *ch, struct sram_channel *ch,
unsigned int bpl, u32 risc) unsigned int bpl, u32 risc)
{ {
unsigned int i, lines; unsigned int i, lines;
u32 cdt; u32 cdt;
if (ch->cmds_start == 0) { if (ch->cmds_start == 0) {
cx_write(ch->ptr1_reg, 0); cx_write(ch->ptr1_reg, 0);
cx_write(ch->ptr2_reg, 0); cx_write(ch->ptr2_reg, 0);
cx_write(ch->cnt2_reg, 0); cx_write(ch->cnt2_reg, 0);
cx_write(ch->cnt1_reg, 0); cx_write(ch->cnt1_reg, 0);
return 0; return 0;
} }
bpl = (bpl + 7) & ~7; /* alignment */ bpl = (bpl + 7) & ~7; /* alignment */
@ -64,7 +64,7 @@ int cx25821_sram_channel_setup_upstream(struct cx25821_dev *dev,
if (lines > 4) if (lines > 4)
{ {
lines = 4; lines = 4;
} }
BUG_ON(lines < 2); BUG_ON(lines < 2);
@ -72,10 +72,10 @@ int cx25821_sram_channel_setup_upstream(struct cx25821_dev *dev,
/* write CDT */ /* write CDT */
for (i = 0; i < lines; i++) { for (i = 0; i < lines; i++) {
cx_write(cdt + 16*i, ch->fifo_start + bpl*i); cx_write(cdt + 16*i, ch->fifo_start + bpl*i);
cx_write(cdt + 16*i + 4, 0); cx_write(cdt + 16*i + 4, 0);
cx_write(cdt + 16*i + 8, 0); cx_write(cdt + 16*i + 8, 0);
cx_write(cdt + 16*i + 12, 0); cx_write(cdt + 16*i + 12, 0);
} }
/* write CMDS */ /* write CMDS */
@ -90,7 +90,7 @@ int cx25821_sram_channel_setup_upstream(struct cx25821_dev *dev,
cx_write(ch->cmds_start + 20, VID_IQ_SIZE_DW); cx_write(ch->cmds_start + 20, VID_IQ_SIZE_DW);
for (i = 24; i < 80; i += 4) for (i = 24; i < 80; i += 4)
cx_write(ch->cmds_start + i, 0); cx_write(ch->cmds_start + i, 0);
/* fill registers */ /* fill registers */
cx_write(ch->ptr1_reg, ch->fifo_start); cx_write(ch->ptr1_reg, ch->fifo_start);
@ -102,8 +102,8 @@ int cx25821_sram_channel_setup_upstream(struct cx25821_dev *dev,
} }
static __le32 *cx25821_update_riscprogram( struct cx25821_dev *dev, static __le32 *cx25821_update_riscprogram( struct cx25821_dev *dev,
__le32 *rp, unsigned int offset, unsigned int bpl, __le32 *rp, unsigned int offset, unsigned int bpl,
u32 sync_line, unsigned int lines, int fifo_enable, int field_type) u32 sync_line, unsigned int lines, int fifo_enable, int field_type)
{ {
unsigned int line, i; unsigned int line, i;
int dist_betwn_starts = bpl * 2; int dist_betwn_starts = bpl * 2;
@ -114,32 +114,32 @@ static __le32 *cx25821_update_riscprogram( struct cx25821_dev *dev,
if( USE_RISC_NOOP_VIDEO ) if( USE_RISC_NOOP_VIDEO )
{ {
for( i = 0; i < NUM_NO_OPS; i++ ) for( i = 0; i < NUM_NO_OPS; i++ )
{ {
*(rp++) = cpu_to_le32(RISC_NOOP); *(rp++) = cpu_to_le32(RISC_NOOP);
} }
} }
/* scan lines */ /* scan lines */
for (line = 0; line < lines; line++) for (line = 0; line < lines; line++)
{ {
*(rp++) = cpu_to_le32(RISC_READ|RISC_SOL|RISC_EOL|bpl); *(rp++) = cpu_to_le32(RISC_READ|RISC_SOL|RISC_EOL|bpl);
*(rp++) = cpu_to_le32(dev->_data_buf_phys_addr+offset); *(rp++) = cpu_to_le32(dev->_data_buf_phys_addr+offset);
*(rp++) = cpu_to_le32(0); /* bits 63-32 */ *(rp++) = cpu_to_le32(0); /* bits 63-32 */
if ( (lines <= NTSC_FIELD_HEIGHT) || (line < (NTSC_FIELD_HEIGHT-1)) || !(dev->_isNTSC) ) if ( (lines <= NTSC_FIELD_HEIGHT) || (line < (NTSC_FIELD_HEIGHT-1)) || !(dev->_isNTSC) )
{ {
offset += dist_betwn_starts; offset += dist_betwn_starts;
} }
} }
return rp; return rp;
} }
static __le32 *cx25821_risc_field_upstream( struct cx25821_dev *dev, __le32 *rp, static __le32 *cx25821_risc_field_upstream( struct cx25821_dev *dev, __le32 *rp,
dma_addr_t databuf_phys_addr, dma_addr_t databuf_phys_addr,
unsigned int offset, u32 sync_line, unsigned int offset, u32 sync_line,
unsigned int bpl, unsigned int lines, int fifo_enable, int field_type) unsigned int bpl, unsigned int lines, int fifo_enable, int field_type)
{ {
unsigned int line, i; unsigned int line, i;
struct sram_channel *sram_ch = &dev->sram_channels[dev->_channel_upstream_select]; struct sram_channel *sram_ch = &dev->sram_channels[dev->_channel_upstream_select];
@ -149,50 +149,50 @@ static __le32 *cx25821_risc_field_upstream( struct cx25821_dev *dev, __le32 *rp,
/* sync instruction */ /* sync instruction */
if (sync_line != NO_SYNC_LINE) if (sync_line != NO_SYNC_LINE)
{ {
*(rp++) = cpu_to_le32(RISC_RESYNC | sync_line); *(rp++) = cpu_to_le32(RISC_RESYNC | sync_line);
} }
if( USE_RISC_NOOP_VIDEO ) if( USE_RISC_NOOP_VIDEO )
{ {
for( i = 0; i < NUM_NO_OPS; i++ ) for( i = 0; i < NUM_NO_OPS; i++ )
{ {
*(rp++) = cpu_to_le32(RISC_NOOP); *(rp++) = cpu_to_le32(RISC_NOOP);
} }
} }
/* scan lines */ /* scan lines */
for (line = 0; line < lines; line++) for (line = 0; line < lines; line++)
{ {
*(rp++) = cpu_to_le32(RISC_READ|RISC_SOL|RISC_EOL|bpl); *(rp++) = cpu_to_le32(RISC_READ|RISC_SOL|RISC_EOL|bpl);
*(rp++) = cpu_to_le32(databuf_phys_addr+offset); *(rp++) = cpu_to_le32(databuf_phys_addr+offset);
*(rp++) = cpu_to_le32(0); /* bits 63-32 */ *(rp++) = cpu_to_le32(0); /* bits 63-32 */
if ( (lines <= NTSC_FIELD_HEIGHT) || (line < (NTSC_FIELD_HEIGHT-1)) || !(dev->_isNTSC) ) if ( (lines <= NTSC_FIELD_HEIGHT) || (line < (NTSC_FIELD_HEIGHT-1)) || !(dev->_isNTSC) )
{ {
offset += dist_betwn_starts; //to skip the other field line offset += dist_betwn_starts; //to skip the other field line
} }
// check if we need to enable the FIFO after the first 4 lines // check if we need to enable the FIFO after the first 4 lines
// For the upstream video channel, the risc engine will enable the FIFO. // For the upstream video channel, the risc engine will enable the FIFO.
if ( fifo_enable && line == 3 ) if ( fifo_enable && line == 3 )
{ {
*(rp++) = RISC_WRITECR; *(rp++) = RISC_WRITECR;
*(rp++) = sram_ch->dma_ctl; *(rp++) = sram_ch->dma_ctl;
*(rp++) = FLD_VID_FIFO_EN; *(rp++) = FLD_VID_FIFO_EN;
*(rp++) = 0x00000001; *(rp++) = 0x00000001;
} }
} }
return rp; return rp;
} }
int cx25821_risc_buffer_upstream( struct cx25821_dev *dev, int cx25821_risc_buffer_upstream( struct cx25821_dev *dev,
struct pci_dev *pci, struct pci_dev *pci,
unsigned int top_offset, unsigned int top_offset,
unsigned int bpl, unsigned int lines) unsigned int bpl, unsigned int lines)
{ {
__le32 *rp; __le32 *rp;
int fifo_enable = 0; int fifo_enable = 0;
@ -208,14 +208,14 @@ int cx25821_risc_buffer_upstream( struct cx25821_dev *dev,
if( dev->_isNTSC ) if( dev->_isNTSC )
{ {
odd_num_lines = singlefield_lines + 1; odd_num_lines = singlefield_lines + 1;
risc_program_size = FRAME1_VID_PROG_SIZE; risc_program_size = FRAME1_VID_PROG_SIZE;
frame_size = (bpl == Y411_LINE_SZ) ? FRAME_SIZE_NTSC_Y411 : FRAME_SIZE_NTSC_Y422; frame_size = (bpl == Y411_LINE_SZ) ? FRAME_SIZE_NTSC_Y411 : FRAME_SIZE_NTSC_Y422;
} }
else else
{ {
risc_program_size = PAL_VID_PROG_SIZE; risc_program_size = PAL_VID_PROG_SIZE;
frame_size = (bpl == Y411_LINE_SZ) ? FRAME_SIZE_PAL_Y411 : FRAME_SIZE_PAL_Y422; frame_size = (bpl == Y411_LINE_SZ) ? FRAME_SIZE_PAL_Y411 : FRAME_SIZE_PAL_Y422;
} }
@ -224,38 +224,38 @@ int cx25821_risc_buffer_upstream( struct cx25821_dev *dev,
for( frame = 0; frame < NUM_FRAMES; frame++ ) for( frame = 0; frame < NUM_FRAMES; frame++ )
{ {
databuf_offset = frame_size * frame; databuf_offset = frame_size * frame;
if (UNSET != top_offset) if (UNSET != top_offset)
{ {
fifo_enable = (frame == 0) ? FIFO_ENABLE : FIFO_DISABLE; fifo_enable = (frame == 0) ? FIFO_ENABLE : FIFO_DISABLE;
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); 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);
} }
fifo_enable = FIFO_DISABLE; fifo_enable = FIFO_DISABLE;
//Even Field //Even Field
rp = cx25821_risc_field_upstream(dev, rp, dev->_data_buf_phys_addr+databuf_offset, bottom_offset, 0x200, bpl, singlefield_lines, fifo_enable, EVEN_FIELD); rp = cx25821_risc_field_upstream(dev, rp, dev->_data_buf_phys_addr+databuf_offset, bottom_offset, 0x200, bpl, singlefield_lines, fifo_enable, EVEN_FIELD);
if( frame == 0 ) if( frame == 0 )
{ {
risc_flag = RISC_CNT_RESET; risc_flag = RISC_CNT_RESET;
risc_phys_jump_addr = dev->_dma_phys_start_addr + risc_program_size; risc_phys_jump_addr = dev->_dma_phys_start_addr + risc_program_size;
} }
else else
{ {
risc_phys_jump_addr = dev->_dma_phys_start_addr; risc_phys_jump_addr = dev->_dma_phys_start_addr;
risc_flag = RISC_CNT_INC; risc_flag = RISC_CNT_INC;
} }
// Loop to 2ndFrameRISC or to Start of Risc program & generate IRQ // Loop to 2ndFrameRISC or to Start of Risc program & generate IRQ
*(rp++) = cpu_to_le32(RISC_JUMP|RISC_IRQ1|risc_flag); *(rp++) = cpu_to_le32(RISC_JUMP|RISC_IRQ1|risc_flag);
*(rp++) = cpu_to_le32(risc_phys_jump_addr); *(rp++) = cpu_to_le32(risc_phys_jump_addr);
*(rp++) = cpu_to_le32(0); *(rp++) = cpu_to_le32(0);
} }
return 0; return 0;
@ -269,8 +269,8 @@ void cx25821_stop_upstream_video_ch1(struct cx25821_dev *dev)
if( !dev->_is_running ) if( !dev->_is_running )
{ {
printk("cx25821: No video file is currently running so return!\n"); printk("cx25821: No video file is currently running so return!\n");
return; return;
} }
//Disable RISC interrupts //Disable RISC interrupts
@ -283,7 +283,7 @@ void cx25821_stop_upstream_video_ch1(struct cx25821_dev *dev)
//Clear data buffer memory //Clear data buffer memory
if( dev->_data_buf_virt_addr ) if( dev->_data_buf_virt_addr )
memset( dev->_data_buf_virt_addr, 0, dev->_data_buf_size ); memset( dev->_data_buf_virt_addr, 0, dev->_data_buf_size );
dev->_is_running = 0; dev->_is_running = 0;
dev->_is_first_frame = 0; dev->_is_first_frame = 0;
@ -292,12 +292,12 @@ void cx25821_stop_upstream_video_ch1(struct cx25821_dev *dev)
if( dev->_irq_queues ) if( dev->_irq_queues )
{ {
kfree(dev->_irq_queues); kfree(dev->_irq_queues);
dev->_irq_queues = NULL; dev->_irq_queues = NULL;
} }
if( dev->_filename != NULL ) if( dev->_filename != NULL )
kfree(dev->_filename); kfree(dev->_filename);
tmp = cx_read( VID_CH_MODE_SEL ); tmp = cx_read( VID_CH_MODE_SEL );
cx_write( VID_CH_MODE_SEL, tmp & 0xFFFFFE00); cx_write( VID_CH_MODE_SEL, tmp & 0xFFFFFE00);
@ -307,19 +307,19 @@ void cx25821_free_mem_upstream_ch1(struct cx25821_dev *dev)
{ {
if( dev->_is_running ) if( dev->_is_running )
{ {
cx25821_stop_upstream_video_ch1(dev); cx25821_stop_upstream_video_ch1(dev);
} }
if (dev->_dma_virt_addr) if (dev->_dma_virt_addr)
{ {
pci_free_consistent(dev->pci, dev->_risc_size, dev->_dma_virt_addr, dev->_dma_phys_addr); pci_free_consistent(dev->pci, dev->_risc_size, dev->_dma_virt_addr, dev->_dma_phys_addr);
dev->_dma_virt_addr = NULL; dev->_dma_virt_addr = NULL;
} }
if (dev->_data_buf_virt_addr) if (dev->_data_buf_virt_addr)
{ {
pci_free_consistent(dev->pci, dev->_data_buf_size, dev->_data_buf_virt_addr, dev->_data_buf_phys_addr); pci_free_consistent(dev->pci, dev->_data_buf_size, dev->_data_buf_virt_addr, dev->_data_buf_phys_addr);
dev->_data_buf_virt_addr = NULL; dev->_data_buf_virt_addr = NULL;
} }
} }
@ -340,15 +340,15 @@ int cx25821_get_frame(struct cx25821_dev *dev, struct sram_channel *sram_ch )
if( dev->_file_status == END_OF_FILE ) if( dev->_file_status == END_OF_FILE )
return 0; return 0;
if( dev->_isNTSC ) if( dev->_isNTSC )
{ {
frame_size = (line_size == Y411_LINE_SZ) ? FRAME_SIZE_NTSC_Y411 : FRAME_SIZE_NTSC_Y422; frame_size = (line_size == Y411_LINE_SZ) ? FRAME_SIZE_NTSC_Y411 : FRAME_SIZE_NTSC_Y422;
} }
else else
{ {
frame_size = (line_size == Y411_LINE_SZ) ? FRAME_SIZE_PAL_Y411 : FRAME_SIZE_PAL_Y422; frame_size = (line_size == Y411_LINE_SZ) ? FRAME_SIZE_PAL_Y411 : FRAME_SIZE_PAL_Y422;
} }
frame_offset = (frame_index_temp > 0) ? frame_size : 0; frame_offset = (frame_index_temp > 0) ? frame_size : 0;
@ -360,61 +360,61 @@ int cx25821_get_frame(struct cx25821_dev *dev, struct sram_channel *sram_ch )
if (IS_ERR(myfile)) if (IS_ERR(myfile))
{ {
const int open_errno = -PTR_ERR(myfile); const int open_errno = -PTR_ERR(myfile);
printk("%s(): ERROR opening file(%s) with errno = %d! \n", __func__, dev->_filename, open_errno); printk("%s(): ERROR opening file(%s) with errno = %d! \n", __func__, dev->_filename, open_errno);
return PTR_ERR(myfile); return PTR_ERR(myfile);
} }
else else
{ {
if( !(myfile->f_op) ) if( !(myfile->f_op) )
{ {
printk("%s: File has no file operations registered!", __func__); printk("%s: File has no file operations registered!", __func__);
filp_close(myfile, NULL); filp_close(myfile, NULL);
return -EIO; return -EIO;
} }
if( !myfile->f_op->read ) if( !myfile->f_op->read )
{ {
printk("%s: File has no READ operations registered!", __func__); printk("%s: File has no READ operations registered!", __func__);
filp_close(myfile, NULL); filp_close(myfile, NULL);
return -EIO; return -EIO;
} }
pos = myfile->f_pos; pos = myfile->f_pos;
old_fs = get_fs(); old_fs = get_fs();
set_fs(KERNEL_DS); set_fs(KERNEL_DS);
for( i = 0; i < dev->_lines_count; i++ ) for( i = 0; i < dev->_lines_count; i++ )
{ {
pos = file_offset; pos = file_offset;
vfs_read_retval = vfs_read(myfile, mybuf, line_size, &pos); vfs_read_retval = vfs_read(myfile, mybuf, line_size, &pos);
if( vfs_read_retval > 0 && vfs_read_retval == line_size && dev->_data_buf_virt_addr != NULL ) if( vfs_read_retval > 0 && vfs_read_retval == line_size && dev->_data_buf_virt_addr != NULL )
{ {
memcpy( (void*)(dev->_data_buf_virt_addr+frame_offset/4), mybuf, vfs_read_retval); memcpy( (void*)(dev->_data_buf_virt_addr+frame_offset/4), mybuf, vfs_read_retval);
} }
file_offset += vfs_read_retval; file_offset += vfs_read_retval;
frame_offset += vfs_read_retval; frame_offset += vfs_read_retval;
if( vfs_read_retval < line_size ) if( vfs_read_retval < line_size )
{ {
printk(KERN_INFO "Done: exit %s() since no more bytes to read from Video file.\n", __func__ ); printk(KERN_INFO "Done: exit %s() since no more bytes to read from Video file.\n", __func__ );
break; break;
} }
} }
if( i > 0 ) if( i > 0 )
dev->_frame_count++; dev->_frame_count++;
dev->_file_status = (vfs_read_retval == line_size) ? IN_PROGRESS : END_OF_FILE; dev->_file_status = (vfs_read_retval == line_size) ? IN_PROGRESS : END_OF_FILE;
set_fs(old_fs); set_fs(old_fs);
filp_close(myfile, NULL); filp_close(myfile, NULL);
} }
return 0; return 0;
@ -426,8 +426,8 @@ static void cx25821_vidups_handler(struct work_struct *work)
if( !dev ) if( !dev )
{ {
printk("ERROR %s(): since container_of(work_struct) FAILED! \n", __func__ ); printk("ERROR %s(): since container_of(work_struct) FAILED! \n", __func__ );
return; return;
} }
cx25821_get_frame( dev, &dev->sram_channels[dev->_channel_upstream_select] ); cx25821_get_frame( dev, &dev->sram_channels[dev->_channel_upstream_select] );
@ -451,70 +451,70 @@ int cx25821_openfile(struct cx25821_dev *dev, struct sram_channel *sram_ch)
if (IS_ERR(myfile)) if (IS_ERR(myfile))
{ {
const int open_errno = -PTR_ERR(myfile); const int open_errno = -PTR_ERR(myfile);
printk("%s(): ERROR opening file(%s) with errno = %d! \n", __func__, dev->_filename, open_errno); printk("%s(): ERROR opening file(%s) with errno = %d! \n", __func__, dev->_filename, open_errno);
return PTR_ERR(myfile); return PTR_ERR(myfile);
} }
else else
{ {
if( !(myfile->f_op) ) if( !(myfile->f_op) )
{ {
printk("%s: File has no file operations registered!", __func__); printk("%s: File has no file operations registered!", __func__);
filp_close(myfile, NULL); filp_close(myfile, NULL);
return -EIO; return -EIO;
} }
if( !myfile->f_op->read ) if( !myfile->f_op->read )
{ {
printk("%s: File has no READ operations registered! Returning.", __func__); printk("%s: File has no READ operations registered! Returning.", __func__);
filp_close(myfile, NULL); filp_close(myfile, NULL);
return -EIO; return -EIO;
} }
pos = myfile->f_pos; pos = myfile->f_pos;
old_fs = get_fs(); old_fs = get_fs();
set_fs(KERNEL_DS); set_fs(KERNEL_DS);
for( j = 0; j < NUM_FRAMES; j++ ) for( j = 0; j < NUM_FRAMES; j++ )
{ {
for( i = 0; i < dev->_lines_count; i++ ) for( i = 0; i < dev->_lines_count; i++ )
{ {
pos = offset; pos = offset;
vfs_read_retval = vfs_read(myfile, mybuf, line_size, &pos); vfs_read_retval = vfs_read(myfile, mybuf, line_size, &pos);
if( vfs_read_retval > 0 && vfs_read_retval == line_size && dev->_data_buf_virt_addr != NULL ) if( vfs_read_retval > 0 && vfs_read_retval == line_size && dev->_data_buf_virt_addr != NULL )
{ {
memcpy( (void*)(dev->_data_buf_virt_addr+offset/4), mybuf, vfs_read_retval); memcpy( (void*)(dev->_data_buf_virt_addr+offset/4), mybuf, vfs_read_retval);
} }
offset += vfs_read_retval; offset += vfs_read_retval;
if( vfs_read_retval < line_size ) if( vfs_read_retval < line_size )
{ {
printk(KERN_INFO "Done: exit %s() since no more bytes to read from Video file.\n", __func__ ); printk(KERN_INFO "Done: exit %s() since no more bytes to read from Video file.\n", __func__ );
break; break;
} }
} }
if( i > 0 ) if( i > 0 )
dev->_frame_count++; dev->_frame_count++;
if( vfs_read_retval < line_size ) if( vfs_read_retval < line_size )
{ {
break; break;
} }
} }
dev->_file_status = (vfs_read_retval == line_size) ? IN_PROGRESS : END_OF_FILE; dev->_file_status = (vfs_read_retval == line_size) ? IN_PROGRESS : END_OF_FILE;
set_fs(old_fs); set_fs(old_fs);
myfile->f_pos = 0; myfile->f_pos = 0;
filp_close(myfile, NULL); filp_close(myfile, NULL);
} }
return 0; return 0;
@ -522,8 +522,8 @@ int cx25821_openfile(struct cx25821_dev *dev, struct sram_channel *sram_ch)
int cx25821_upstream_buffer_prepare(struct cx25821_dev *dev, int cx25821_upstream_buffer_prepare(struct cx25821_dev *dev,
struct sram_channel *sram_ch, struct sram_channel *sram_ch,
int bpl) int bpl)
{ {
int ret = 0; int ret = 0;
dma_addr_t dma_addr; dma_addr_t dma_addr;
@ -531,7 +531,7 @@ int cx25821_upstream_buffer_prepare(struct cx25821_dev *dev,
if( dev->_dma_virt_addr != NULL ) if( dev->_dma_virt_addr != NULL )
{ {
pci_free_consistent(dev->pci, dev->upstream_riscbuf_size, dev->_dma_virt_addr, dev->_dma_phys_addr); pci_free_consistent(dev->pci, dev->upstream_riscbuf_size, dev->_dma_virt_addr, dev->_dma_phys_addr);
} }
@ -544,8 +544,8 @@ int cx25821_upstream_buffer_prepare(struct cx25821_dev *dev,
if (!dev->_dma_virt_addr) if (!dev->_dma_virt_addr)
{ {
printk("cx25821: FAILED to allocate memory for Risc buffer! Returning.\n"); printk("cx25821: FAILED to allocate memory for Risc buffer! Returning.\n");
return -ENOMEM; return -ENOMEM;
} }
@ -555,7 +555,7 @@ int cx25821_upstream_buffer_prepare(struct cx25821_dev *dev,
if( dev->_data_buf_virt_addr != NULL ) if( dev->_data_buf_virt_addr != NULL )
{ {
pci_free_consistent(dev->pci, dev->upstream_databuf_size, dev->_data_buf_virt_addr, dev->_data_buf_phys_addr); pci_free_consistent(dev->pci, dev->upstream_databuf_size, dev->_data_buf_virt_addr, dev->_data_buf_phys_addr);
} }
//For Video Data buffer allocation //For Video Data buffer allocation
@ -565,8 +565,8 @@ int cx25821_upstream_buffer_prepare(struct cx25821_dev *dev,
if (!dev->_data_buf_virt_addr) if (!dev->_data_buf_virt_addr)
{ {
printk("cx25821: FAILED to allocate memory for data buffer! Returning.\n"); printk("cx25821: FAILED to allocate memory for data buffer! Returning.\n");
return -ENOMEM; return -ENOMEM;
} }
@ -576,15 +576,15 @@ int cx25821_upstream_buffer_prepare(struct cx25821_dev *dev,
ret = cx25821_openfile(dev, sram_ch); ret = cx25821_openfile(dev, sram_ch);
if( ret < 0 ) if( ret < 0 )
return ret; return ret;
//Create RISC programs //Create RISC programs
ret = cx25821_risc_buffer_upstream(dev, dev->pci, 0, bpl, dev->_lines_count ); ret = cx25821_risc_buffer_upstream(dev, dev->pci, 0, bpl, dev->_lines_count );
if (ret < 0) if (ret < 0)
{ {
printk(KERN_INFO "cx25821: Failed creating Video Upstream Risc programs! \n"); printk(KERN_INFO "cx25821: Failed creating Video Upstream Risc programs! \n");
goto error; goto error;
} }
return 0; return 0;
@ -607,70 +607,70 @@ int cx25821_video_upstream_irq(struct cx25821_dev *dev, int chan_num, u32 status
if (status & FLD_VID_SRC_RISC1) if (status & FLD_VID_SRC_RISC1)
{ {
// We should only process one program per call // We should only process one program per call
u32 prog_cnt = cx_read( channel->gpcnt ); u32 prog_cnt = cx_read( channel->gpcnt );
//Since we've identified our IRQ, clear our bits from the interrupt mask and interrupt status registers //Since we've identified our IRQ, clear our bits from the interrupt mask and interrupt status registers
int_msk_tmp = cx_read(channel->int_msk); int_msk_tmp = cx_read(channel->int_msk);
cx_write(channel->int_msk, int_msk_tmp & ~_intr_msk); cx_write(channel->int_msk, int_msk_tmp & ~_intr_msk);
cx_write( channel->int_stat, _intr_msk ); cx_write( channel->int_stat, _intr_msk );
spin_lock(&dev->slock); spin_lock(&dev->slock);
dev->_frame_index = prog_cnt; dev->_frame_index = prog_cnt;
queue_work(dev->_irq_queues, &dev->_irq_work_entry); queue_work(dev->_irq_queues, &dev->_irq_work_entry);
if ( dev->_is_first_frame ) if ( dev->_is_first_frame )
{ {
dev->_is_first_frame = 0; dev->_is_first_frame = 0;
if( dev->_isNTSC ) if( dev->_isNTSC )
{ {
singlefield_lines += 1; singlefield_lines += 1;
odd_risc_prog_size = ODD_FLD_NTSC_PROG_SIZE; odd_risc_prog_size = ODD_FLD_NTSC_PROG_SIZE;
} }
else else
{ {
singlefield_lines = PAL_FIELD_HEIGHT; singlefield_lines = PAL_FIELD_HEIGHT;
odd_risc_prog_size = ODD_FLD_PAL_PROG_SIZE; odd_risc_prog_size = ODD_FLD_PAL_PROG_SIZE;
} }
if( dev->_dma_virt_start_addr != NULL ) if( dev->_dma_virt_start_addr != NULL )
{ {
line_size_in_bytes = (dev->_pixel_format == PIXEL_FRMT_411) ? Y411_LINE_SZ : Y422_LINE_SZ; line_size_in_bytes = (dev->_pixel_format == PIXEL_FRMT_411) ? Y411_LINE_SZ : Y422_LINE_SZ;
risc_phys_jump_addr = dev->_dma_phys_start_addr + odd_risc_prog_size; risc_phys_jump_addr = dev->_dma_phys_start_addr + odd_risc_prog_size;
rp = cx25821_update_riscprogram(dev, dev->_dma_virt_start_addr, TOP_OFFSET, line_size_in_bytes, 0x0, singlefield_lines, FIFO_DISABLE, ODD_FIELD); rp = cx25821_update_riscprogram(dev, dev->_dma_virt_start_addr, TOP_OFFSET, line_size_in_bytes, 0x0, singlefield_lines, FIFO_DISABLE, ODD_FIELD);
// Jump to Even Risc program of 1st Frame // Jump to Even Risc program of 1st Frame
*(rp++) = cpu_to_le32(RISC_JUMP); *(rp++) = cpu_to_le32(RISC_JUMP);
*(rp++) = cpu_to_le32(risc_phys_jump_addr); *(rp++) = cpu_to_le32(risc_phys_jump_addr);
*(rp++) = cpu_to_le32(0); *(rp++) = cpu_to_le32(0);
} }
} }
spin_unlock(&dev->slock); spin_unlock(&dev->slock);
} }
else else
{ {
if(status & FLD_VID_SRC_UF) if(status & FLD_VID_SRC_UF)
printk("%s: Video Received Underflow Error Interrupt!\n", __func__); printk("%s: Video Received Underflow Error Interrupt!\n", __func__);
if(status & FLD_VID_SRC_SYNC) if(status & FLD_VID_SRC_SYNC)
printk("%s: Video Received Sync Error Interrupt!\n", __func__); printk("%s: Video Received Sync Error Interrupt!\n", __func__);
if(status & FLD_VID_SRC_OPC_ERR) if(status & FLD_VID_SRC_OPC_ERR)
printk("%s: Video Received OpCode Error Interrupt!\n", __func__); printk("%s: Video Received OpCode Error Interrupt!\n", __func__);
} }
if( dev->_file_status == END_OF_FILE ) if( dev->_file_status == END_OF_FILE )
{ {
printk("cx25821: EOF Channel 1 Framecount = %d\n", dev->_frame_count ); printk("cx25821: EOF Channel 1 Framecount = %d\n", dev->_frame_count );
return -1; return -1;
} }
//ElSE, set the interrupt mask register, re-enable irq. //ElSE, set the interrupt mask register, re-enable irq.
@ -690,7 +690,7 @@ static irqreturn_t cx25821_upstream_irq(int irq, void *dev_id)
if( !dev ) if( !dev )
return -1; return -1;
channel_num = VID_UPSTREAM_SRAM_CHANNEL_I; channel_num = VID_UPSTREAM_SRAM_CHANNEL_I;
@ -702,16 +702,16 @@ static irqreturn_t cx25821_upstream_irq(int irq, void *dev_id)
// Only deal with our interrupt // Only deal with our interrupt
if(vid_status) if(vid_status)
{ {
handled = cx25821_video_upstream_irq(dev, channel_num, vid_status); handled = cx25821_video_upstream_irq(dev, channel_num, vid_status);
} }
if( handled < 0 ) if( handled < 0 )
{ {
cx25821_stop_upstream_video_ch1(dev); cx25821_stop_upstream_video_ch1(dev);
} }
else else
{ {
handled += handled; handled += handled;
} }
return IRQ_RETVAL(handled); return IRQ_RETVAL(handled);
@ -741,7 +741,7 @@ void cx25821_set_pixelengine(struct cx25821_dev *dev, struct sram_channel *ch, i
if(dev->_isNTSC) if(dev->_isNTSC)
{ {
odd_num_lines += 1; odd_num_lines += 1;
} }
value = (num_lines << 16) | odd_num_lines; value = (num_lines << 16) | odd_num_lines;
@ -754,7 +754,7 @@ void cx25821_set_pixelengine(struct cx25821_dev *dev, struct sram_channel *ch, i
int cx25821_start_video_dma_upstream(struct cx25821_dev *dev, int cx25821_start_video_dma_upstream(struct cx25821_dev *dev,
struct sram_channel *sram_ch) struct sram_channel *sram_ch)
{ {
u32 tmp = 0; u32 tmp = 0;
int err = 0; int err = 0;
@ -785,8 +785,8 @@ int cx25821_start_video_dma_upstream(struct cx25821_dev *dev,
err = request_irq(dev->pci->irq, cx25821_upstream_irq, IRQF_SHARED | IRQF_DISABLED, dev->name, dev); err = request_irq(dev->pci->irq, cx25821_upstream_irq, IRQF_SHARED | IRQF_DISABLED, dev->name, dev);
if (err < 0) if (err < 0)
{ {
printk(KERN_ERR "%s: can't get upstream IRQ %d\n", dev->name, dev->pci->irq); printk(KERN_ERR "%s: can't get upstream IRQ %d\n", dev->name, dev->pci->irq);
goto fail_irq; goto fail_irq;
} }
@ -818,8 +818,8 @@ int cx25821_vidupstream_init_ch1(struct cx25821_dev *dev, int channel_select, in
if( dev->_is_running ) if( dev->_is_running )
{ {
printk("Video Channel is still running so return!\n"); printk("Video Channel is still running so return!\n");
return 0; return 0;
} }
@ -832,8 +832,8 @@ int cx25821_vidupstream_init_ch1(struct cx25821_dev *dev, int channel_select, in
if(!dev->_irq_queues) if(!dev->_irq_queues)
{ {
printk("cx25821: create_singlethread_workqueue() for Video FAILED!\n"); printk("cx25821: create_singlethread_workqueue() for Video FAILED!\n");
return -ENOMEM; return -ENOMEM;
} }
// 656/VIP SRC Upstream Channel I & J and 7 - Host Bus Interface for channel A-C // 656/VIP SRC Upstream Channel I & J and 7 - Host Bus Interface for channel A-C
@ -853,37 +853,37 @@ int cx25821_vidupstream_init_ch1(struct cx25821_dev *dev, int channel_select, in
if( dev->input_filename ) if( dev->input_filename )
{ {
str_length = strlen(dev->input_filename); str_length = strlen(dev->input_filename);
dev->_filename = (char *) kmalloc(str_length + 1, GFP_KERNEL); dev->_filename = (char *) kmalloc(str_length + 1, GFP_KERNEL);
if( !dev->_filename ) if( !dev->_filename )
goto error; goto error;
memcpy(dev->_filename, dev->input_filename, str_length + 1); memcpy(dev->_filename, dev->input_filename, str_length + 1);
} }
else else
{ {
str_length = strlen(dev->_defaultname); str_length = strlen(dev->_defaultname);
dev->_filename = (char *) kmalloc(str_length + 1, GFP_KERNEL); dev->_filename = (char *) kmalloc(str_length + 1, GFP_KERNEL);
if( !dev->_filename ) if( !dev->_filename )
goto error; goto error;
memcpy(dev->_filename, dev->_defaultname, str_length + 1); memcpy(dev->_filename, dev->_defaultname, str_length + 1);
} }
//Default if filename is empty string //Default if filename is empty string
if( strcmp(dev->input_filename,"") == 0) if( strcmp(dev->input_filename,"") == 0)
{ {
if( dev->_isNTSC ) if( dev->_isNTSC )
{ {
dev->_filename = (dev->_pixel_format == PIXEL_FRMT_411) ? "/root/vid411.yuv" : "/root/vidtest.yuv"; dev->_filename = (dev->_pixel_format == PIXEL_FRMT_411) ? "/root/vid411.yuv" : "/root/vidtest.yuv";
} }
else else
{ {
dev->_filename = (dev->_pixel_format == PIXEL_FRMT_411) ? "/root/pal411.yuv" : "/root/pal422.yuv"; dev->_filename = (dev->_pixel_format == PIXEL_FRMT_411) ? "/root/pal411.yuv" : "/root/pal422.yuv";
} }
} }
dev->_is_running = 0; dev->_is_running = 0;
@ -906,8 +906,8 @@ int cx25821_vidupstream_init_ch1(struct cx25821_dev *dev, int channel_select, in
retval = cx25821_upstream_buffer_prepare(dev, sram_ch, dev->_line_size); retval = cx25821_upstream_buffer_prepare(dev, sram_ch, dev->_line_size);
if (retval < 0) if (retval < 0)
{ {
printk(KERN_ERR "%s: Failed to set up Video upstream buffers!\n", dev->name); printk(KERN_ERR "%s: Failed to set up Video upstream buffers!\n", dev->name);
goto error; goto error;
} }

View File

@ -70,38 +70,38 @@
#ifdef USE_RISC_NOOP_VIDEO #ifdef USE_RISC_NOOP_VIDEO
#define PAL_US_VID_PROG_SIZE ((PAL_FIELD_HEIGHT) * 3 * DWORD_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + \ #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) RISC_SYNC_INSTRUCTION_SIZE + NUM_NO_OPS*DWORD_SIZE)
#define PAL_RISC_BUF_SIZE (2 * PAL_US_VID_PROG_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 + \ #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) 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 + \ #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) RISC_WRITECR_INSTRUCTION_SIZE + NUM_NO_OPS*DWORD_SIZE)
#define ODD_FLD_NTSC_PROG_SIZE ((NTSC_ODD_FLD_LINES) * 3 * DWORD_SIZE + RISC_SYNC_INSTRUCTION_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) 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 + \ #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) JUMP_INSTRUCTION_SIZE + NUM_NO_OPS*DWORD_SIZE)
#define NTSC_RISC_BUF_SIZE (2 * (RISC_SYNC_INSTRUCTION_SIZE + NTSC_US_VID_PROG_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 + \ #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) RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE + 2*NUM_NO_OPS*DWORD_SIZE)
#endif #endif
#ifndef USE_RISC_NOOP_VIDEO #ifndef USE_RISC_NOOP_VIDEO
#define PAL_US_VID_PROG_SIZE ((PAL_FIELD_HEIGHT) * 3 * DWORD_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + \ #define PAL_US_VID_PROG_SIZE ((PAL_FIELD_HEIGHT) * 3 * DWORD_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + \
RISC_SYNC_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE) RISC_SYNC_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE)
#define PAL_RISC_BUF_SIZE (2 * PAL_US_VID_PROG_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 + \ #define PAL_VID_PROG_SIZE ((PAL_FIELD_HEIGHT*2) * 3 * DWORD_SIZE + 2*RISC_SYNC_INSTRUCTION_SIZE + \
RISC_WRITECR_INSTRUCTION_SIZE + JUMP_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_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 ODD_FLD_NTSC_PROG_SIZE ((NTSC_ODD_FLD_LINES) * 3 * DWORD_SIZE + RISC_SYNC_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE )
@ -109,5 +109,5 @@
#define NTSC_US_VID_PROG_SIZE ((NTSC_ODD_FLD_LINES + 1) * 3 * DWORD_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + JUMP_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 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 + \ #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 ) RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE )
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -52,7 +52,7 @@
#define dprintk(level, fmt, arg...)\ #define dprintk(level, fmt, arg...)\
do { if (VIDEO_DEBUG >= level)\ do { if (VIDEO_DEBUG >= level)\
printk(KERN_DEBUG "%s/0: " fmt, dev->name, ## arg);\ printk(KERN_DEBUG "%s/0: " fmt, dev->name, ## arg);\
} while (0) } while (0)
@ -117,9 +117,9 @@ extern int res_locked(struct cx25821_dev *dev, unsigned int bit);
extern void res_free(struct cx25821_dev *dev, struct cx25821_fh *fh, unsigned int bits); extern void res_free(struct cx25821_dev *dev, struct cx25821_fh *fh, unsigned int bits);
extern int cx25821_video_mux(struct cx25821_dev *dev, unsigned int input); extern int cx25821_video_mux(struct cx25821_dev *dev, unsigned int input);
extern int cx25821_start_video_dma(struct cx25821_dev *dev, extern int cx25821_start_video_dma(struct cx25821_dev *dev,
struct cx25821_dmaqueue *q, struct cx25821_dmaqueue *q,
struct cx25821_buffer *buf, struct cx25821_buffer *buf,
struct sram_channel *channel); struct sram_channel *channel);
extern int cx25821_set_scale(struct cx25821_dev *dev, unsigned int width, unsigned int height, enum v4l2_field field); extern int cx25821_set_scale(struct cx25821_dev *dev, unsigned int width, unsigned int height, enum v4l2_field field);
extern int cx25821_video_irq(struct cx25821_dev *dev, int chan_num, u32 status); extern int cx25821_video_irq(struct cx25821_dev *dev, int chan_num, u32 status);

View File

@ -40,37 +40,37 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]); dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]);
if (!list_empty(&q->queued)) { if (!list_empty(&q->queued)) {
list_add_tail(&buf->vb.queue, &q->queued); list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED; buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i); dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i);
} else if (list_empty(&q->active)) { } else if (list_empty(&q->active)) {
list_add_tail(&buf->vb.queue, &q->active); list_add_tail(&buf->vb.queue, &q->active);
cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH00]); cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH00]);
buf->vb.state = VIDEOBUF_ACTIVE; buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++; buf->count = q->count++;
mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n", dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n",
buf, buf->vb. i, buf->count, q->count); buf, buf->vb. i, buf->count, q->count);
} else { } else {
prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue); prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue);
if (prev->vb.width == buf->vb.width && if (prev->vb.width == buf->vb.width &&
prev->vb.height == buf->vb.height && prev->vb.height == buf->vb.height &&
prev->fmt == buf->fmt) { prev->fmt == buf->fmt) {
list_add_tail(&buf->vb.queue, &q->active); list_add_tail(&buf->vb.queue, &q->active);
buf->vb.state = VIDEOBUF_ACTIVE; buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++; buf->count = q->count++;
prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
/* 64 bit bits 63-32 */ /* 64 bit bits 63-32 */
prev->risc.jmp[2] = cpu_to_le32(0); prev->risc.jmp[2] = cpu_to_le32(0);
dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count); dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count);
} else { } else {
list_add_tail(&buf->vb.queue, &q->queued); list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED; buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i); dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i);
} }
} }
if (list_empty(&q->active)) if (list_empty(&q->active))
@ -100,18 +100,18 @@ static int video_open(struct file *file)
lock_kernel(); lock_kernel();
list_for_each(list, &cx25821_devlist) list_for_each(list, &cx25821_devlist)
{ {
h = list_entry(list, struct cx25821_dev, devlist); h = list_entry(list, struct cx25821_dev, devlist);
if (h->video_dev[SRAM_CH00] && h->video_dev[SRAM_CH00]->minor == minor) if (h->video_dev[SRAM_CH00] && h->video_dev[SRAM_CH00]->minor == minor)
{ {
dev = h; dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE; type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
} }
} }
if (NULL == dev) { if (NULL == dev) {
unlock_kernel(); unlock_kernel();
return -ENODEV; return -ENODEV;
} }
printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
@ -119,8 +119,8 @@ static int video_open(struct file *file)
/* allocate + initialize per filehandle data */ /* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL); fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) { if (NULL == fh) {
unlock_kernel(); unlock_kernel();
return -ENOMEM; return -ENOMEM;
} }
file->private_data = fh; file->private_data = fh;
@ -129,9 +129,9 @@ static int video_open(struct file *file)
fh->width = 720; fh->width = 720;
if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK)
fh->height = 576; fh->height = 576;
else else
fh->height = 480; fh->height = 480;
dev->channel_opened = SRAM_CH00; dev->channel_opened = SRAM_CH00;
pix_format = (dev->pixel_formats[dev->channel_opened] == PIXEL_FRMT_411) ? V4L2_PIX_FMT_Y41P : V4L2_PIX_FMT_YUYV; 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)
v4l2_prio_open(&dev->prio,&fh->prio); v4l2_prio_open(&dev->prio,&fh->prio);
videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops, videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops,
&dev->pci->dev, &dev->slock, &dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED, V4L2_FIELD_INTERLACED,
sizeof(struct cx25821_buffer), sizeof(struct cx25821_buffer),
fh); fh);
dprintk(1, "post videobuf_queue_init()\n"); dprintk(1, "post videobuf_queue_init()\n");
unlock_kernel(); unlock_kernel();
@ -158,15 +158,15 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo
switch (fh->type) switch (fh->type)
{ {
case V4L2_BUF_TYPE_VIDEO_CAPTURE: case V4L2_BUF_TYPE_VIDEO_CAPTURE:
if (res_locked(fh->dev, RESOURCE_VIDEO0)) if (res_locked(fh->dev, RESOURCE_VIDEO0))
return -EBUSY; return -EBUSY;
return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK); return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK);
default: default:
BUG(); BUG();
return 0; return 0;
} }
} }
@ -176,34 +176,34 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait
struct cx25821_buffer *buf; struct cx25821_buffer *buf;
if (res_check(fh, RESOURCE_VIDEO0)) { if (res_check(fh, RESOURCE_VIDEO0)) {
/* streaming capture */ /* streaming capture */
if (list_empty(&fh->vidq.stream)) if (list_empty(&fh->vidq.stream))
return POLLERR; return POLLERR;
buf = list_entry(fh->vidq.stream.next, buf = list_entry(fh->vidq.stream.next,
struct cx25821_buffer, vb.stream); struct cx25821_buffer, vb.stream);
} else { } else {
/* read() capture */ /* read() capture */
buf = (struct cx25821_buffer *)fh->vidq.read_buf; buf = (struct cx25821_buffer *)fh->vidq.read_buf;
if (NULL == buf) if (NULL == buf)
return POLLERR; return POLLERR;
} }
poll_wait(file, &buf->vb.done, wait); poll_wait(file, &buf->vb.done, wait);
if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR) if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR)
{ {
if( buf->vb.state == VIDEOBUF_DONE ) if( buf->vb.state == VIDEOBUF_DONE )
{ {
struct cx25821_dev *dev = fh->dev; struct cx25821_dev *dev = fh->dev;
if( dev && dev->use_cif_resolution[SRAM_CH00] ) if( dev && dev->use_cif_resolution[SRAM_CH00] )
{ {
u8 cam_id = *((char*)buf->vb.baddr+3); u8 cam_id = *((char*)buf->vb.baddr+3);
memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2)); memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2));
*((char*)buf->vb.baddr+3) = cam_id; *((char*)buf->vb.baddr+3) = cam_id;
} }
} }
return POLLIN|POLLRDNORM; return POLLIN|POLLRDNORM;
} }
return 0; return 0;
@ -220,13 +220,13 @@ static int video_release(struct file *file)
/* stop video capture */ /* stop video capture */
if (res_check(fh, RESOURCE_VIDEO0)) { if (res_check(fh, RESOURCE_VIDEO0)) {
videobuf_queue_cancel(&fh->vidq); videobuf_queue_cancel(&fh->vidq);
res_free(dev, fh, RESOURCE_VIDEO0); res_free(dev, fh, RESOURCE_VIDEO0);
} }
if (fh->vidq.read_buf) { if (fh->vidq.read_buf) {
buffer_release(&fh->vidq, fh->vidq.read_buf); buffer_release(&fh->vidq, fh->vidq.read_buf);
kfree(fh->vidq.read_buf); kfree(fh->vidq.read_buf);
} }
videobuf_mmap_free(&fh->vidq); videobuf_mmap_free(&fh->vidq);
@ -246,17 +246,17 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE))
{ {
return -EINVAL; return -EINVAL;
} }
if (unlikely(i != fh->type)) if (unlikely(i != fh->type))
{ {
return -EINVAL; return -EINVAL;
} }
if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO0)))) if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO0))))
{ {
return -EBUSY; return -EBUSY;
} }
return videobuf_streamon(get_queue(fh)); return videobuf_streamon(get_queue(fh));
@ -269,14 +269,14 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
int err, res; int err, res;
if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL; return -EINVAL;
if (i != fh->type) if (i != fh->type)
return -EINVAL; return -EINVAL;
res = get_resource(fh, RESOURCE_VIDEO0); res = get_resource(fh, RESOURCE_VIDEO0);
err = videobuf_streamoff(get_queue(fh)); err = videobuf_streamoff(get_queue(fh));
if (err < 0) if (err < 0)
return err; return err;
res_free(dev, fh, res); res_free(dev, fh, res);
return 0; return 0;
} }
@ -291,16 +291,16 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
if (fh) if (fh)
{ {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
dprintk(2, "%s()\n", __func__); dprintk(2, "%s()\n", __func__);
err = vidioc_try_fmt_vid_cap(file, priv, f); err = vidioc_try_fmt_vid_cap(file, priv, f);
if (0 != err) if (0 != err)
return err; return err;
fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat);
fh->vidq.field = f->fmt.pix.field; fh->vidq.field = f->fmt.pix.field;
@ -308,30 +308,30 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
// check if width and height is valid based on set standard // check if width and height is valid based on set standard
if (is_valid_width(f->fmt.pix.width, dev->tvnorm)) if (is_valid_width(f->fmt.pix.width, dev->tvnorm))
{ {
fh->width = f->fmt.pix.width; fh->width = f->fmt.pix.width;
} }
if (is_valid_height(f->fmt.pix.height, dev->tvnorm)) if (is_valid_height(f->fmt.pix.height, dev->tvnorm))
{ {
fh->height = f->fmt.pix.height; fh->height = f->fmt.pix.height;
} }
if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P) if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P)
pix_format = PIXEL_FRMT_411; pix_format = PIXEL_FRMT_411;
else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV) else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV)
pix_format = PIXEL_FRMT_422; pix_format = PIXEL_FRMT_422;
else else
return -EINVAL; return -EINVAL;
cx25821_set_pixel_format( dev, SRAM_CH00, pix_format ); cx25821_set_pixel_format( dev, SRAM_CH00, pix_format );
// check if cif resolution // check if cif resolution
if (fh->width == 320 || fh->width == 352) if (fh->width == 320 || fh->width == 352)
{ {
dev->use_cif_resolution[SRAM_CH00] = 1; dev->use_cif_resolution[SRAM_CH00] = 1;
}else }else
{ {
dev->use_cif_resolution[SRAM_CH00] = 0; dev->use_cif_resolution[SRAM_CH00] = 0;
} }
dev->cif_width[SRAM_CH00] = fh->width; dev->cif_width[SRAM_CH00] = fh->width;
medusa_set_resolution( dev, fh->width, SRAM_CH00 ); medusa_set_resolution( dev, fh->width, SRAM_CH00 );
@ -378,10 +378,10 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
struct v4l2_control *ctl) struct v4l2_control *ctl)
{ {
struct cx25821_fh *fh = priv; struct cx25821_fh *fh = priv;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
int err; int err;
if (fh) { if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err) if (0 != err)
return err; return err;

View File

@ -41,37 +41,37 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]); dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]);
if (!list_empty(&q->queued)) { if (!list_empty(&q->queued)) {
list_add_tail(&buf->vb.queue, &q->queued); list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED; buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i); dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i);
} else if (list_empty(&q->active)) { } else if (list_empty(&q->active)) {
list_add_tail(&buf->vb.queue, &q->active); list_add_tail(&buf->vb.queue, &q->active);
cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH01]); cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH01]);
buf->vb.state = VIDEOBUF_ACTIVE; buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++; buf->count = q->count++;
mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n", dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n",
buf, buf->vb. i, buf->count, q->count); buf, buf->vb. i, buf->count, q->count);
} else { } else {
prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue); prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue);
if (prev->vb.width == buf->vb.width && if (prev->vb.width == buf->vb.width &&
prev->vb.height == buf->vb.height && prev->vb.height == buf->vb.height &&
prev->fmt == buf->fmt) { prev->fmt == buf->fmt) {
list_add_tail(&buf->vb.queue, &q->active); list_add_tail(&buf->vb.queue, &q->active);
buf->vb.state = VIDEOBUF_ACTIVE; buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++; buf->count = q->count++;
prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
/* 64 bit bits 63-32 */ /* 64 bit bits 63-32 */
prev->risc.jmp[2] = cpu_to_le32(0); prev->risc.jmp[2] = cpu_to_le32(0);
dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count); dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count);
} else { } else {
list_add_tail(&buf->vb.queue, &q->queued); list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED; buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i); dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i);
} }
} }
if (list_empty(&q->active)) if (list_empty(&q->active))
@ -101,17 +101,17 @@ static int video_open(struct file *file)
lock_kernel(); lock_kernel();
list_for_each(list, &cx25821_devlist) list_for_each(list, &cx25821_devlist)
{ {
h = list_entry(list, struct cx25821_dev, devlist); h = list_entry(list, struct cx25821_dev, devlist);
if (h->video_dev[SRAM_CH01] && h->video_dev[SRAM_CH01]->minor == minor) { if (h->video_dev[SRAM_CH01] && h->video_dev[SRAM_CH01]->minor == minor) {
dev = h; dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE; type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
} }
} }
if (NULL == dev) { if (NULL == dev) {
unlock_kernel(); unlock_kernel();
return -ENODEV; return -ENODEV;
} }
printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
@ -119,8 +119,8 @@ static int video_open(struct file *file)
/* allocate + initialize per filehandle data */ /* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL); fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) { if (NULL == fh) {
unlock_kernel(); unlock_kernel();
return -ENOMEM; return -ENOMEM;
} }
file->private_data = fh; file->private_data = fh;
@ -129,9 +129,9 @@ static int video_open(struct file *file)
fh->width = 720; fh->width = 720;
if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK)
fh->height = 576; fh->height = 576;
else else
fh->height = 480; fh->height = 480;
dev->channel_opened = SRAM_CH01; dev->channel_opened = SRAM_CH01;
pix_format = (dev->pixel_formats[dev->channel_opened] == PIXEL_FRMT_411) ? V4L2_PIX_FMT_Y41P : V4L2_PIX_FMT_YUYV; 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)
v4l2_prio_open(&dev->prio,&fh->prio); v4l2_prio_open(&dev->prio,&fh->prio);
videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops, videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops,
&dev->pci->dev, &dev->slock, &dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED, V4L2_FIELD_INTERLACED,
sizeof(struct cx25821_buffer), sizeof(struct cx25821_buffer),
fh); fh);
dprintk(1, "post videobuf_queue_init()\n"); dprintk(1, "post videobuf_queue_init()\n");
unlock_kernel(); unlock_kernel();
@ -158,15 +158,15 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo
switch (fh->type) switch (fh->type)
{ {
case V4L2_BUF_TYPE_VIDEO_CAPTURE: case V4L2_BUF_TYPE_VIDEO_CAPTURE:
if (res_locked(fh->dev, RESOURCE_VIDEO1)) if (res_locked(fh->dev, RESOURCE_VIDEO1))
return -EBUSY; return -EBUSY;
return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK); return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK);
default: default:
BUG(); BUG();
return 0; return 0;
} }
} }
@ -176,34 +176,34 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait
struct cx25821_buffer *buf; struct cx25821_buffer *buf;
if (res_check(fh, RESOURCE_VIDEO1)) { if (res_check(fh, RESOURCE_VIDEO1)) {
/* streaming capture */ /* streaming capture */
if (list_empty(&fh->vidq.stream)) if (list_empty(&fh->vidq.stream))
return POLLERR; return POLLERR;
buf = list_entry(fh->vidq.stream.next, buf = list_entry(fh->vidq.stream.next,
struct cx25821_buffer, vb.stream); struct cx25821_buffer, vb.stream);
} else { } else {
/* read() capture */ /* read() capture */
buf = (struct cx25821_buffer *)fh->vidq.read_buf; buf = (struct cx25821_buffer *)fh->vidq.read_buf;
if (NULL == buf) if (NULL == buf)
return POLLERR; return POLLERR;
} }
poll_wait(file, &buf->vb.done, wait); poll_wait(file, &buf->vb.done, wait);
if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR) if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR)
{ {
if( buf->vb.state == VIDEOBUF_DONE ) if( buf->vb.state == VIDEOBUF_DONE )
{ {
struct cx25821_dev *dev = fh->dev; struct cx25821_dev *dev = fh->dev;
if( dev && dev->use_cif_resolution[SRAM_CH01] ) if( dev && dev->use_cif_resolution[SRAM_CH01] )
{ {
u8 cam_id = *((char*)buf->vb.baddr+3); u8 cam_id = *((char*)buf->vb.baddr+3);
memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2)); memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2));
*((char*)buf->vb.baddr+3) = cam_id; *((char*)buf->vb.baddr+3) = cam_id;
} }
} }
return POLLIN|POLLRDNORM; return POLLIN|POLLRDNORM;
} }
return 0; return 0;
@ -219,13 +219,13 @@ static int video_release(struct file *file)
/* stop video capture */ /* stop video capture */
if (res_check(fh, RESOURCE_VIDEO1)) { if (res_check(fh, RESOURCE_VIDEO1)) {
videobuf_queue_cancel(&fh->vidq); videobuf_queue_cancel(&fh->vidq);
res_free(dev, fh, RESOURCE_VIDEO1); res_free(dev, fh, RESOURCE_VIDEO1);
} }
if (fh->vidq.read_buf) { if (fh->vidq.read_buf) {
buffer_release(&fh->vidq, fh->vidq.read_buf); buffer_release(&fh->vidq, fh->vidq.read_buf);
kfree(fh->vidq.read_buf); kfree(fh->vidq.read_buf);
} }
videobuf_mmap_free(&fh->vidq); videobuf_mmap_free(&fh->vidq);
@ -245,17 +245,17 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE))
{ {
return -EINVAL; return -EINVAL;
} }
if (unlikely(i != fh->type)) if (unlikely(i != fh->type))
{ {
return -EINVAL; return -EINVAL;
} }
if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO1)))) if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO1))))
{ {
return -EBUSY; return -EBUSY;
} }
return videobuf_streamon(get_queue(fh)); return videobuf_streamon(get_queue(fh));
@ -268,14 +268,14 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
int err, res; int err, res;
if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL; return -EINVAL;
if (i != fh->type) if (i != fh->type)
return -EINVAL; return -EINVAL;
res = get_resource(fh, RESOURCE_VIDEO1); res = get_resource(fh, RESOURCE_VIDEO1);
err = videobuf_streamoff(get_queue(fh)); err = videobuf_streamoff(get_queue(fh));
if (err < 0) if (err < 0)
return err; return err;
res_free(dev, fh, res); res_free(dev, fh, res);
return 0; return 0;
} }
@ -291,16 +291,16 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
if (fh) if (fh)
{ {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
dprintk(2, "%s()\n", __func__); dprintk(2, "%s()\n", __func__);
err = vidioc_try_fmt_vid_cap(file, priv, f); err = vidioc_try_fmt_vid_cap(file, priv, f);
if (0 != err) if (0 != err)
return err; return err;
fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat);
fh->vidq.field = f->fmt.pix.field; fh->vidq.field = f->fmt.pix.field;
@ -308,27 +308,27 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
// check if width and height is valid based on set standard // check if width and height is valid based on set standard
if (is_valid_width(f->fmt.pix.width, dev->tvnorm)) if (is_valid_width(f->fmt.pix.width, dev->tvnorm))
{ {
fh->width = f->fmt.pix.width; fh->width = f->fmt.pix.width;
} }
if (is_valid_height(f->fmt.pix.height, dev->tvnorm)) if (is_valid_height(f->fmt.pix.height, dev->tvnorm))
{ {
fh->height = f->fmt.pix.height; fh->height = f->fmt.pix.height;
} }
if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P) if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P)
pix_format = PIXEL_FRMT_411; pix_format = PIXEL_FRMT_411;
else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV) else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV)
pix_format = PIXEL_FRMT_422; pix_format = PIXEL_FRMT_422;
else else
return -EINVAL; return -EINVAL;
cx25821_set_pixel_format( dev, SRAM_CH01, pix_format ); cx25821_set_pixel_format( dev, SRAM_CH01, pix_format );
// check if cif resolution // check if cif resolution
if (fh->width == 320 || fh->width == 352) if (fh->width == 320 || fh->width == 352)
{ {
dev->use_cif_resolution[SRAM_CH01] = 1; dev->use_cif_resolution[SRAM_CH01] = 1;
}else }else
{ {
dev->use_cif_resolution[SRAM_CH01] = 0; dev->use_cif_resolution[SRAM_CH01] = 0;
@ -378,10 +378,10 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
struct v4l2_control *ctl) struct v4l2_control *ctl)
{ {
struct cx25821_fh *fh = priv; struct cx25821_fh *fh = priv;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
int err; int err;
if (fh) { if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err) if (0 != err)
return err; return err;

View File

@ -41,37 +41,37 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]); dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]);
if (!list_empty(&q->queued)) { if (!list_empty(&q->queued)) {
list_add_tail(&buf->vb.queue, &q->queued); list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED; buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i); dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i);
} else if (list_empty(&q->active)) { } else if (list_empty(&q->active)) {
list_add_tail(&buf->vb.queue, &q->active); list_add_tail(&buf->vb.queue, &q->active);
cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH02]); cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH02]);
buf->vb.state = VIDEOBUF_ACTIVE; buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++; buf->count = q->count++;
mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n", dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n",
buf, buf->vb. i, buf->count, q->count); buf, buf->vb. i, buf->count, q->count);
} else { } else {
prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue); prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue);
if (prev->vb.width == buf->vb.width && if (prev->vb.width == buf->vb.width &&
prev->vb.height == buf->vb.height && prev->vb.height == buf->vb.height &&
prev->fmt == buf->fmt) { prev->fmt == buf->fmt) {
list_add_tail(&buf->vb.queue, &q->active); list_add_tail(&buf->vb.queue, &q->active);
buf->vb.state = VIDEOBUF_ACTIVE; buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++; buf->count = q->count++;
prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
/* 64 bit bits 63-32 */ /* 64 bit bits 63-32 */
prev->risc.jmp[2] = cpu_to_le32(0); prev->risc.jmp[2] = cpu_to_le32(0);
dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count); dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count);
} else { } else {
list_add_tail(&buf->vb.queue, &q->queued); list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED; buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i); dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i);
} }
} }
if (list_empty(&q->active)) if (list_empty(&q->active))
@ -101,17 +101,17 @@ static int video_open(struct file *file)
lock_kernel(); lock_kernel();
list_for_each(list, &cx25821_devlist) list_for_each(list, &cx25821_devlist)
{ {
h = list_entry(list, struct cx25821_dev, devlist); h = list_entry(list, struct cx25821_dev, devlist);
if (h->video_dev[SRAM_CH02] && h->video_dev[SRAM_CH02]->minor == minor) { if (h->video_dev[SRAM_CH02] && h->video_dev[SRAM_CH02]->minor == minor) {
dev = h; dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE; type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
} }
} }
if (NULL == dev) { if (NULL == dev) {
unlock_kernel(); unlock_kernel();
return -ENODEV; return -ENODEV;
} }
printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
@ -119,8 +119,8 @@ static int video_open(struct file *file)
/* allocate + initialize per filehandle data */ /* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL); fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) { if (NULL == fh) {
unlock_kernel(); unlock_kernel();
return -ENOMEM; return -ENOMEM;
} }
file->private_data = fh; file->private_data = fh;
fh->dev = dev; fh->dev = dev;
@ -128,9 +128,9 @@ static int video_open(struct file *file)
fh->width = 720; fh->width = 720;
if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK)
fh->height = 576; fh->height = 576;
else else
fh->height = 480; fh->height = 480;
dev->channel_opened = SRAM_CH02; dev->channel_opened = SRAM_CH02;
pix_format = (dev->pixel_formats[dev->channel_opened] == PIXEL_FRMT_411) ? V4L2_PIX_FMT_Y41P : V4L2_PIX_FMT_YUYV; 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)
v4l2_prio_open(&dev->prio,&fh->prio); v4l2_prio_open(&dev->prio,&fh->prio);
videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops, videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops,
&dev->pci->dev, &dev->slock, &dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED, V4L2_FIELD_INTERLACED,
sizeof(struct cx25821_buffer), sizeof(struct cx25821_buffer),
fh); fh);
dprintk(1, "post videobuf_queue_init()\n"); dprintk(1, "post videobuf_queue_init()\n");
unlock_kernel(); unlock_kernel();
@ -157,15 +157,15 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo
switch (fh->type) switch (fh->type)
{ {
case V4L2_BUF_TYPE_VIDEO_CAPTURE: case V4L2_BUF_TYPE_VIDEO_CAPTURE:
if (res_locked(fh->dev, RESOURCE_VIDEO2)) if (res_locked(fh->dev, RESOURCE_VIDEO2))
return -EBUSY; return -EBUSY;
return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK); return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK);
default: default:
BUG(); BUG();
return 0; return 0;
} }
} }
@ -175,34 +175,34 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait
struct cx25821_buffer *buf; struct cx25821_buffer *buf;
if (res_check(fh, RESOURCE_VIDEO2)) { if (res_check(fh, RESOURCE_VIDEO2)) {
/* streaming capture */ /* streaming capture */
if (list_empty(&fh->vidq.stream)) if (list_empty(&fh->vidq.stream))
return POLLERR; return POLLERR;
buf = list_entry(fh->vidq.stream.next, buf = list_entry(fh->vidq.stream.next,
struct cx25821_buffer, vb.stream); struct cx25821_buffer, vb.stream);
} else { } else {
/* read() capture */ /* read() capture */
buf = (struct cx25821_buffer *)fh->vidq.read_buf; buf = (struct cx25821_buffer *)fh->vidq.read_buf;
if (NULL == buf) if (NULL == buf)
return POLLERR; return POLLERR;
} }
poll_wait(file, &buf->vb.done, wait); poll_wait(file, &buf->vb.done, wait);
if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR) if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR)
{ {
if( buf->vb.state == VIDEOBUF_DONE ) if( buf->vb.state == VIDEOBUF_DONE )
{ {
struct cx25821_dev *dev = fh->dev; struct cx25821_dev *dev = fh->dev;
if( dev && dev->use_cif_resolution[SRAM_CH02] ) if( dev && dev->use_cif_resolution[SRAM_CH02] )
{ {
u8 cam_id = *((char*)buf->vb.baddr+3); u8 cam_id = *((char*)buf->vb.baddr+3);
memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2)); memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2));
*((char*)buf->vb.baddr+3) = cam_id; *((char*)buf->vb.baddr+3) = cam_id;
} }
} }
return POLLIN|POLLRDNORM; return POLLIN|POLLRDNORM;
} }
return 0; return 0;
@ -219,13 +219,13 @@ static int video_release(struct file *file)
/* stop video capture */ /* stop video capture */
if (res_check(fh, RESOURCE_VIDEO2)) { if (res_check(fh, RESOURCE_VIDEO2)) {
videobuf_queue_cancel(&fh->vidq); videobuf_queue_cancel(&fh->vidq);
res_free(dev, fh, RESOURCE_VIDEO2); res_free(dev, fh, RESOURCE_VIDEO2);
} }
if (fh->vidq.read_buf) { if (fh->vidq.read_buf) {
buffer_release(&fh->vidq, fh->vidq.read_buf); buffer_release(&fh->vidq, fh->vidq.read_buf);
kfree(fh->vidq.read_buf); kfree(fh->vidq.read_buf);
} }
videobuf_mmap_free(&fh->vidq); videobuf_mmap_free(&fh->vidq);
@ -245,17 +245,17 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE))
{ {
return -EINVAL; return -EINVAL;
} }
if (unlikely(i != fh->type)) if (unlikely(i != fh->type))
{ {
return -EINVAL; return -EINVAL;
} }
if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO2)))) if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO2))))
{ {
return -EBUSY; return -EBUSY;
} }
return videobuf_streamon(get_queue(fh)); return videobuf_streamon(get_queue(fh));
@ -268,14 +268,14 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
int err, res; int err, res;
if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL; return -EINVAL;
if (i != fh->type) if (i != fh->type)
return -EINVAL; return -EINVAL;
res = get_resource(fh, RESOURCE_VIDEO2); res = get_resource(fh, RESOURCE_VIDEO2);
err = videobuf_streamoff(get_queue(fh)); err = videobuf_streamoff(get_queue(fh));
if (err < 0) if (err < 0)
return err; return err;
res_free(dev, fh, res); res_free(dev, fh, res);
return 0; return 0;
} }
@ -291,16 +291,16 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
if (fh) if (fh)
{ {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
dprintk(2, "%s()\n", __func__); dprintk(2, "%s()\n", __func__);
err = vidioc_try_fmt_vid_cap(file, priv, f); err = vidioc_try_fmt_vid_cap(file, priv, f);
if (0 != err) if (0 != err)
return err; return err;
fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat);
fh->vidq.field = f->fmt.pix.field; fh->vidq.field = f->fmt.pix.field;
@ -308,27 +308,27 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
// check if width and height is valid based on set standard // check if width and height is valid based on set standard
if (is_valid_width(f->fmt.pix.width, dev->tvnorm)) if (is_valid_width(f->fmt.pix.width, dev->tvnorm))
{ {
fh->width = f->fmt.pix.width; fh->width = f->fmt.pix.width;
} }
if (is_valid_height(f->fmt.pix.height, dev->tvnorm)) if (is_valid_height(f->fmt.pix.height, dev->tvnorm))
{ {
fh->height = f->fmt.pix.height; fh->height = f->fmt.pix.height;
} }
if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P) if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P)
pix_format = PIXEL_FRMT_411; pix_format = PIXEL_FRMT_411;
else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV) else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV)
pix_format = PIXEL_FRMT_422; pix_format = PIXEL_FRMT_422;
else else
return -EINVAL; return -EINVAL;
cx25821_set_pixel_format( dev, SRAM_CH02, pix_format ); cx25821_set_pixel_format( dev, SRAM_CH02, pix_format );
// check if cif resolution // check if cif resolution
if (fh->width == 320 || fh->width == 352) if (fh->width == 320 || fh->width == 352)
{ {
dev->use_cif_resolution[SRAM_CH02] = 1; dev->use_cif_resolution[SRAM_CH02] = 1;
}else }else
{ {
dev->use_cif_resolution[SRAM_CH02] = 0; dev->use_cif_resolution[SRAM_CH02] = 0;
@ -381,10 +381,10 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
struct v4l2_control *ctl) struct v4l2_control *ctl)
{ {
struct cx25821_fh *fh = priv; struct cx25821_fh *fh = priv;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
int err; int err;
if (fh) { if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err) if (0 != err)
return err; return err;

View File

@ -41,37 +41,37 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]); dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]);
if (!list_empty(&q->queued)) { if (!list_empty(&q->queued)) {
list_add_tail(&buf->vb.queue, &q->queued); list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED; buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i); dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i);
} else if (list_empty(&q->active)) { } else if (list_empty(&q->active)) {
list_add_tail(&buf->vb.queue, &q->active); list_add_tail(&buf->vb.queue, &q->active);
cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH03]); cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH03]);
buf->vb.state = VIDEOBUF_ACTIVE; buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++; buf->count = q->count++;
mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n", dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n",
buf, buf->vb. i, buf->count, q->count); buf, buf->vb. i, buf->count, q->count);
} else { } else {
prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue); prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue);
if (prev->vb.width == buf->vb.width && if (prev->vb.width == buf->vb.width &&
prev->vb.height == buf->vb.height && prev->vb.height == buf->vb.height &&
prev->fmt == buf->fmt) { prev->fmt == buf->fmt) {
list_add_tail(&buf->vb.queue, &q->active); list_add_tail(&buf->vb.queue, &q->active);
buf->vb.state = VIDEOBUF_ACTIVE; buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++; buf->count = q->count++;
prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
/* 64 bit bits 63-32 */ /* 64 bit bits 63-32 */
prev->risc.jmp[2] = cpu_to_le32(0); prev->risc.jmp[2] = cpu_to_le32(0);
dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count); dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count);
} else { } else {
list_add_tail(&buf->vb.queue, &q->queued); list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED; buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i); dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i);
} }
} }
if (list_empty(&q->active)) if (list_empty(&q->active))
@ -101,17 +101,17 @@ static int video_open(struct file *file)
lock_kernel(); lock_kernel();
list_for_each(list, &cx25821_devlist) list_for_each(list, &cx25821_devlist)
{ {
h = list_entry(list, struct cx25821_dev, devlist); h = list_entry(list, struct cx25821_dev, devlist);
if (h->video_dev[SRAM_CH03] && h->video_dev[SRAM_CH03]->minor == minor) { if (h->video_dev[SRAM_CH03] && h->video_dev[SRAM_CH03]->minor == minor) {
dev = h; dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE; type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
} }
} }
if (NULL == dev) { if (NULL == dev) {
unlock_kernel(); unlock_kernel();
return -ENODEV; return -ENODEV;
} }
printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
@ -119,8 +119,8 @@ static int video_open(struct file *file)
/* allocate + initialize per filehandle data */ /* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL); fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) { if (NULL == fh) {
unlock_kernel(); unlock_kernel();
return -ENOMEM; return -ENOMEM;
} }
file->private_data = fh; file->private_data = fh;
fh->dev = dev; fh->dev = dev;
@ -128,9 +128,9 @@ static int video_open(struct file *file)
fh->width = 720; fh->width = 720;
if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK)
fh->height = 576; fh->height = 576;
else else
fh->height = 480; fh->height = 480;
dev->channel_opened = SRAM_CH03; dev->channel_opened = SRAM_CH03;
pix_format = (dev->pixel_formats[dev->channel_opened] == PIXEL_FRMT_411) ? V4L2_PIX_FMT_Y41P : V4L2_PIX_FMT_YUYV; 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)
v4l2_prio_open(&dev->prio,&fh->prio); v4l2_prio_open(&dev->prio,&fh->prio);
videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops, videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops,
&dev->pci->dev, &dev->slock, &dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED, V4L2_FIELD_INTERLACED,
sizeof(struct cx25821_buffer), sizeof(struct cx25821_buffer),
fh); fh);
dprintk(1, "post videobuf_queue_init()\n"); dprintk(1, "post videobuf_queue_init()\n");
unlock_kernel(); unlock_kernel();
@ -157,15 +157,15 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo
switch (fh->type) switch (fh->type)
{ {
case V4L2_BUF_TYPE_VIDEO_CAPTURE: case V4L2_BUF_TYPE_VIDEO_CAPTURE:
if (res_locked(fh->dev, RESOURCE_VIDEO3)) if (res_locked(fh->dev, RESOURCE_VIDEO3))
return -EBUSY; return -EBUSY;
return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK); return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK);
default: default:
BUG(); BUG();
return 0; return 0;
} }
} }
@ -175,34 +175,34 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait
struct cx25821_buffer *buf; struct cx25821_buffer *buf;
if (res_check(fh, RESOURCE_VIDEO3)) { if (res_check(fh, RESOURCE_VIDEO3)) {
/* streaming capture */ /* streaming capture */
if (list_empty(&fh->vidq.stream)) if (list_empty(&fh->vidq.stream))
return POLLERR; return POLLERR;
buf = list_entry(fh->vidq.stream.next, buf = list_entry(fh->vidq.stream.next,
struct cx25821_buffer, vb.stream); struct cx25821_buffer, vb.stream);
} else { } else {
/* read() capture */ /* read() capture */
buf = (struct cx25821_buffer *)fh->vidq.read_buf; buf = (struct cx25821_buffer *)fh->vidq.read_buf;
if (NULL == buf) if (NULL == buf)
return POLLERR; return POLLERR;
} }
poll_wait(file, &buf->vb.done, wait); poll_wait(file, &buf->vb.done, wait);
if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR) if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR)
{ {
if( buf->vb.state == VIDEOBUF_DONE ) if( buf->vb.state == VIDEOBUF_DONE )
{ {
struct cx25821_dev *dev = fh->dev; struct cx25821_dev *dev = fh->dev;
if( dev && dev->use_cif_resolution[SRAM_CH03] ) if( dev && dev->use_cif_resolution[SRAM_CH03] )
{ {
u8 cam_id = *((char*)buf->vb.baddr+3); u8 cam_id = *((char*)buf->vb.baddr+3);
memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2)); memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2));
*((char*)buf->vb.baddr+3) = cam_id; *((char*)buf->vb.baddr+3) = cam_id;
} }
} }
return POLLIN|POLLRDNORM; return POLLIN|POLLRDNORM;
} }
return 0; return 0;
@ -219,13 +219,13 @@ static int video_release(struct file *file)
/* stop video capture */ /* stop video capture */
if (res_check(fh, RESOURCE_VIDEO3)) { if (res_check(fh, RESOURCE_VIDEO3)) {
videobuf_queue_cancel(&fh->vidq); videobuf_queue_cancel(&fh->vidq);
res_free(dev, fh, RESOURCE_VIDEO3); res_free(dev, fh, RESOURCE_VIDEO3);
} }
if (fh->vidq.read_buf) { if (fh->vidq.read_buf) {
buffer_release(&fh->vidq, fh->vidq.read_buf); buffer_release(&fh->vidq, fh->vidq.read_buf);
kfree(fh->vidq.read_buf); kfree(fh->vidq.read_buf);
} }
videobuf_mmap_free(&fh->vidq); videobuf_mmap_free(&fh->vidq);
@ -245,17 +245,17 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE))
{ {
return -EINVAL; return -EINVAL;
} }
if (unlikely(i != fh->type)) if (unlikely(i != fh->type))
{ {
return -EINVAL; return -EINVAL;
} }
if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO3)))) if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO3))))
{ {
return -EBUSY; return -EBUSY;
} }
return videobuf_streamon(get_queue(fh)); return videobuf_streamon(get_queue(fh));
@ -268,14 +268,14 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
int err, res; int err, res;
if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL; return -EINVAL;
if (i != fh->type) if (i != fh->type)
return -EINVAL; return -EINVAL;
res = get_resource(fh, RESOURCE_VIDEO3); res = get_resource(fh, RESOURCE_VIDEO3);
err = videobuf_streamoff(get_queue(fh)); err = videobuf_streamoff(get_queue(fh));
if (err < 0) if (err < 0)
return err; return err;
res_free(dev, fh, res); res_free(dev, fh, res);
return 0; return 0;
} }
@ -291,16 +291,16 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
if (fh) if (fh)
{ {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
dprintk(2, "%s()\n", __func__); dprintk(2, "%s()\n", __func__);
err = vidioc_try_fmt_vid_cap(file, priv, f); err = vidioc_try_fmt_vid_cap(file, priv, f);
if (0 != err) if (0 != err)
return err; return err;
fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat);
fh->vidq.field = f->fmt.pix.field; fh->vidq.field = f->fmt.pix.field;
@ -308,30 +308,30 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
// check if width and height is valid based on set standard // check if width and height is valid based on set standard
if (is_valid_width(f->fmt.pix.width, dev->tvnorm)) if (is_valid_width(f->fmt.pix.width, dev->tvnorm))
{ {
fh->width = f->fmt.pix.width; fh->width = f->fmt.pix.width;
} }
if (is_valid_height(f->fmt.pix.height, dev->tvnorm)) if (is_valid_height(f->fmt.pix.height, dev->tvnorm))
{ {
fh->height = f->fmt.pix.height; fh->height = f->fmt.pix.height;
} }
if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P) if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P)
pix_format = PIXEL_FRMT_411; pix_format = PIXEL_FRMT_411;
else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV) else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV)
pix_format = PIXEL_FRMT_422; pix_format = PIXEL_FRMT_422;
else else
return -EINVAL; return -EINVAL;
cx25821_set_pixel_format( dev, SRAM_CH03, pix_format ); cx25821_set_pixel_format( dev, SRAM_CH03, pix_format );
// check if cif resolution // check if cif resolution
if (fh->width == 320 || fh->width == 352) if (fh->width == 320 || fh->width == 352)
{ {
dev->use_cif_resolution[SRAM_CH03] = 1; dev->use_cif_resolution[SRAM_CH03] = 1;
}else }else
{ {
dev->use_cif_resolution[SRAM_CH03] = 0; dev->use_cif_resolution[SRAM_CH03] = 0;
} }
dev->cif_width[SRAM_CH03] = fh->width; dev->cif_width[SRAM_CH03] = fh->width;
medusa_set_resolution( dev, fh->width, SRAM_CH03 ); medusa_set_resolution( dev, fh->width, SRAM_CH03 );
@ -379,10 +379,10 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
struct v4l2_control *ctl) struct v4l2_control *ctl)
{ {
struct cx25821_fh *fh = priv; struct cx25821_fh *fh = priv;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
int err; int err;
if (fh) { if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err) if (0 != err)
return err; return err;

View File

@ -40,37 +40,37 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]); dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]);
if (!list_empty(&q->queued)) { if (!list_empty(&q->queued)) {
list_add_tail(&buf->vb.queue, &q->queued); list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED; buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i); dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i);
} else if (list_empty(&q->active)) { } else if (list_empty(&q->active)) {
list_add_tail(&buf->vb.queue, &q->active); list_add_tail(&buf->vb.queue, &q->active);
cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH04]); cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH04]);
buf->vb.state = VIDEOBUF_ACTIVE; buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++; buf->count = q->count++;
mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n", dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n",
buf, buf->vb. i, buf->count, q->count); buf, buf->vb. i, buf->count, q->count);
} else { } else {
prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue); prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue);
if (prev->vb.width == buf->vb.width && if (prev->vb.width == buf->vb.width &&
prev->vb.height == buf->vb.height && prev->vb.height == buf->vb.height &&
prev->fmt == buf->fmt) { prev->fmt == buf->fmt) {
list_add_tail(&buf->vb.queue, &q->active); list_add_tail(&buf->vb.queue, &q->active);
buf->vb.state = VIDEOBUF_ACTIVE; buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++; buf->count = q->count++;
prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
/* 64 bit bits 63-32 */ /* 64 bit bits 63-32 */
prev->risc.jmp[2] = cpu_to_le32(0); prev->risc.jmp[2] = cpu_to_le32(0);
dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count); dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count);
} else { } else {
list_add_tail(&buf->vb.queue, &q->queued); list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED; buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i); dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i);
} }
} }
if (list_empty(&q->active)) if (list_empty(&q->active))
@ -100,17 +100,17 @@ static int video_open(struct file *file)
lock_kernel(); lock_kernel();
list_for_each(list, &cx25821_devlist) list_for_each(list, &cx25821_devlist)
{ {
h = list_entry(list, struct cx25821_dev, devlist); h = list_entry(list, struct cx25821_dev, devlist);
if (h->video_dev[SRAM_CH04] && h->video_dev[SRAM_CH04]->minor == minor) { if (h->video_dev[SRAM_CH04] && h->video_dev[SRAM_CH04]->minor == minor) {
dev = h; dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE; type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
} }
} }
if (NULL == dev) { if (NULL == dev) {
unlock_kernel(); unlock_kernel();
return -ENODEV; return -ENODEV;
} }
printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
@ -118,8 +118,8 @@ static int video_open(struct file *file)
/* allocate + initialize per filehandle data */ /* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL); fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) { if (NULL == fh) {
unlock_kernel(); unlock_kernel();
return -ENOMEM; return -ENOMEM;
} }
file->private_data = fh; file->private_data = fh;
fh->dev = dev; fh->dev = dev;
@ -127,9 +127,9 @@ static int video_open(struct file *file)
fh->width = 720; fh->width = 720;
if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK)
fh->height = 576; fh->height = 576;
else else
fh->height = 480; fh->height = 480;
dev->channel_opened = SRAM_CH04; dev->channel_opened = SRAM_CH04;
pix_format = (dev->pixel_formats[dev->channel_opened] == PIXEL_FRMT_411) ? V4L2_PIX_FMT_Y41P : V4L2_PIX_FMT_YUYV; 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)
v4l2_prio_open(&dev->prio,&fh->prio); v4l2_prio_open(&dev->prio,&fh->prio);
videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops, videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops,
&dev->pci->dev, &dev->slock, &dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED, V4L2_FIELD_INTERLACED,
sizeof(struct cx25821_buffer), sizeof(struct cx25821_buffer),
fh); fh);
dprintk(1, "post videobuf_queue_init()\n"); dprintk(1, "post videobuf_queue_init()\n");
unlock_kernel(); unlock_kernel();
@ -155,15 +155,15 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo
switch (fh->type) switch (fh->type)
{ {
case V4L2_BUF_TYPE_VIDEO_CAPTURE: case V4L2_BUF_TYPE_VIDEO_CAPTURE:
if (res_locked(fh->dev, RESOURCE_VIDEO4)) if (res_locked(fh->dev, RESOURCE_VIDEO4))
return -EBUSY; return -EBUSY;
return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK); return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK);
default: default:
BUG(); BUG();
return 0; return 0;
} }
} }
@ -173,34 +173,34 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait
struct cx25821_buffer *buf; struct cx25821_buffer *buf;
if (res_check(fh, RESOURCE_VIDEO4)) { if (res_check(fh, RESOURCE_VIDEO4)) {
/* streaming capture */ /* streaming capture */
if (list_empty(&fh->vidq.stream)) if (list_empty(&fh->vidq.stream))
return POLLERR; return POLLERR;
buf = list_entry(fh->vidq.stream.next, buf = list_entry(fh->vidq.stream.next,
struct cx25821_buffer, vb.stream); struct cx25821_buffer, vb.stream);
} else { } else {
/* read() capture */ /* read() capture */
buf = (struct cx25821_buffer *)fh->vidq.read_buf; buf = (struct cx25821_buffer *)fh->vidq.read_buf;
if (NULL == buf) if (NULL == buf)
return POLLERR; return POLLERR;
} }
poll_wait(file, &buf->vb.done, wait); poll_wait(file, &buf->vb.done, wait);
if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR) if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR)
{ {
if( buf->vb.state == VIDEOBUF_DONE ) if( buf->vb.state == VIDEOBUF_DONE )
{ {
struct cx25821_dev *dev = fh->dev; struct cx25821_dev *dev = fh->dev;
if( dev && dev->use_cif_resolution[SRAM_CH04] ) if( dev && dev->use_cif_resolution[SRAM_CH04] )
{ {
u8 cam_id = *((char*)buf->vb.baddr+3); u8 cam_id = *((char*)buf->vb.baddr+3);
memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2)); memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2));
*((char*)buf->vb.baddr+3) = cam_id; *((char*)buf->vb.baddr+3) = cam_id;
} }
} }
return POLLIN|POLLRDNORM; return POLLIN|POLLRDNORM;
} }
return 0; return 0;
@ -217,13 +217,13 @@ static int video_release(struct file *file)
/* stop video capture */ /* stop video capture */
if (res_check(fh, RESOURCE_VIDEO4)) { if (res_check(fh, RESOURCE_VIDEO4)) {
videobuf_queue_cancel(&fh->vidq); videobuf_queue_cancel(&fh->vidq);
res_free(dev, fh, RESOURCE_VIDEO4); res_free(dev, fh, RESOURCE_VIDEO4);
} }
if (fh->vidq.read_buf) { if (fh->vidq.read_buf) {
buffer_release(&fh->vidq, fh->vidq.read_buf); buffer_release(&fh->vidq, fh->vidq.read_buf);
kfree(fh->vidq.read_buf); kfree(fh->vidq.read_buf);
} }
videobuf_mmap_free(&fh->vidq); videobuf_mmap_free(&fh->vidq);
@ -243,17 +243,17 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE))
{ {
return -EINVAL; return -EINVAL;
} }
if (unlikely(i != fh->type)) if (unlikely(i != fh->type))
{ {
return -EINVAL; return -EINVAL;
} }
if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO4)))) if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO4))))
{ {
return -EBUSY; return -EBUSY;
} }
return videobuf_streamon(get_queue(fh)); return videobuf_streamon(get_queue(fh));
@ -266,14 +266,14 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
int err, res; int err, res;
if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL; return -EINVAL;
if (i != fh->type) if (i != fh->type)
return -EINVAL; return -EINVAL;
res = get_resource(fh, RESOURCE_VIDEO4); res = get_resource(fh, RESOURCE_VIDEO4);
err = videobuf_streamoff(get_queue(fh)); err = videobuf_streamoff(get_queue(fh));
if (err < 0) if (err < 0)
return err; return err;
res_free(dev, fh, res); res_free(dev, fh, res);
return 0; return 0;
} }
@ -290,15 +290,15 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
// check priority // check priority
if (fh) if (fh)
{ {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
dprintk(2, "%s()\n", __func__); dprintk(2, "%s()\n", __func__);
err = vidioc_try_fmt_vid_cap(file, priv, f); err = vidioc_try_fmt_vid_cap(file, priv, f);
if (0 != err) if (0 != err)
return err; return err;
fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat);
fh->vidq.field = f->fmt.pix.field; fh->vidq.field = f->fmt.pix.field;
@ -306,27 +306,27 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
// check if width and height is valid based on set standard // check if width and height is valid based on set standard
if (is_valid_width(f->fmt.pix.width, dev->tvnorm)) if (is_valid_width(f->fmt.pix.width, dev->tvnorm))
{ {
fh->width = f->fmt.pix.width; fh->width = f->fmt.pix.width;
} }
if (is_valid_height(f->fmt.pix.height, dev->tvnorm)) if (is_valid_height(f->fmt.pix.height, dev->tvnorm))
{ {
fh->height = f->fmt.pix.height; fh->height = f->fmt.pix.height;
} }
if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P) if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P)
pix_format = PIXEL_FRMT_411; pix_format = PIXEL_FRMT_411;
else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV) else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV)
pix_format = PIXEL_FRMT_422; pix_format = PIXEL_FRMT_422;
else else
return -EINVAL; return -EINVAL;
cx25821_set_pixel_format( dev, SRAM_CH04, pix_format ); cx25821_set_pixel_format( dev, SRAM_CH04, pix_format );
// check if cif resolution // check if cif resolution
if (fh->width == 320 || fh->width == 352) if (fh->width == 320 || fh->width == 352)
{ {
dev->use_cif_resolution[SRAM_CH04] = 1; dev->use_cif_resolution[SRAM_CH04] = 1;
}else }else
{ {
dev->use_cif_resolution[SRAM_CH04] = 0; dev->use_cif_resolution[SRAM_CH04] = 0;
@ -377,10 +377,10 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
struct v4l2_control *ctl) struct v4l2_control *ctl)
{ {
struct cx25821_fh *fh = priv; struct cx25821_fh *fh = priv;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
int err; int err;
if (fh) { if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err) if (0 != err)
return err; return err;

View File

@ -40,37 +40,37 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]); dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]);
if (!list_empty(&q->queued)) { if (!list_empty(&q->queued)) {
list_add_tail(&buf->vb.queue, &q->queued); list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED; buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i); dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i);
} else if (list_empty(&q->active)) { } else if (list_empty(&q->active)) {
list_add_tail(&buf->vb.queue, &q->active); list_add_tail(&buf->vb.queue, &q->active);
cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH05]); cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH05]);
buf->vb.state = VIDEOBUF_ACTIVE; buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++; buf->count = q->count++;
mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n", dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n",
buf, buf->vb. i, buf->count, q->count); buf, buf->vb. i, buf->count, q->count);
} else { } else {
prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue); prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue);
if (prev->vb.width == buf->vb.width && if (prev->vb.width == buf->vb.width &&
prev->vb.height == buf->vb.height && prev->vb.height == buf->vb.height &&
prev->fmt == buf->fmt) { prev->fmt == buf->fmt) {
list_add_tail(&buf->vb.queue, &q->active); list_add_tail(&buf->vb.queue, &q->active);
buf->vb.state = VIDEOBUF_ACTIVE; buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++; buf->count = q->count++;
prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
/* 64 bit bits 63-32 */ /* 64 bit bits 63-32 */
prev->risc.jmp[2] = cpu_to_le32(0); prev->risc.jmp[2] = cpu_to_le32(0);
dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count); dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count);
} else { } else {
list_add_tail(&buf->vb.queue, &q->queued); list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED; buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i); dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i);
} }
} }
if (list_empty(&q->active)) if (list_empty(&q->active))
@ -100,17 +100,17 @@ static int video_open(struct file *file)
lock_kernel(); lock_kernel();
list_for_each(list, &cx25821_devlist) list_for_each(list, &cx25821_devlist)
{ {
h = list_entry(list, struct cx25821_dev, devlist); h = list_entry(list, struct cx25821_dev, devlist);
if (h->video_dev[SRAM_CH05] && h->video_dev[SRAM_CH05]->minor == minor) { if (h->video_dev[SRAM_CH05] && h->video_dev[SRAM_CH05]->minor == minor) {
dev = h; dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE; type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
} }
} }
if (NULL == dev) { if (NULL == dev) {
unlock_kernel(); unlock_kernel();
return -ENODEV; return -ENODEV;
} }
printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
@ -118,8 +118,8 @@ static int video_open(struct file *file)
/* allocate + initialize per filehandle data */ /* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL); fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) { if (NULL == fh) {
unlock_kernel(); unlock_kernel();
return -ENOMEM; return -ENOMEM;
} }
file->private_data = fh; file->private_data = fh;
fh->dev = dev; fh->dev = dev;
@ -127,9 +127,9 @@ static int video_open(struct file *file)
fh->width = 720; fh->width = 720;
if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK)
fh->height = 576; fh->height = 576;
else else
fh->height = 480; fh->height = 480;
dev->channel_opened = SRAM_CH05; dev->channel_opened = SRAM_CH05;
pix_format = (dev->pixel_formats[dev->channel_opened] == PIXEL_FRMT_411) ? V4L2_PIX_FMT_Y41P : V4L2_PIX_FMT_YUYV; 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)
v4l2_prio_open(&dev->prio,&fh->prio); v4l2_prio_open(&dev->prio,&fh->prio);
videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops, videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops,
&dev->pci->dev, &dev->slock, &dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED, V4L2_FIELD_INTERLACED,
sizeof(struct cx25821_buffer), sizeof(struct cx25821_buffer),
fh); fh);
dprintk(1, "post videobuf_queue_init()\n"); dprintk(1, "post videobuf_queue_init()\n");
unlock_kernel(); unlock_kernel();
@ -156,15 +156,15 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo
switch (fh->type) switch (fh->type)
{ {
case V4L2_BUF_TYPE_VIDEO_CAPTURE: case V4L2_BUF_TYPE_VIDEO_CAPTURE:
if (res_locked(fh->dev, RESOURCE_VIDEO5)) if (res_locked(fh->dev, RESOURCE_VIDEO5))
return -EBUSY; return -EBUSY;
return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK); return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK);
default: default:
BUG(); BUG();
return 0; return 0;
} }
} }
@ -174,34 +174,34 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait
struct cx25821_buffer *buf; struct cx25821_buffer *buf;
if (res_check(fh, RESOURCE_VIDEO5)) { if (res_check(fh, RESOURCE_VIDEO5)) {
/* streaming capture */ /* streaming capture */
if (list_empty(&fh->vidq.stream)) if (list_empty(&fh->vidq.stream))
return POLLERR; return POLLERR;
buf = list_entry(fh->vidq.stream.next, buf = list_entry(fh->vidq.stream.next,
struct cx25821_buffer, vb.stream); struct cx25821_buffer, vb.stream);
} else { } else {
/* read() capture */ /* read() capture */
buf = (struct cx25821_buffer *)fh->vidq.read_buf; buf = (struct cx25821_buffer *)fh->vidq.read_buf;
if (NULL == buf) if (NULL == buf)
return POLLERR; return POLLERR;
} }
poll_wait(file, &buf->vb.done, wait); poll_wait(file, &buf->vb.done, wait);
if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR) if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR)
{ {
if( buf->vb.state == VIDEOBUF_DONE ) if( buf->vb.state == VIDEOBUF_DONE )
{ {
struct cx25821_dev *dev = fh->dev; struct cx25821_dev *dev = fh->dev;
if( dev && dev->use_cif_resolution[SRAM_CH05] ) if( dev && dev->use_cif_resolution[SRAM_CH05] )
{ {
u8 cam_id = *((char*)buf->vb.baddr+3); u8 cam_id = *((char*)buf->vb.baddr+3);
memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2)); memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2));
*((char*)buf->vb.baddr+3) = cam_id; *((char*)buf->vb.baddr+3) = cam_id;
} }
} }
return POLLIN|POLLRDNORM; return POLLIN|POLLRDNORM;
} }
return 0; return 0;
@ -218,13 +218,13 @@ static int video_release(struct file *file)
/* stop video capture */ /* stop video capture */
if (res_check(fh, RESOURCE_VIDEO5)) { if (res_check(fh, RESOURCE_VIDEO5)) {
videobuf_queue_cancel(&fh->vidq); videobuf_queue_cancel(&fh->vidq);
res_free(dev, fh, RESOURCE_VIDEO5); res_free(dev, fh, RESOURCE_VIDEO5);
} }
if (fh->vidq.read_buf) { if (fh->vidq.read_buf) {
buffer_release(&fh->vidq, fh->vidq.read_buf); buffer_release(&fh->vidq, fh->vidq.read_buf);
kfree(fh->vidq.read_buf); kfree(fh->vidq.read_buf);
} }
videobuf_mmap_free(&fh->vidq); videobuf_mmap_free(&fh->vidq);
@ -244,17 +244,17 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE))
{ {
return -EINVAL; return -EINVAL;
} }
if (unlikely(i != fh->type)) if (unlikely(i != fh->type))
{ {
return -EINVAL; return -EINVAL;
} }
if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO5)))) if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO5))))
{ {
return -EBUSY; return -EBUSY;
} }
return videobuf_streamon(get_queue(fh)); return videobuf_streamon(get_queue(fh));
@ -267,14 +267,14 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
int err, res; int err, res;
if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL; return -EINVAL;
if (i != fh->type) if (i != fh->type)
return -EINVAL; return -EINVAL;
res = get_resource(fh, RESOURCE_VIDEO5); res = get_resource(fh, RESOURCE_VIDEO5);
err = videobuf_streamoff(get_queue(fh)); err = videobuf_streamoff(get_queue(fh));
if (err < 0) if (err < 0)
return err; return err;
res_free(dev, fh, res); res_free(dev, fh, res);
return 0; return 0;
} }
@ -289,16 +289,16 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
if (fh) if (fh)
{ {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
dprintk(2, "%s()\n", __func__); dprintk(2, "%s()\n", __func__);
err = vidioc_try_fmt_vid_cap(file, priv, f); err = vidioc_try_fmt_vid_cap(file, priv, f);
if (0 != err) if (0 != err)
return err; return err;
fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat);
fh->vidq.field = f->fmt.pix.field; fh->vidq.field = f->fmt.pix.field;
@ -306,27 +306,27 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
// check if width and height is valid based on set standard // check if width and height is valid based on set standard
if (is_valid_width(f->fmt.pix.width, dev->tvnorm)) if (is_valid_width(f->fmt.pix.width, dev->tvnorm))
{ {
fh->width = f->fmt.pix.width; fh->width = f->fmt.pix.width;
} }
if (is_valid_height(f->fmt.pix.height, dev->tvnorm)) if (is_valid_height(f->fmt.pix.height, dev->tvnorm))
{ {
fh->height = f->fmt.pix.height; fh->height = f->fmt.pix.height;
} }
if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P) if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P)
pix_format = PIXEL_FRMT_411; pix_format = PIXEL_FRMT_411;
else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV) else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV)
pix_format = PIXEL_FRMT_422; pix_format = PIXEL_FRMT_422;
else else
return -EINVAL; return -EINVAL;
cx25821_set_pixel_format( dev, SRAM_CH05, pix_format ); cx25821_set_pixel_format( dev, SRAM_CH05, pix_format );
// check if cif resolution // check if cif resolution
if (fh->width == 320 || fh->width == 352) if (fh->width == 320 || fh->width == 352)
{ {
dev->use_cif_resolution[SRAM_CH05] = 1; dev->use_cif_resolution[SRAM_CH05] = 1;
}else }else
{ {
dev->use_cif_resolution[SRAM_CH05] = 0; dev->use_cif_resolution[SRAM_CH05] = 0;
@ -376,10 +376,10 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
struct v4l2_control *ctl) struct v4l2_control *ctl)
{ {
struct cx25821_fh *fh = priv; struct cx25821_fh *fh = priv;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
int err; int err;
if (fh) { if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err) if (0 != err)
return err; return err;

View File

@ -40,37 +40,37 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]); dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]);
if (!list_empty(&q->queued)) { if (!list_empty(&q->queued)) {
list_add_tail(&buf->vb.queue, &q->queued); list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED; buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i); dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i);
} else if (list_empty(&q->active)) { } else if (list_empty(&q->active)) {
list_add_tail(&buf->vb.queue, &q->active); list_add_tail(&buf->vb.queue, &q->active);
cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH06]); cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH06]);
buf->vb.state = VIDEOBUF_ACTIVE; buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++; buf->count = q->count++;
mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n", dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n",
buf, buf->vb. i, buf->count, q->count); buf, buf->vb. i, buf->count, q->count);
} else { } else {
prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue); prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue);
if (prev->vb.width == buf->vb.width && if (prev->vb.width == buf->vb.width &&
prev->vb.height == buf->vb.height && prev->vb.height == buf->vb.height &&
prev->fmt == buf->fmt) { prev->fmt == buf->fmt) {
list_add_tail(&buf->vb.queue, &q->active); list_add_tail(&buf->vb.queue, &q->active);
buf->vb.state = VIDEOBUF_ACTIVE; buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++; buf->count = q->count++;
prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
/* 64 bit bits 63-32 */ /* 64 bit bits 63-32 */
prev->risc.jmp[2] = cpu_to_le32(0); prev->risc.jmp[2] = cpu_to_le32(0);
dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count); dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count);
} else { } else {
list_add_tail(&buf->vb.queue, &q->queued); list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED; buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i); dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i);
} }
} }
if (list_empty(&q->active)) if (list_empty(&q->active))
@ -100,17 +100,17 @@ static int video_open(struct file *file)
lock_kernel(); lock_kernel();
list_for_each(list, &cx25821_devlist) list_for_each(list, &cx25821_devlist)
{ {
h = list_entry(list, struct cx25821_dev, devlist); h = list_entry(list, struct cx25821_dev, devlist);
if (h->video_dev[SRAM_CH06] && h->video_dev[SRAM_CH06]->minor == minor) { if (h->video_dev[SRAM_CH06] && h->video_dev[SRAM_CH06]->minor == minor) {
dev = h; dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE; type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
} }
} }
if (NULL == dev) { if (NULL == dev) {
unlock_kernel(); unlock_kernel();
return -ENODEV; return -ENODEV;
} }
printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
@ -118,8 +118,8 @@ static int video_open(struct file *file)
/* allocate + initialize per filehandle data */ /* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL); fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) { if (NULL == fh) {
unlock_kernel(); unlock_kernel();
return -ENOMEM; return -ENOMEM;
} }
file->private_data = fh; file->private_data = fh;
fh->dev = dev; fh->dev = dev;
@ -127,9 +127,9 @@ static int video_open(struct file *file)
fh->width = 720; fh->width = 720;
if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK)
fh->height = 576; fh->height = 576;
else else
fh->height = 480; fh->height = 480;
dev->channel_opened = SRAM_CH06; dev->channel_opened = SRAM_CH06;
pix_format = (dev->pixel_formats[dev->channel_opened] == PIXEL_FRMT_411) ? V4L2_PIX_FMT_Y41P : V4L2_PIX_FMT_YUYV; 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)
v4l2_prio_open(&dev->prio,&fh->prio); v4l2_prio_open(&dev->prio,&fh->prio);
videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops, videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops,
&dev->pci->dev, &dev->slock, &dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED, V4L2_FIELD_INTERLACED,
sizeof(struct cx25821_buffer), sizeof(struct cx25821_buffer),
fh); fh);
dprintk(1, "post videobuf_queue_init()\n"); dprintk(1, "post videobuf_queue_init()\n");
unlock_kernel(); unlock_kernel();
@ -156,15 +156,15 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo
switch (fh->type) switch (fh->type)
{ {
case V4L2_BUF_TYPE_VIDEO_CAPTURE: case V4L2_BUF_TYPE_VIDEO_CAPTURE:
if (res_locked(fh->dev, RESOURCE_VIDEO6)) if (res_locked(fh->dev, RESOURCE_VIDEO6))
return -EBUSY; return -EBUSY;
return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK); return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK);
default: default:
BUG(); BUG();
return 0; return 0;
} }
} }
@ -174,34 +174,34 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait
struct cx25821_buffer *buf; struct cx25821_buffer *buf;
if (res_check(fh, RESOURCE_VIDEO6)) { if (res_check(fh, RESOURCE_VIDEO6)) {
/* streaming capture */ /* streaming capture */
if (list_empty(&fh->vidq.stream)) if (list_empty(&fh->vidq.stream))
return POLLERR; return POLLERR;
buf = list_entry(fh->vidq.stream.next, buf = list_entry(fh->vidq.stream.next,
struct cx25821_buffer, vb.stream); struct cx25821_buffer, vb.stream);
} else { } else {
/* read() capture */ /* read() capture */
buf = (struct cx25821_buffer *)fh->vidq.read_buf; buf = (struct cx25821_buffer *)fh->vidq.read_buf;
if (NULL == buf) if (NULL == buf)
return POLLERR; return POLLERR;
} }
poll_wait(file, &buf->vb.done, wait); poll_wait(file, &buf->vb.done, wait);
if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR) if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR)
{ {
if( buf->vb.state == VIDEOBUF_DONE ) if( buf->vb.state == VIDEOBUF_DONE )
{ {
struct cx25821_dev *dev = fh->dev; struct cx25821_dev *dev = fh->dev;
if( dev && dev->use_cif_resolution[SRAM_CH06] ) if( dev && dev->use_cif_resolution[SRAM_CH06] )
{ {
u8 cam_id = *((char*)buf->vb.baddr+3); u8 cam_id = *((char*)buf->vb.baddr+3);
memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2)); memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2));
*((char*)buf->vb.baddr+3) = cam_id; *((char*)buf->vb.baddr+3) = cam_id;
} }
} }
return POLLIN|POLLRDNORM; return POLLIN|POLLRDNORM;
} }
return 0; return 0;
@ -218,12 +218,12 @@ static int video_release(struct file *file)
/* stop video capture */ /* stop video capture */
if (res_check(fh, RESOURCE_VIDEO6)) { if (res_check(fh, RESOURCE_VIDEO6)) {
videobuf_queue_cancel(&fh->vidq); videobuf_queue_cancel(&fh->vidq);
res_free(dev, fh, RESOURCE_VIDEO6); res_free(dev, fh, RESOURCE_VIDEO6);
} }
if (fh->vidq.read_buf) { if (fh->vidq.read_buf) {
buffer_release(&fh->vidq, fh->vidq.read_buf); buffer_release(&fh->vidq, fh->vidq.read_buf);
kfree(fh->vidq.read_buf); kfree(fh->vidq.read_buf);
} }
videobuf_mmap_free(&fh->vidq); videobuf_mmap_free(&fh->vidq);
@ -243,17 +243,17 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE))
{ {
return -EINVAL; return -EINVAL;
} }
if (unlikely(i != fh->type)) if (unlikely(i != fh->type))
{ {
return -EINVAL; return -EINVAL;
} }
if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO6)))) if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO6))))
{ {
return -EBUSY; return -EBUSY;
} }
return videobuf_streamon(get_queue(fh)); return videobuf_streamon(get_queue(fh));
@ -266,14 +266,14 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
int err, res; int err, res;
if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL; return -EINVAL;
if (i != fh->type) if (i != fh->type)
return -EINVAL; return -EINVAL;
res = get_resource(fh, RESOURCE_VIDEO6); res = get_resource(fh, RESOURCE_VIDEO6);
err = videobuf_streamoff(get_queue(fh)); err = videobuf_streamoff(get_queue(fh));
if (err < 0) if (err < 0)
return err; return err;
res_free(dev, fh, res); res_free(dev, fh, res);
return 0; return 0;
} }
@ -288,16 +288,16 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
if (fh) if (fh)
{ {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
dprintk(2, "%s()\n", __func__); dprintk(2, "%s()\n", __func__);
err = vidioc_try_fmt_vid_cap(file, priv, f); err = vidioc_try_fmt_vid_cap(file, priv, f);
if (0 != err) if (0 != err)
return err; return err;
fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat);
fh->vidq.field = f->fmt.pix.field; fh->vidq.field = f->fmt.pix.field;
@ -305,27 +305,27 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
// check if width and height is valid based on set standard // check if width and height is valid based on set standard
if (is_valid_width(f->fmt.pix.width, dev->tvnorm)) if (is_valid_width(f->fmt.pix.width, dev->tvnorm))
{ {
fh->width = f->fmt.pix.width; fh->width = f->fmt.pix.width;
} }
if (is_valid_height(f->fmt.pix.height, dev->tvnorm)) if (is_valid_height(f->fmt.pix.height, dev->tvnorm))
{ {
fh->height = f->fmt.pix.height; fh->height = f->fmt.pix.height;
} }
if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P) if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P)
pix_format = PIXEL_FRMT_411; pix_format = PIXEL_FRMT_411;
else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV) else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV)
pix_format = PIXEL_FRMT_422; pix_format = PIXEL_FRMT_422;
else else
return -EINVAL; return -EINVAL;
cx25821_set_pixel_format( dev, SRAM_CH06, pix_format ); cx25821_set_pixel_format( dev, SRAM_CH06, pix_format );
// check if cif resolution // check if cif resolution
if (fh->width == 320 || fh->width == 352) if (fh->width == 320 || fh->width == 352)
{ {
dev->use_cif_resolution[SRAM_CH06] = 1; dev->use_cif_resolution[SRAM_CH06] = 1;
}else }else
{ {
dev->use_cif_resolution[SRAM_CH06] = 0; dev->use_cif_resolution[SRAM_CH06] = 0;
@ -376,10 +376,10 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
struct v4l2_control *ctl) struct v4l2_control *ctl)
{ {
struct cx25821_fh *fh = priv; struct cx25821_fh *fh = priv;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
int err; int err;
if (fh) { if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err) if (0 != err)
return err; return err;

View File

@ -37,39 +37,39 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
buf->risc.jmp[1] = cpu_to_le32(q->stopper.dma); buf->risc.jmp[1] = cpu_to_le32(q->stopper.dma);
buf->risc.jmp[2] = cpu_to_le32(0); /* bits 63-32 */ buf->risc.jmp[2] = cpu_to_le32(0); /* bits 63-32 */
dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]); dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]);
if (!list_empty(&q->queued)) { if (!list_empty(&q->queued)) {
list_add_tail(&buf->vb.queue, &q->queued); list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED; buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i); dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i);
} else if (list_empty(&q->active)) { } else if (list_empty(&q->active)) {
list_add_tail(&buf->vb.queue, &q->active); list_add_tail(&buf->vb.queue, &q->active);
cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH07]); cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH07]);
buf->vb.state = VIDEOBUF_ACTIVE; buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++; buf->count = q->count++;
mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n", dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n",
buf, buf->vb. i, buf->count, q->count); buf, buf->vb. i, buf->count, q->count);
} else { } else {
prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue); prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue);
if (prev->vb.width == buf->vb.width && if (prev->vb.width == buf->vb.width &&
prev->vb.height == buf->vb.height && prev->vb.height == buf->vb.height &&
prev->fmt == buf->fmt) { prev->fmt == buf->fmt) {
list_add_tail(&buf->vb.queue, &q->active); list_add_tail(&buf->vb.queue, &q->active);
buf->vb.state = VIDEOBUF_ACTIVE; buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++; buf->count = q->count++;
prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
/* 64 bit bits 63-32 */ /* 64 bit bits 63-32 */
prev->risc.jmp[2] = cpu_to_le32(0); prev->risc.jmp[2] = cpu_to_le32(0);
dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count); dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count);
} else { } else {
list_add_tail(&buf->vb.queue, &q->queued); list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED; buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i); dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i);
} }
} }
if (list_empty(&q->active)) if (list_empty(&q->active))
@ -99,17 +99,17 @@ static int video_open(struct file *file)
lock_kernel(); lock_kernel();
list_for_each(list, &cx25821_devlist) list_for_each(list, &cx25821_devlist)
{ {
h = list_entry(list, struct cx25821_dev, devlist); h = list_entry(list, struct cx25821_dev, devlist);
if (h->video_dev[SRAM_CH07] && h->video_dev[SRAM_CH07]->minor == minor) { if (h->video_dev[SRAM_CH07] && h->video_dev[SRAM_CH07]->minor == minor) {
dev = h; dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE; type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
} }
} }
if (NULL == dev) { if (NULL == dev) {
unlock_kernel(); unlock_kernel();
return -ENODEV; return -ENODEV;
} }
printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
@ -117,8 +117,8 @@ static int video_open(struct file *file)
/* allocate + initialize per filehandle data */ /* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL); fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) { if (NULL == fh) {
unlock_kernel(); unlock_kernel();
return -ENOMEM; return -ENOMEM;
} }
file->private_data = fh; file->private_data = fh;
fh->dev = dev; fh->dev = dev;
@ -126,9 +126,9 @@ static int video_open(struct file *file)
fh->width = 720; fh->width = 720;
if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK)
fh->height = 576; fh->height = 576;
else else
fh->height = 480; fh->height = 480;
dev->channel_opened = SRAM_CH07; dev->channel_opened = SRAM_CH07;
pix_format = (dev->pixel_formats[dev->channel_opened] == PIXEL_FRMT_411) ? V4L2_PIX_FMT_Y41P : V4L2_PIX_FMT_YUYV; 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)
v4l2_prio_open(&dev->prio,&fh->prio); v4l2_prio_open(&dev->prio,&fh->prio);
videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops, videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops,
&dev->pci->dev, &dev->slock, &dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED, V4L2_FIELD_INTERLACED,
sizeof(struct cx25821_buffer), sizeof(struct cx25821_buffer),
fh); fh);
dprintk(1, "post videobuf_queue_init()\n"); dprintk(1, "post videobuf_queue_init()\n");
unlock_kernel(); unlock_kernel();
@ -155,15 +155,15 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo
switch (fh->type) switch (fh->type)
{ {
case V4L2_BUF_TYPE_VIDEO_CAPTURE: case V4L2_BUF_TYPE_VIDEO_CAPTURE:
if (res_locked(fh->dev, RESOURCE_VIDEO7)) if (res_locked(fh->dev, RESOURCE_VIDEO7))
return -EBUSY; return -EBUSY;
return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK); return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK);
default: default:
BUG(); BUG();
return 0; return 0;
} }
} }
@ -173,34 +173,34 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait
struct cx25821_buffer *buf; struct cx25821_buffer *buf;
if (res_check(fh, RESOURCE_VIDEO7)) { if (res_check(fh, RESOURCE_VIDEO7)) {
/* streaming capture */ /* streaming capture */
if (list_empty(&fh->vidq.stream)) if (list_empty(&fh->vidq.stream))
return POLLERR; return POLLERR;
buf = list_entry(fh->vidq.stream.next, buf = list_entry(fh->vidq.stream.next,
struct cx25821_buffer, vb.stream); struct cx25821_buffer, vb.stream);
} else { } else {
/* read() capture */ /* read() capture */
buf = (struct cx25821_buffer *)fh->vidq.read_buf; buf = (struct cx25821_buffer *)fh->vidq.read_buf;
if (NULL == buf) if (NULL == buf)
return POLLERR; return POLLERR;
} }
poll_wait(file, &buf->vb.done, wait); poll_wait(file, &buf->vb.done, wait);
if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR) if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR)
{ {
if( buf->vb.state == VIDEOBUF_DONE ) if( buf->vb.state == VIDEOBUF_DONE )
{ {
struct cx25821_dev *dev = fh->dev; struct cx25821_dev *dev = fh->dev;
if( dev && dev->use_cif_resolution[SRAM_CH07] ) if( dev && dev->use_cif_resolution[SRAM_CH07] )
{ {
u8 cam_id = *((char*)buf->vb.baddr+3); u8 cam_id = *((char*)buf->vb.baddr+3);
memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2)); memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2));
*((char*)buf->vb.baddr+3) = cam_id; *((char*)buf->vb.baddr+3) = cam_id;
} }
} }
return POLLIN|POLLRDNORM; return POLLIN|POLLRDNORM;
} }
return 0; return 0;
@ -217,13 +217,13 @@ static int video_release(struct file *file)
/* stop video capture */ /* stop video capture */
if (res_check(fh, RESOURCE_VIDEO7)) { if (res_check(fh, RESOURCE_VIDEO7)) {
videobuf_queue_cancel(&fh->vidq); videobuf_queue_cancel(&fh->vidq);
res_free(dev, fh, RESOURCE_VIDEO7); res_free(dev, fh, RESOURCE_VIDEO7);
} }
if (fh->vidq.read_buf) { if (fh->vidq.read_buf) {
buffer_release(&fh->vidq, fh->vidq.read_buf); buffer_release(&fh->vidq, fh->vidq.read_buf);
kfree(fh->vidq.read_buf); kfree(fh->vidq.read_buf);
} }
videobuf_mmap_free(&fh->vidq); videobuf_mmap_free(&fh->vidq);
@ -243,17 +243,17 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE))
{ {
return -EINVAL; return -EINVAL;
} }
if (unlikely(i != fh->type)) if (unlikely(i != fh->type))
{ {
return -EINVAL; return -EINVAL;
} }
if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO7)))) if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO7))))
{ {
return -EBUSY; return -EBUSY;
} }
return videobuf_streamon(get_queue(fh)); return videobuf_streamon(get_queue(fh));
@ -266,14 +266,14 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
int err, res; int err, res;
if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL; return -EINVAL;
if (i != fh->type) if (i != fh->type)
return -EINVAL; return -EINVAL;
res = get_resource(fh, RESOURCE_VIDEO7); res = get_resource(fh, RESOURCE_VIDEO7);
err = videobuf_streamoff(get_queue(fh)); err = videobuf_streamoff(get_queue(fh));
if (err < 0) if (err < 0)
return err; return err;
res_free(dev, fh, res); res_free(dev, fh, res);
return 0; return 0;
} }
@ -288,8 +288,8 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
if (fh) if (fh)
{ {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
@ -297,7 +297,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
err = vidioc_try_fmt_vid_cap(file, priv, f); err = vidioc_try_fmt_vid_cap(file, priv, f);
if (0 != err) if (0 != err)
return err; return err;
fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat);
fh->vidq.field = f->fmt.pix.field; fh->vidq.field = f->fmt.pix.field;
@ -305,27 +305,27 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
// check if width and height is valid based on set standard // check if width and height is valid based on set standard
if (is_valid_width(f->fmt.pix.width, dev->tvnorm)) if (is_valid_width(f->fmt.pix.width, dev->tvnorm))
{ {
fh->width = f->fmt.pix.width; fh->width = f->fmt.pix.width;
} }
if (is_valid_height(f->fmt.pix.height, dev->tvnorm)) if (is_valid_height(f->fmt.pix.height, dev->tvnorm))
{ {
fh->height = f->fmt.pix.height; fh->height = f->fmt.pix.height;
} }
if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P) if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P)
pix_format = PIXEL_FRMT_411; pix_format = PIXEL_FRMT_411;
else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV) else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV)
pix_format = PIXEL_FRMT_422; pix_format = PIXEL_FRMT_422;
else else
return -EINVAL; return -EINVAL;
cx25821_set_pixel_format( dev, SRAM_CH07, pix_format ); cx25821_set_pixel_format( dev, SRAM_CH07, pix_format );
// check if cif resolution // check if cif resolution
if (fh->width == 320 || fh->width == 352) if (fh->width == 320 || fh->width == 352)
{ {
dev->use_cif_resolution[SRAM_CH07] = 1; dev->use_cif_resolution[SRAM_CH07] = 1;
}else }else
{ {
dev->use_cif_resolution[SRAM_CH07] = 0; dev->use_cif_resolution[SRAM_CH07] = 0;
@ -375,10 +375,10 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
struct v4l2_control *ctl) struct v4l2_control *ctl)
{ {
struct cx25821_fh *fh = priv; struct cx25821_fh *fh = priv;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
int err; int err;
if (fh) { if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err) if (0 != err)
return err; return err;

View File

@ -40,37 +40,37 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]); dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]);
if (!list_empty(&q->queued)) { if (!list_empty(&q->queued)) {
list_add_tail(&buf->vb.queue, &q->queued); list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED; buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i); dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i);
} else if (list_empty(&q->active)) { } else if (list_empty(&q->active)) {
list_add_tail(&buf->vb.queue, &q->active); list_add_tail(&buf->vb.queue, &q->active);
cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[VIDEO_IOCTL_CH]); cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[VIDEO_IOCTL_CH]);
buf->vb.state = VIDEOBUF_ACTIVE; buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++; buf->count = q->count++;
mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n", dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n",
buf, buf->vb. i, buf->count, q->count); buf, buf->vb. i, buf->count, q->count);
} else { } else {
prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue); prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue);
if (prev->vb.width == buf->vb.width && if (prev->vb.width == buf->vb.width &&
prev->vb.height == buf->vb.height && prev->vb.height == buf->vb.height &&
prev->fmt == buf->fmt) { prev->fmt == buf->fmt) {
list_add_tail(&buf->vb.queue, &q->active); list_add_tail(&buf->vb.queue, &q->active);
buf->vb.state = VIDEOBUF_ACTIVE; buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++; buf->count = q->count++;
prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
/* 64 bit bits 63-32 */ /* 64 bit bits 63-32 */
prev->risc.jmp[2] = cpu_to_le32(0); prev->risc.jmp[2] = cpu_to_le32(0);
dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count); dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count);
} else { } else {
list_add_tail(&buf->vb.queue, &q->queued); list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED; buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i); dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i);
} }
} }
if (list_empty(&q->active)) if (list_empty(&q->active))
@ -100,18 +100,18 @@ static int video_open(struct file *file)
lock_kernel(); lock_kernel();
list_for_each(list, &cx25821_devlist) list_for_each(list, &cx25821_devlist)
{ {
h = list_entry(list, struct cx25821_dev, devlist); h = list_entry(list, struct cx25821_dev, devlist);
if (h->ioctl_dev && h->ioctl_dev->minor == minor) if (h->ioctl_dev && h->ioctl_dev->minor == minor)
{ {
dev = h; dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE; type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
} }
} }
if (NULL == dev) { if (NULL == dev) {
unlock_kernel(); unlock_kernel();
return -ENODEV; return -ENODEV;
} }
printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
@ -119,8 +119,8 @@ static int video_open(struct file *file)
/* allocate + initialize per filehandle data */ /* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL); fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) { if (NULL == fh) {
unlock_kernel(); unlock_kernel();
return -ENOMEM; return -ENOMEM;
} }
file->private_data = fh; file->private_data = fh;
@ -129,9 +129,9 @@ static int video_open(struct file *file)
fh->width = 720; fh->width = 720;
if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK)
fh->height = 576; fh->height = 576;
else else
fh->height = 480; fh->height = 480;
dev->channel_opened = VIDEO_IOCTL_CH; dev->channel_opened = VIDEO_IOCTL_CH;
pix_format = V4L2_PIX_FMT_YUYV; pix_format = V4L2_PIX_FMT_YUYV;
@ -140,11 +140,11 @@ static int video_open(struct file *file)
v4l2_prio_open(&dev->prio,&fh->prio); v4l2_prio_open(&dev->prio,&fh->prio);
videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops, videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops,
&dev->pci->dev, &dev->slock, &dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED, V4L2_FIELD_INTERLACED,
sizeof(struct cx25821_buffer), sizeof(struct cx25821_buffer),
fh); fh);
dprintk(1, "post videobuf_queue_init()\n"); dprintk(1, "post videobuf_queue_init()\n");
unlock_kernel(); unlock_kernel();
@ -158,15 +158,15 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo
switch (fh->type) switch (fh->type)
{ {
case V4L2_BUF_TYPE_VIDEO_CAPTURE: case V4L2_BUF_TYPE_VIDEO_CAPTURE:
if (res_locked(fh->dev, RESOURCE_VIDEO_IOCTL)) if (res_locked(fh->dev, RESOURCE_VIDEO_IOCTL))
return -EBUSY; return -EBUSY;
return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK); return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK);
default: default:
BUG(); BUG();
return 0; return 0;
} }
} }
@ -176,21 +176,21 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait
struct cx25821_buffer *buf; struct cx25821_buffer *buf;
if (res_check(fh, RESOURCE_VIDEO_IOCTL)) { if (res_check(fh, RESOURCE_VIDEO_IOCTL)) {
/* streaming capture */ /* streaming capture */
if (list_empty(&fh->vidq.stream)) if (list_empty(&fh->vidq.stream))
return POLLERR; return POLLERR;
buf = list_entry(fh->vidq.stream.next, buf = list_entry(fh->vidq.stream.next,
struct cx25821_buffer, vb.stream); struct cx25821_buffer, vb.stream);
} else { } else {
/* read() capture */ /* read() capture */
buf = (struct cx25821_buffer *)fh->vidq.read_buf; buf = (struct cx25821_buffer *)fh->vidq.read_buf;
if (NULL == buf) if (NULL == buf)
return POLLERR; return POLLERR;
} }
poll_wait(file, &buf->vb.done, wait); poll_wait(file, &buf->vb.done, wait);
if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR) if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR)
return POLLIN|POLLRDNORM; return POLLIN|POLLRDNORM;
return 0; return 0;
} }
@ -203,13 +203,13 @@ static int video_release(struct file *file)
/* stop video capture */ /* stop video capture */
if (res_check(fh, RESOURCE_VIDEO_IOCTL)) { if (res_check(fh, RESOURCE_VIDEO_IOCTL)) {
videobuf_queue_cancel(&fh->vidq); videobuf_queue_cancel(&fh->vidq);
res_free(dev, fh, RESOURCE_VIDEO_IOCTL); res_free(dev, fh, RESOURCE_VIDEO_IOCTL);
} }
if (fh->vidq.read_buf) { if (fh->vidq.read_buf) {
buffer_release(&fh->vidq, fh->vidq.read_buf); buffer_release(&fh->vidq, fh->vidq.read_buf);
kfree(fh->vidq.read_buf); kfree(fh->vidq.read_buf);
} }
videobuf_mmap_free(&fh->vidq); videobuf_mmap_free(&fh->vidq);
@ -230,17 +230,17 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE))
{ {
return -EINVAL; return -EINVAL;
} }
if (unlikely(i != fh->type)) if (unlikely(i != fh->type))
{ {
return -EINVAL; return -EINVAL;
} }
if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO_IOCTL)))) if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO_IOCTL))))
{ {
return -EBUSY; return -EBUSY;
} }
return videobuf_streamon(get_queue(fh)); return videobuf_streamon(get_queue(fh));
@ -253,14 +253,14 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
int err, res; int err, res;
if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL; return -EINVAL;
if (i != fh->type) if (i != fh->type)
return -EINVAL; return -EINVAL;
res = get_resource(fh, RESOURCE_VIDEO_IOCTL); res = get_resource(fh, RESOURCE_VIDEO_IOCTL);
err = videobuf_streamoff(get_queue(fh)); err = videobuf_streamoff(get_queue(fh));
if (err < 0) if (err < 0)
return err; return err;
res_free(dev, fh, res); res_free(dev, fh, res);
return 0; return 0;
} }
@ -274,16 +274,16 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
if (fh) if (fh)
{ {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
dprintk(2, "%s()\n", __func__); dprintk(2, "%s()\n", __func__);
err = vidioc_try_fmt_vid_cap(file, priv, f); err = vidioc_try_fmt_vid_cap(file, priv, f);
if (0 != err) if (0 != err)
return err; return err;
fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat);
fh->width = f->fmt.pix.width; fh->width = f->fmt.pix.width;
fh->height = f->fmt.pix.height; fh->height = f->fmt.pix.height;
@ -315,89 +315,89 @@ static long video_ioctl_set(struct file *file, unsigned int cmd, unsigned long a
if( !data_from_user ) if( !data_from_user )
{ {
printk("cx25821 in %s(): User data is INVALID. Returning.\n", __func__); printk("cx25821 in %s(): User data is INVALID. Returning.\n", __func__);
return 0; return 0;
} }
command = data_from_user->command; command = data_from_user->command;
if( command != SET_VIDEO_STD && command != SET_PIXEL_FORMAT && command != ENABLE_CIF_RESOLUTION && if( command != SET_VIDEO_STD && command != SET_PIXEL_FORMAT && command != ENABLE_CIF_RESOLUTION &&
command != REG_READ && command != REG_WRITE && command != MEDUSA_READ && command != MEDUSA_WRITE) command != REG_READ && command != REG_WRITE && command != MEDUSA_READ && command != MEDUSA_WRITE)
{ {
return 0; return 0;
} }
switch(command) switch(command)
{ {
case SET_VIDEO_STD: case SET_VIDEO_STD:
dev->tvnorm = !strcmp(data_from_user->vid_stdname,"PAL") ? V4L2_STD_PAL_BG : V4L2_STD_NTSC_M; dev->tvnorm = !strcmp(data_from_user->vid_stdname,"PAL") ? V4L2_STD_PAL_BG : V4L2_STD_NTSC_M;
medusa_set_videostandard(dev); medusa_set_videostandard(dev);
break; break;
case SET_PIXEL_FORMAT: case SET_PIXEL_FORMAT:
selected_channel = data_from_user->decoder_select; selected_channel = data_from_user->decoder_select;
pix_format = data_from_user->pixel_format; pix_format = data_from_user->pixel_format;
if( !(selected_channel <= 7 && selected_channel >= 0) ) if( !(selected_channel <= 7 && selected_channel >= 0) )
{ {
selected_channel -= 4; selected_channel -= 4;
selected_channel = selected_channel % 8; selected_channel = selected_channel % 8;
} }
if( selected_channel >= 0 ) if( selected_channel >= 0 )
cx25821_set_pixel_format( dev, selected_channel, pix_format ); cx25821_set_pixel_format( dev, selected_channel, pix_format );
break; break;
case ENABLE_CIF_RESOLUTION: case ENABLE_CIF_RESOLUTION:
selected_channel = data_from_user->decoder_select; selected_channel = data_from_user->decoder_select;
cif_enable = data_from_user->cif_resolution_enable; cif_enable = data_from_user->cif_resolution_enable;
cif_width = data_from_user->cif_width; cif_width = data_from_user->cif_width;
if( cif_enable ) if( cif_enable )
{ {
if( dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK ) if( dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK )
width = 352; width = 352;
else else
width = (cif_width == 320 || cif_width == 352) ? cif_width : 320; width = (cif_width == 320 || cif_width == 352) ? cif_width : 320;
} }
if( !(selected_channel <= 7 && selected_channel >= 0) ) if( !(selected_channel <= 7 && selected_channel >= 0) )
{ {
selected_channel -= 4; selected_channel -= 4;
selected_channel = selected_channel % 8; selected_channel = selected_channel % 8;
} }
if( selected_channel <= 7 && selected_channel >= 0 ) if( selected_channel <= 7 && selected_channel >= 0 )
{ {
dev->use_cif_resolution[selected_channel] = cif_enable; dev->use_cif_resolution[selected_channel] = cif_enable;
dev->cif_width[selected_channel] = width; dev->cif_width[selected_channel] = width;
} }
else else
{ {
for( i=0; i < VID_CHANNEL_NUM; i++ ) for( i=0; i < VID_CHANNEL_NUM; i++ )
{ {
dev->use_cif_resolution[i] = cif_enable; dev->use_cif_resolution[i] = cif_enable;
dev->cif_width[i] = width; dev->cif_width[i] = width;
} }
} }
medusa_set_resolution( dev, width, selected_channel ); medusa_set_resolution( dev, width, selected_channel );
break; break;
case REG_READ: case REG_READ:
data_from_user->reg_data = cx_read(data_from_user->reg_address); data_from_user->reg_data = cx_read(data_from_user->reg_address);
break; break;
case REG_WRITE: case REG_WRITE:
cx_write(data_from_user->reg_address, data_from_user->reg_data); cx_write(data_from_user->reg_address, data_from_user->reg_data);
break; break;
case MEDUSA_READ: case MEDUSA_READ:
value = cx25821_i2c_read(&dev->i2c_bus[0], (u16)data_from_user->reg_address, &data_from_user->reg_data); value = cx25821_i2c_read(&dev->i2c_bus[0], (u16)data_from_user->reg_address, &data_from_user->reg_data);
break; break;
case MEDUSA_WRITE: case MEDUSA_WRITE:
cx25821_i2c_write(&dev->i2c_bus[0], (u16)data_from_user->reg_address, data_from_user->reg_data); cx25821_i2c_write(&dev->i2c_bus[0], (u16)data_from_user->reg_address, data_from_user->reg_data);
break; break;
} }
return 0; return 0;
@ -426,9 +426,9 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
if (fh) if (fh)
{ {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
return 0; return 0;

View File

@ -41,37 +41,37 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]); dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]);
if (!list_empty(&q->queued)) { if (!list_empty(&q->queued)) {
list_add_tail(&buf->vb.queue, &q->queued); list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED; buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i); dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i);
} else if (list_empty(&q->active)) { } else if (list_empty(&q->active)) {
list_add_tail(&buf->vb.queue, &q->active); list_add_tail(&buf->vb.queue, &q->active);
cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH10]); cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH10]);
buf->vb.state = VIDEOBUF_ACTIVE; buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++; buf->count = q->count++;
mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n", dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n",
buf, buf->vb. i, buf->count, q->count); buf, buf->vb. i, buf->count, q->count);
} else { } else {
prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue); prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue);
if (prev->vb.width == buf->vb.width && if (prev->vb.width == buf->vb.width &&
prev->vb.height == buf->vb.height && prev->vb.height == buf->vb.height &&
prev->fmt == buf->fmt) { prev->fmt == buf->fmt) {
list_add_tail(&buf->vb.queue, &q->active); list_add_tail(&buf->vb.queue, &q->active);
buf->vb.state = VIDEOBUF_ACTIVE; buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++; buf->count = q->count++;
prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
/* 64 bit bits 63-32 */ /* 64 bit bits 63-32 */
prev->risc.jmp[2] = cpu_to_le32(0); prev->risc.jmp[2] = cpu_to_le32(0);
dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count); dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count);
} else { } else {
list_add_tail(&buf->vb.queue, &q->queued); list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED; buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i); dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i);
} }
} }
if (list_empty(&q->active)) if (list_empty(&q->active))
@ -100,17 +100,17 @@ static int video_open(struct file *file)
lock_kernel(); lock_kernel();
list_for_each(list, &cx25821_devlist) list_for_each(list, &cx25821_devlist)
{ {
h = list_entry(list, struct cx25821_dev, devlist); h = list_entry(list, struct cx25821_dev, devlist);
if (h->video_dev[SRAM_CH10] && h->video_dev[SRAM_CH10]->minor == minor) { if (h->video_dev[SRAM_CH10] && h->video_dev[SRAM_CH10]->minor == minor) {
dev = h; dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE; type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
} }
} }
if (NULL == dev) { if (NULL == dev) {
unlock_kernel(); unlock_kernel();
return -ENODEV; return -ENODEV;
} }
printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
@ -118,8 +118,8 @@ static int video_open(struct file *file)
/* allocate + initialize per filehandle data */ /* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL); fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) { if (NULL == fh) {
unlock_kernel(); unlock_kernel();
return -ENOMEM; return -ENOMEM;
} }
file->private_data = fh; file->private_data = fh;
@ -128,9 +128,9 @@ static int video_open(struct file *file)
fh->width = 720; fh->width = 720;
if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK)
fh->height = 576; fh->height = 576;
else else
fh->height = 480; fh->height = 480;
dev->channel_opened = 9; dev->channel_opened = 9;
@ -139,11 +139,11 @@ static int video_open(struct file *file)
v4l2_prio_open(&dev->prio,&fh->prio); v4l2_prio_open(&dev->prio,&fh->prio);
videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops, videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops,
&dev->pci->dev, &dev->slock, &dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED, V4L2_FIELD_INTERLACED,
sizeof(struct cx25821_buffer), sizeof(struct cx25821_buffer),
fh); fh);
dprintk(1, "post videobuf_queue_init()\n"); dprintk(1, "post videobuf_queue_init()\n");
unlock_kernel(); unlock_kernel();
@ -157,15 +157,15 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo
switch (fh->type) switch (fh->type)
{ {
case V4L2_BUF_TYPE_VIDEO_CAPTURE: case V4L2_BUF_TYPE_VIDEO_CAPTURE:
if (res_locked(fh->dev, RESOURCE_VIDEO10)) if (res_locked(fh->dev, RESOURCE_VIDEO10))
return -EBUSY; return -EBUSY;
return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK); return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK);
default: default:
BUG(); BUG();
return 0; return 0;
} }
} }
@ -175,21 +175,21 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait
struct cx25821_buffer *buf; struct cx25821_buffer *buf;
if (res_check(fh, RESOURCE_VIDEO10)) { if (res_check(fh, RESOURCE_VIDEO10)) {
/* streaming capture */ /* streaming capture */
if (list_empty(&fh->vidq.stream)) if (list_empty(&fh->vidq.stream))
return POLLERR; return POLLERR;
buf = list_entry(fh->vidq.stream.next, buf = list_entry(fh->vidq.stream.next,
struct cx25821_buffer, vb.stream); struct cx25821_buffer, vb.stream);
} else { } else {
/* read() capture */ /* read() capture */
buf = (struct cx25821_buffer *)fh->vidq.read_buf; buf = (struct cx25821_buffer *)fh->vidq.read_buf;
if (NULL == buf) if (NULL == buf)
return POLLERR; return POLLERR;
} }
poll_wait(file, &buf->vb.done, wait); poll_wait(file, &buf->vb.done, wait);
if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR) if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR)
return POLLIN|POLLRDNORM; return POLLIN|POLLRDNORM;
return 0; return 0;
} }
@ -203,13 +203,13 @@ static int video_release(struct file *file)
/* stop video capture */ /* stop video capture */
if (res_check(fh, RESOURCE_VIDEO10)) { if (res_check(fh, RESOURCE_VIDEO10)) {
videobuf_queue_cancel(&fh->vidq); videobuf_queue_cancel(&fh->vidq);
res_free(dev, fh, RESOURCE_VIDEO10); res_free(dev, fh, RESOURCE_VIDEO10);
} }
if (fh->vidq.read_buf) { if (fh->vidq.read_buf) {
buffer_release(&fh->vidq, fh->vidq.read_buf); buffer_release(&fh->vidq, fh->vidq.read_buf);
kfree(fh->vidq.read_buf); kfree(fh->vidq.read_buf);
} }
videobuf_mmap_free(&fh->vidq); videobuf_mmap_free(&fh->vidq);
@ -230,17 +230,17 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE))
{ {
return -EINVAL; return -EINVAL;
} }
if (unlikely(i != fh->type)) if (unlikely(i != fh->type))
{ {
return -EINVAL; return -EINVAL;
} }
if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO10)))) if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO10))))
{ {
return -EBUSY; return -EBUSY;
} }
return videobuf_streamon(get_queue(fh)); return videobuf_streamon(get_queue(fh));
@ -253,14 +253,14 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
int err, res; int err, res;
if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL; return -EINVAL;
if (i != fh->type) if (i != fh->type)
return -EINVAL; return -EINVAL;
res = get_resource(fh, RESOURCE_VIDEO10); res = get_resource(fh, RESOURCE_VIDEO10);
err = videobuf_streamoff(get_queue(fh)); err = videobuf_streamoff(get_queue(fh));
if (err < 0) if (err < 0)
return err; return err;
res_free(dev, fh, res); res_free(dev, fh, res);
return 0; return 0;
} }
@ -278,15 +278,15 @@ static long video_ioctl_upstream10(struct file *file, unsigned int cmd, unsigned
if( !data_from_user ) if( !data_from_user )
{ {
printk("cx25821 in %s(): Upstream data is INVALID. Returning.\n", __func__); printk("cx25821 in %s(): Upstream data is INVALID. Returning.\n", __func__);
return 0; return 0;
} }
command = data_from_user->command; command = data_from_user->command;
if( command != UPSTREAM_START_VIDEO && command != UPSTREAM_STOP_VIDEO ) if( command != UPSTREAM_START_VIDEO && command != UPSTREAM_STOP_VIDEO )
{ {
return 0; return 0;
} }
dev->input_filename_ch2 = data_from_user->input_filename; dev->input_filename_ch2 = data_from_user->input_filename;
@ -299,13 +299,13 @@ static long video_ioctl_upstream10(struct file *file, unsigned int cmd, unsigned
switch(command) switch(command)
{ {
case UPSTREAM_START_VIDEO: case UPSTREAM_START_VIDEO:
cx25821_start_upstream_video_ch2(dev, data_from_user); cx25821_start_upstream_video_ch2(dev, data_from_user);
break; break;
case UPSTREAM_STOP_VIDEO: case UPSTREAM_STOP_VIDEO:
cx25821_stop_upstream_video_ch2(dev); cx25821_stop_upstream_video_ch2(dev);
break; break;
} }
return 0; return 0;
@ -320,16 +320,16 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
if (fh) if (fh)
{ {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
dprintk(2, "%s()\n", __func__); dprintk(2, "%s()\n", __func__);
err = vidioc_try_fmt_vid_cap(file, priv, f); err = vidioc_try_fmt_vid_cap(file, priv, f);
if (0 != err) if (0 != err)
return err; return err;
fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat);
fh->width = f->fmt.pix.width; fh->width = f->fmt.pix.width;
fh->height = f->fmt.pix.height; fh->height = f->fmt.pix.height;
@ -368,9 +368,9 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
if (fh) if (fh)
{ {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
return 0; return 0;

View File

@ -40,37 +40,37 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]); dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]);
if (!list_empty(&q->queued)) { if (!list_empty(&q->queued)) {
list_add_tail(&buf->vb.queue, &q->queued); list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED; buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i); dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i);
} else if (list_empty(&q->active)) { } else if (list_empty(&q->active)) {
list_add_tail(&buf->vb.queue, &q->active); list_add_tail(&buf->vb.queue, &q->active);
cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH09]); cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH09]);
buf->vb.state = VIDEOBUF_ACTIVE; buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++; buf->count = q->count++;
mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n", dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n",
buf, buf->vb. i, buf->count, q->count); buf, buf->vb. i, buf->count, q->count);
} else { } else {
prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue); prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue);
if (prev->vb.width == buf->vb.width && if (prev->vb.width == buf->vb.width &&
prev->vb.height == buf->vb.height && prev->vb.height == buf->vb.height &&
prev->fmt == buf->fmt) { prev->fmt == buf->fmt) {
list_add_tail(&buf->vb.queue, &q->active); list_add_tail(&buf->vb.queue, &q->active);
buf->vb.state = VIDEOBUF_ACTIVE; buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++; buf->count = q->count++;
prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
/* 64 bit bits 63-32 */ /* 64 bit bits 63-32 */
prev->risc.jmp[2] = cpu_to_le32(0); prev->risc.jmp[2] = cpu_to_le32(0);
dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count); dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count);
} else { } else {
list_add_tail(&buf->vb.queue, &q->queued); list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED; buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i); dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i);
} }
} }
if (list_empty(&q->active)) if (list_empty(&q->active))
@ -99,18 +99,18 @@ static int video_open(struct file *file)
lock_kernel(); lock_kernel();
list_for_each(list, &cx25821_devlist) list_for_each(list, &cx25821_devlist)
{ {
h = list_entry(list, struct cx25821_dev, devlist); h = list_entry(list, struct cx25821_dev, devlist);
if (h->video_dev[SRAM_CH09] && h->video_dev[SRAM_CH09]->minor == minor) if (h->video_dev[SRAM_CH09] && h->video_dev[SRAM_CH09]->minor == minor)
{ {
dev = h; dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE; type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
} }
} }
if (NULL == dev) { if (NULL == dev) {
unlock_kernel(); unlock_kernel();
return -ENODEV; return -ENODEV;
} }
printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
@ -118,8 +118,8 @@ static int video_open(struct file *file)
/* allocate + initialize per filehandle data */ /* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL); fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) { if (NULL == fh) {
unlock_kernel(); unlock_kernel();
return -ENOMEM; return -ENOMEM;
} }
file->private_data = fh; file->private_data = fh;
@ -128,9 +128,9 @@ static int video_open(struct file *file)
fh->width = 720; fh->width = 720;
if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK) if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK)
fh->height = 576; fh->height = 576;
else else
fh->height = 480; fh->height = 480;
dev->channel_opened = 8; dev->channel_opened = 8;
fh->fmt = format_by_fourcc(V4L2_PIX_FMT_YUYV); fh->fmt = format_by_fourcc(V4L2_PIX_FMT_YUYV);
@ -138,11 +138,11 @@ static int video_open(struct file *file)
v4l2_prio_open(&dev->prio,&fh->prio); v4l2_prio_open(&dev->prio,&fh->prio);
videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops, videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops,
&dev->pci->dev, &dev->slock, &dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED, V4L2_FIELD_INTERLACED,
sizeof(struct cx25821_buffer), sizeof(struct cx25821_buffer),
fh); fh);
dprintk(1, "post videobuf_queue_init()\n"); dprintk(1, "post videobuf_queue_init()\n");
unlock_kernel(); unlock_kernel();
@ -156,15 +156,15 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo
switch (fh->type) switch (fh->type)
{ {
case V4L2_BUF_TYPE_VIDEO_CAPTURE: case V4L2_BUF_TYPE_VIDEO_CAPTURE:
if (res_locked(fh->dev, RESOURCE_VIDEO9)) if (res_locked(fh->dev, RESOURCE_VIDEO9))
return -EBUSY; return -EBUSY;
return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK); return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK);
default: default:
BUG(); BUG();
return 0; return 0;
} }
} }
@ -174,21 +174,21 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait
struct cx25821_buffer *buf; struct cx25821_buffer *buf;
if (res_check(fh, RESOURCE_VIDEO9)) { if (res_check(fh, RESOURCE_VIDEO9)) {
/* streaming capture */ /* streaming capture */
if (list_empty(&fh->vidq.stream)) if (list_empty(&fh->vidq.stream))
return POLLERR; return POLLERR;
buf = list_entry(fh->vidq.stream.next, buf = list_entry(fh->vidq.stream.next,
struct cx25821_buffer, vb.stream); struct cx25821_buffer, vb.stream);
} else { } else {
/* read() capture */ /* read() capture */
buf = (struct cx25821_buffer *)fh->vidq.read_buf; buf = (struct cx25821_buffer *)fh->vidq.read_buf;
if (NULL == buf) if (NULL == buf)
return POLLERR; return POLLERR;
} }
poll_wait(file, &buf->vb.done, wait); poll_wait(file, &buf->vb.done, wait);
if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR) if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR)
return POLLIN|POLLRDNORM; return POLLIN|POLLRDNORM;
return 0; return 0;
} }
@ -203,13 +203,13 @@ static int video_release(struct file *file)
/* stop video capture */ /* stop video capture */
if (res_check(fh, RESOURCE_VIDEO9)) { if (res_check(fh, RESOURCE_VIDEO9)) {
videobuf_queue_cancel(&fh->vidq); videobuf_queue_cancel(&fh->vidq);
res_free(dev, fh, RESOURCE_VIDEO9); res_free(dev, fh, RESOURCE_VIDEO9);
} }
if (fh->vidq.read_buf) { if (fh->vidq.read_buf) {
buffer_release(&fh->vidq, fh->vidq.read_buf); buffer_release(&fh->vidq, fh->vidq.read_buf);
kfree(fh->vidq.read_buf); kfree(fh->vidq.read_buf);
} }
videobuf_mmap_free(&fh->vidq); videobuf_mmap_free(&fh->vidq);
@ -230,17 +230,17 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE))
{ {
return -EINVAL; return -EINVAL;
} }
if (unlikely(i != fh->type)) if (unlikely(i != fh->type))
{ {
return -EINVAL; return -EINVAL;
} }
if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO9)))) if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO9))))
{ {
return -EBUSY; return -EBUSY;
} }
return videobuf_streamon(get_queue(fh)); return videobuf_streamon(get_queue(fh));
@ -253,14 +253,14 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
int err, res; int err, res;
if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL; return -EINVAL;
if (i != fh->type) if (i != fh->type)
return -EINVAL; return -EINVAL;
res = get_resource(fh, RESOURCE_VIDEO9); res = get_resource(fh, RESOURCE_VIDEO9);
err = videobuf_streamoff(get_queue(fh)); err = videobuf_streamoff(get_queue(fh));
if (err < 0) if (err < 0)
return err; return err;
res_free(dev, fh, res); res_free(dev, fh, res);
return 0; return 0;
} }
@ -278,15 +278,15 @@ static long video_ioctl_upstream9(struct file *file, unsigned int cmd, unsigned
if( !data_from_user ) if( !data_from_user )
{ {
printk("cx25821 in %s(): Upstream data is INVALID. Returning.\n", __func__); printk("cx25821 in %s(): Upstream data is INVALID. Returning.\n", __func__);
return 0; return 0;
} }
command = data_from_user->command; command = data_from_user->command;
if( command != UPSTREAM_START_VIDEO && command != UPSTREAM_STOP_VIDEO ) if( command != UPSTREAM_START_VIDEO && command != UPSTREAM_STOP_VIDEO )
{ {
return 0; return 0;
} }
@ -300,13 +300,13 @@ static long video_ioctl_upstream9(struct file *file, unsigned int cmd, unsigned
switch(command) switch(command)
{ {
case UPSTREAM_START_VIDEO: case UPSTREAM_START_VIDEO:
cx25821_start_upstream_video_ch1(dev, data_from_user); cx25821_start_upstream_video_ch1(dev, data_from_user);
break; break;
case UPSTREAM_STOP_VIDEO: case UPSTREAM_STOP_VIDEO:
cx25821_stop_upstream_video_ch1(dev); cx25821_stop_upstream_video_ch1(dev);
break; break;
} }
return 0; return 0;
@ -321,16 +321,16 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
if (fh) if (fh)
{ {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
dprintk(2, "%s()\n", __func__); dprintk(2, "%s()\n", __func__);
err = vidioc_try_fmt_vid_cap(file, priv, f); err = vidioc_try_fmt_vid_cap(file, priv, f);
if (0 != err) if (0 != err)
return err; return err;
fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat);
fh->width = f->fmt.pix.width; fh->width = f->fmt.pix.width;
fh->height = f->fmt.pix.height; fh->height = f->fmt.pix.height;
@ -367,9 +367,9 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
int err; int err;
if (fh) if (fh)
{ {
err = v4l2_prio_check(&dev->prio, &fh->prio); err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err) if (0 != err)
return err; return err;
} }
return 0; return 0;

View File

@ -529,8 +529,8 @@ extern int cx25821_i2c_write(struct cx25821_i2c *bus, u16 reg_addr, int value);
extern int cx25821_i2c_unregister(struct cx25821_i2c *bus); extern int cx25821_i2c_unregister(struct cx25821_i2c *bus);
extern void cx25821_gpio_init(struct cx25821_dev *dev); extern void cx25821_gpio_init(struct cx25821_dev *dev);
extern void cx25821_set_gpiopin_direction( struct cx25821_dev *dev, extern void cx25821_set_gpiopin_direction( struct cx25821_dev *dev,
int pin_number, int pin_number,
int pin_logic_value); int pin_logic_value);
extern int medusa_video_init(struct cx25821_dev *dev); extern int medusa_video_init(struct cx25821_dev *dev);
extern int medusa_set_videostandard(struct cx25821_dev *dev); extern int medusa_set_videostandard(struct cx25821_dev *dev);
@ -543,18 +543,18 @@ extern int medusa_set_saturation(struct cx25821_dev *dev, int saturation, int d
extern int cx25821_sram_channel_setup(struct cx25821_dev *dev, struct sram_channel *ch, unsigned int bpl, u32 risc); extern int cx25821_sram_channel_setup(struct cx25821_dev *dev, struct sram_channel *ch, unsigned int bpl, u32 risc);
extern int cx25821_risc_buffer(struct pci_dev *pci, struct btcx_riscmem *risc, extern int cx25821_risc_buffer(struct pci_dev *pci, struct btcx_riscmem *risc,
struct scatterlist *sglist, struct scatterlist *sglist,
unsigned int top_offset, unsigned int top_offset,
unsigned int bottom_offset, unsigned int bottom_offset,
unsigned int bpl, unsigned int bpl,
unsigned int padding, unsigned int padding,
unsigned int lines); unsigned int lines);
extern int cx25821_risc_databuffer_audio(struct pci_dev *pci, extern int cx25821_risc_databuffer_audio(struct pci_dev *pci,
struct btcx_riscmem *risc, struct btcx_riscmem *risc,
struct scatterlist *sglist, struct scatterlist *sglist,
unsigned int bpl, unsigned int bpl,
unsigned int lines, unsigned int lines,
unsigned int lpi); unsigned int lpi);
extern void cx25821_free_buffer(struct videobuf_queue *q, struct cx25821_buffer *buf); extern void cx25821_free_buffer(struct videobuf_queue *q, struct cx25821_buffer *buf);
extern int cx25821_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc,u32 reg, u32 mask, u32 value); extern int cx25821_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc,u32 reg, u32 mask, u32 value);
extern void cx25821_sram_channel_dump(struct cx25821_dev *dev, struct sram_channel *ch); extern void cx25821_sram_channel_dump(struct cx25821_dev *dev, struct sram_channel *ch);
@ -565,8 +565,8 @@ extern struct cx25821_dev* cx25821_dev_get(struct pci_dev *pci);
extern void cx25821_print_irqbits(char *name, char *tag, char **strings, int len, u32 bits, u32 mask); extern void cx25821_print_irqbits(char *name, char *tag, char **strings, int len, u32 bits, u32 mask);
extern void cx25821_dev_unregister(struct cx25821_dev *dev); extern void cx25821_dev_unregister(struct cx25821_dev *dev);
extern int cx25821_sram_channel_setup_audio(struct cx25821_dev *dev, extern int cx25821_sram_channel_setup_audio(struct cx25821_dev *dev,
struct sram_channel *ch, struct sram_channel *ch,
unsigned int bpl, u32 risc); unsigned int bpl, u32 risc);
extern int cx25821_vidupstream_init_ch1(struct cx25821_dev *dev, int channel_select, int pixel_format); extern int cx25821_vidupstream_init_ch1(struct cx25821_dev *dev, 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_vidupstream_init_ch2(struct cx25821_dev *dev, int channel_select, int pixel_format);
@ -584,7 +584,7 @@ extern int cx25821_sram_channel_setup_upstream( struct cx25821_dev *dev, struct
extern void cx25821_set_pixel_format(struct cx25821_dev *dev, int channel, u32 format); extern void cx25821_set_pixel_format(struct cx25821_dev *dev, int channel, u32 format);
extern void cx25821_videoioctl_unregister(struct cx25821_dev *dev); extern void cx25821_videoioctl_unregister(struct cx25821_dev *dev);
extern struct video_device *cx25821_vdev_init(struct cx25821_dev *dev, extern struct video_device *cx25821_vdev_init(struct cx25821_dev *dev,
struct pci_dev *pci, struct pci_dev *pci,
struct video_device *template, struct video_device *template,
char *type); char *type);
#endif #endif