Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1a9fc855 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab
Browse files

V4L/DVB (12733): cx25821: some CodingStyle fixes



The original driver were generated with some dos editor, and used their
own coding style.

This patch does some automatic CodingStyle fixes, by running dos2unix
and Lindent tools.

More work still needs to be done for it to use upstream CodingStyle.

Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent bb4c9a74
Loading
Loading
Loading
Loading
+206 −207
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@
 *
 */


#include <linux/module.h>
#include <linux/init.h>
#include <linux/device.h>
@@ -37,7 +36,6 @@
#include <sound/initval.h>
#include <sound/tlv.h>


#include "cx25821.h"
#include "cx25821-reg.h"

@@ -49,12 +47,10 @@
#define dprintk_core(level,fmt, arg...)	if (debug >= level) \
	printk(KERN_DEBUG "%s/1: " fmt, chip->dev->name , ## arg)


/****************************************************************************
	Data type declarations - Can be moded to a header file later
 ****************************************************************************/


static struct snd_card *snd_cx25821_cards[SNDRV_CARDS];
static int devno;

@@ -87,7 +83,6 @@ struct cx25821_audio_dev {
typedef struct cx25821_audio_dev snd_cx25821_card_t;



/****************************************************************************
			Module global static vars
 ****************************************************************************/
@@ -102,7 +97,6 @@ MODULE_PARM_DESC(enable, "Enable cx25821 soundcard. default enabled.");
module_param_array(index, int, NULL, 0444);
MODULE_PARM_DESC(index, "Index value for cx25821 capture interface(s).");


/****************************************************************************
				Module macros
 ****************************************************************************/
@@ -144,17 +138,20 @@ static int _cx25821_start_audio_dma(snd_cx25821_card_t *chip)
{
	struct cx25821_buffer *buf = chip->buf;
	struct cx25821_dev *dev = chip->dev;
	struct sram_channel *audio_ch = &cx25821_sram_channels[AUDIO_SRAM_CHANNEL];
	struct sram_channel *audio_ch =
	    &cx25821_sram_channels[AUDIO_SRAM_CHANNEL];
	u32 tmp = 0;

	// enable output on the GPIO 0 for the MCLK ADC (Audio)
	cx25821_set_gpiopin_direction(chip->dev, 0, 0);

	/* Make sure RISC/FIFO are off before changing FIFO/RISC settings */
	cx_clear(AUD_INT_DMA_CTL, FLD_AUD_DST_A_RISC_EN | FLD_AUD_DST_A_FIFO_EN );
	cx_clear(AUD_INT_DMA_CTL,
		 FLD_AUD_DST_A_RISC_EN | FLD_AUD_DST_A_FIFO_EN);

	/* setup fifo + format - out channel */
	cx25821_sram_channel_setup_audio(chip->dev, audio_ch, buf->bpl, buf->risc.dma);
	cx25821_sram_channel_setup_audio(chip->dev, audio_ch, buf->bpl,
					 buf->risc.dma);

	/* sets bpl size */
	cx_write(AUD_A_LNGTH, buf->bpl);
@@ -165,15 +162,18 @@ static int _cx25821_start_audio_dma(snd_cx25821_card_t *chip)

	//Set the input mode to 16-bit
	tmp = cx_read(AUD_A_CFG);
    cx_write(AUD_A_CFG, tmp | FLD_AUD_DST_PK_MODE | FLD_AUD_DST_ENABLE | FLD_AUD_CLK_ENABLE);
	cx_write(AUD_A_CFG,
		 tmp | FLD_AUD_DST_PK_MODE | FLD_AUD_DST_ENABLE |
		 FLD_AUD_CLK_ENABLE);

	//printk(KERN_INFO "DEBUG: Start audio DMA, %d B/line, cmds_start(0x%x)= %d lines/FIFO, %d periods, %d "
	//      "byte buffer\n", buf->bpl, audio_ch->cmds_start, cx_read(audio_ch->cmds_start + 12)>>1,
	//      chip->num_periods, buf->bpl * chip->num_periods);


	/* Enables corresponding bits at AUD_INT_STAT */
	cx_write(AUD_A_INT_MSK, FLD_AUD_DST_RISCI1 | FLD_AUD_DST_OF | FLD_AUD_DST_SYNC | FLD_AUD_DST_OPC_ERR );
	cx_write(AUD_A_INT_MSK,
		 FLD_AUD_DST_RISCI1 | FLD_AUD_DST_OF | FLD_AUD_DST_SYNC |
		 FLD_AUD_DST_OPC_ERR);

	/* Clean any pending interrupt bits already set */
	cx_write(AUD_A_INT_STAT, ~0);
@@ -183,7 +183,8 @@ static int _cx25821_start_audio_dma(snd_cx25821_card_t *chip)

	// Turn on audio downstream fifo and risc enable 0x101
	tmp = cx_read(AUD_INT_DMA_CTL);
	cx_set(AUD_INT_DMA_CTL, tmp | (FLD_AUD_DST_A_RISC_EN | FLD_AUD_DST_A_FIFO_EN) );
	cx_set(AUD_INT_DMA_CTL,
	       tmp | (FLD_AUD_DST_A_RISC_EN | FLD_AUD_DST_A_FIFO_EN));

	mdelay(100);
	return 0;
@@ -197,11 +198,14 @@ static int _cx25821_stop_audio_dma(snd_cx25821_card_t *chip)
	struct cx25821_dev *dev = chip->dev;

	/* stop dma */
	cx_clear(AUD_INT_DMA_CTL,  FLD_AUD_DST_A_RISC_EN | FLD_AUD_DST_A_FIFO_EN );
	cx_clear(AUD_INT_DMA_CTL,
		 FLD_AUD_DST_A_RISC_EN | FLD_AUD_DST_A_FIFO_EN);

	/* disable irqs */
	cx_clear(PCI_INT_MSK, PCI_MSK_AUD_INT);
	cx_clear(AUD_A_INT_MSK, AUD_INT_OPC_ERR | AUD_INT_DN_SYNC |	AUD_INT_DN_RISCI2 | AUD_INT_DN_RISCI1);
	cx_clear(AUD_A_INT_MSK,
		 AUD_INT_OPC_ERR | AUD_INT_DN_SYNC | AUD_INT_DN_RISCI2 |
		 AUD_INT_DN_RISCI1);

	return 0;
}
@@ -231,31 +235,35 @@ static void cx25821_aud_irq(snd_cx25821_card_t *chip, u32 status, u32 mask)
{
	struct cx25821_dev *dev = chip->dev;

	if (0 == (status & mask))
	{
	if (0 == (status & mask)) {
		return;
	}

	cx_write(AUD_A_INT_STAT, status);
	if (debug > 1 || (status & mask & ~0xff))
		cx25821_print_irqbits(dev->name, "irq aud",
				   cx25821_aud_irqs, ARRAY_SIZE(cx25821_aud_irqs),
				   status, mask);
				      cx25821_aud_irqs,
				      ARRAY_SIZE(cx25821_aud_irqs), status,
				      mask);

	/* risc op code error */
	if (status & AUD_INT_OPC_ERR) {
		printk(KERN_WARNING "WARNING %s/1: Audio risc op code error\n",dev->name);
		printk(KERN_WARNING "WARNING %s/1: Audio risc op code error\n",
		       dev->name);

		cx_clear(AUD_INT_DMA_CTL, FLD_AUD_DST_A_RISC_EN | FLD_AUD_DST_A_FIFO_EN );
		cx25821_sram_channel_dump_audio(dev, &cx25821_sram_channels[AUDIO_SRAM_CHANNEL]);
		cx_clear(AUD_INT_DMA_CTL,
			 FLD_AUD_DST_A_RISC_EN | FLD_AUD_DST_A_FIFO_EN);
		cx25821_sram_channel_dump_audio(dev,
						&cx25821_sram_channels
						[AUDIO_SRAM_CHANNEL]);
	}
	if (status & AUD_INT_DN_SYNC) {
		printk(KERN_WARNING "WARNING %s: Downstream sync error!\n",dev->name);
		printk(KERN_WARNING "WARNING %s: Downstream sync error!\n",
		       dev->name);
		cx_write(AUD_A_GPCNT_CTL, GP_COUNT_CONTROL_RESET);
		return;
	}


	/* risc1 downstream */
	if (status & AUD_INT_DN_RISCI1) {
		atomic_set(&chip->count, cx_read(AUD_A_GPCNT));
@@ -263,7 +271,6 @@ static void cx25821_aud_irq(snd_cx25821_card_t *chip, u32 status, u32 mask)
	}
}


/*
 * BOARD Specific: Handles IRQ calls
 */
@@ -276,30 +283,26 @@ static irqreturn_t cx25821_irq(int irq, void *dev_id)
	int loop, handled = 0;
	int audint_count = 0;


	audint_status = cx_read(AUD_A_INT_STAT);
	audint_mask = cx_read(AUD_A_INT_MSK);
	audint_count = cx_read(AUD_A_GPCNT);
	status = cx_read(PCI_INT_STAT);

	for (loop = 0; loop < 1; loop++)
	{
	for (loop = 0; loop < 1; loop++) {
		status = cx_read(PCI_INT_STAT);
		if (0 == status)
		{
		if (0 == status) {
			status = cx_read(PCI_INT_STAT);
			audint_status = cx_read(AUD_A_INT_STAT);
			audint_mask = cx_read(AUD_A_INT_MSK);

			if (status)
			{
			if (status) {
				handled = 1;
				cx_write(PCI_INT_STAT, status);

				cx25821_aud_irq(chip, audint_status, audint_mask);
				cx25821_aud_irq(chip, audint_status,
						audint_mask);
				break;
			}
			else
			} else
				goto out;
		}

@@ -318,7 +321,6 @@ static irqreturn_t cx25821_irq(int irq, void *dev_id)
	return IRQ_RETVAL(handled);
}


static int dsp_buffer_free(snd_cx25821_card_t * chip)
{
	BUG_ON(!chip->dma_size);
@@ -346,8 +348,7 @@ static int dsp_buffer_free(snd_cx25821_card_t *chip)
static struct snd_pcm_hardware snd_cx25821_digital_hw = {
	.info = SNDRV_PCM_INFO_MMAP |
	    SNDRV_PCM_INFO_INTERLEAVED |
		SNDRV_PCM_INFO_BLOCK_TRANSFER |
		SNDRV_PCM_INFO_MMAP_VALID,
	    SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP_VALID,
	.formats = SNDRV_PCM_FMTBIT_S16_LE,

	.rates = SNDRV_PCM_RATE_48000,
@@ -364,8 +365,6 @@ static struct snd_pcm_hardware snd_cx25821_digital_hw = {
	.buffer_bytes_max = (AUDIO_LINE_SIZE * AUDIO_LINE_SIZE),	//128*128 = 16384 = 1024 * 16
};



/*
 * audio pcm capture open callback
 */
@@ -382,7 +381,8 @@ static int snd_cx25821_pcm_open(struct snd_pcm_substream *substream)
		return -ENODEV;
	}

	err = snd_pcm_hw_constraint_pow2(runtime, 0, SNDRV_PCM_HW_PARAM_PERIODS);
	err =
	    snd_pcm_hw_constraint_pow2(runtime, 0, SNDRV_PCM_HW_PARAM_PERIODS);
	if (err < 0)
		goto _error;

@@ -390,13 +390,12 @@ static int snd_cx25821_pcm_open(struct snd_pcm_substream *substream)

	runtime->hw = snd_cx25821_digital_hw;

	if (cx25821_sram_channels[AUDIO_SRAM_CHANNEL].fifo_size != DEFAULT_FIFO_SIZE)
	{
	if (cx25821_sram_channels[AUDIO_SRAM_CHANNEL].fifo_size !=
	    DEFAULT_FIFO_SIZE) {
		bpl = cx25821_sram_channels[AUDIO_SRAM_CHANNEL].fifo_size / 3;	//since there are 3 audio Clusters
		bpl &= ~7;	/* must be multiple of 8 */

		if( bpl > AUDIO_LINE_SIZE )
		{
		if (bpl > AUDIO_LINE_SIZE) {
			bpl = AUDIO_LINE_SIZE;
		}
		runtime->hw.period_bytes_min = bpl;
@@ -434,7 +433,6 @@ static int snd_cx25821_hw_params(struct snd_pcm_substream * substream,
		substream->runtime->dma_area = NULL;
	}


	chip->period_size = params_period_bytes(hw_params);
	chip->num_periods = params_periods(hw_params);
	chip->dma_size = chip->period_size * params_periods(hw_params);
@@ -446,13 +444,10 @@ static int snd_cx25821_hw_params(struct snd_pcm_substream * substream,
	if (NULL == buf)
		return -ENOMEM;


	if( chip->period_size > AUDIO_LINE_SIZE )
	{
	if (chip->period_size > AUDIO_LINE_SIZE) {
		chip->period_size = AUDIO_LINE_SIZE;
	}


	buf->vb.memory = V4L2_MEMORY_MMAP;
	buf->vb.field = V4L2_FIELD_NONE;
	buf->vb.width = chip->period_size;
@@ -464,7 +459,8 @@ static int snd_cx25821_hw_params(struct snd_pcm_substream * substream,
	videobuf_dma_init(dma);

	ret = videobuf_dma_init_kernel(dma, PCI_DMA_FROMDEVICE,
			(PAGE_ALIGN(buf->vb.size) >> PAGE_SHIFT));
				       (PAGE_ALIGN(buf->vb.size) >>
					PAGE_SHIFT));
	if (ret < 0)
		goto error;

@@ -472,15 +468,15 @@ static int snd_cx25821_hw_params(struct snd_pcm_substream * substream,
	if (ret < 0)
		goto error;


	ret = cx25821_risc_databuffer_audio(chip->pci, &buf->risc, dma->sglist,  buf->vb.width, buf->vb.height, 1);
	if (ret < 0)
	{
		printk(KERN_INFO "DEBUG: ERROR after cx25821_risc_databuffer_audio() \n");
	ret =
	    cx25821_risc_databuffer_audio(chip->pci, &buf->risc, dma->sglist,
					  buf->vb.width, buf->vb.height, 1);
	if (ret < 0) {
		printk(KERN_INFO
		       "DEBUG: ERROR after cx25821_risc_databuffer_audio() \n");
		goto error;
	}


	/* Loop back to start of program */
	buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP | RISC_IRQ1 | RISC_CNT_INC);
	buf->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
@@ -528,7 +524,8 @@ static int snd_cx25821_prepare(struct snd_pcm_substream *substream)
/*
 * trigger callback
 */
static int snd_cx25821_card_trigger(struct snd_pcm_substream *substream, int cmd)
static int snd_cx25821_card_trigger(struct snd_pcm_substream *substream,
				    int cmd)
{
	snd_cx25821_card_t *chip = snd_pcm_substream_chip(substream);
	int err = 0;
@@ -536,8 +533,7 @@ static int snd_cx25821_card_trigger(struct snd_pcm_substream *substream, int cmd
	/* Local interrupts are already disabled by ALSA */
	spin_lock(&chip->reg_lock);

	switch (cmd)
	{
	switch (cmd) {
	case SNDRV_PCM_TRIGGER_START:
		err = _cx25821_start_audio_dma(chip);
		break;
@@ -557,7 +553,8 @@ static int snd_cx25821_card_trigger(struct snd_pcm_substream *substream, int cmd
/*
 * pointer callback
 */
static snd_pcm_uframes_t snd_cx25821_pointer(struct snd_pcm_substream *substream)
static snd_pcm_uframes_t snd_cx25821_pointer(struct snd_pcm_substream
					     *substream)
{
	snd_cx25821_card_t *chip = snd_pcm_substream_chip(substream);
	struct snd_pcm_runtime *runtime = substream->runtime;
@@ -594,7 +591,6 @@ static struct snd_pcm_ops snd_cx25821_pcm_ops = {
	.page = snd_cx25821_page,
};


/*
 * ALSA create a PCM device:  Called when initializing the board. Sets up the name and hooks up
 *  the callbacks
@@ -605,9 +601,9 @@ static int snd_cx25821_pcm(snd_cx25821_card_t *chip, int device, char *name)
	int err;

	err = snd_pcm_new(chip->card, name, device, 0, 1, &pcm);
	if (err < 0)
	{
		printk(KERN_INFO "ERROR: FAILED snd_pcm_new() in %s\n", __func__);
	if (err < 0) {
		printk(KERN_INFO "ERROR: FAILED snd_pcm_new() in %s\n",
		       __func__);
		return err;
	}
	pcm->private_data = chip;
@@ -618,7 +614,6 @@ static int snd_cx25821_pcm(snd_cx25821_card_t *chip, int device, char *name)
	return 0;
}


/****************************************************************************
			Basic Flow for Sound Devices
 ****************************************************************************/
@@ -632,6 +627,7 @@ static struct pci_device_id cx25821_audio_pci_tbl[] __devinitdata = {
	{0x14f1, 0x0920, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
	{0,}
};

MODULE_DEVICE_TABLE(pci, cx25821_audio_pci_tbl);

/*
@@ -662,7 +658,6 @@ static void snd_cx25821_dev_free(struct snd_card * card)
	snd_card_free(chip->card);
}


/*
 * Alsa Constructor - Component probe
 */
@@ -672,9 +667,9 @@ static int cx25821_audio_initdev(struct cx25821_dev *dev)
	snd_cx25821_card_t *chip;
	int err;

	if (devno >= SNDRV_CARDS)
	{
	    printk(KERN_INFO "DEBUG ERROR: devno >= SNDRV_CARDS %s\n", __func__);
	if (devno >= SNDRV_CARDS) {
		printk(KERN_INFO "DEBUG ERROR: devno >= SNDRV_CARDS %s\n",
		       __func__);
		return (-ENODEV);
	}

@@ -684,10 +679,13 @@ static int cx25821_audio_initdev(struct cx25821_dev *dev)
		return (-ENOENT);
	}

	card = snd_card_new(index[devno], id[devno], THIS_MODULE, sizeof(snd_cx25821_card_t));
	if (!card)
	{
	    printk(KERN_INFO "DEBUG ERROR: cannot create snd_card_new in %s\n", __func__);
	card =
	    snd_card_new(index[devno], id[devno], THIS_MODULE,
			 sizeof(snd_cx25821_card_t));
	if (!card) {
		printk(KERN_INFO
		       "DEBUG ERROR: cannot create snd_card_new in %s\n",
		       __func__);
		return (-ENOMEM);
	}

@@ -703,37 +701,38 @@ static int cx25821_audio_initdev(struct cx25821_dev *dev)
	chip->pci = dev->pci;
	chip->iobase = pci_resource_start(dev->pci, 0);


	chip->irq = dev->pci->irq;

	err = request_irq(dev->pci->irq, cx25821_irq,
			  IRQF_SHARED | IRQF_DISABLED, chip->dev->name, chip);

	if (err < 0) {
		printk(KERN_ERR "ERROR %s: can't get IRQ %d for ALSA\n", chip->dev->name, dev->pci->irq);
		printk(KERN_ERR "ERROR %s: can't get IRQ %d for ALSA\n",
		       chip->dev->name, dev->pci->irq);
		goto error;
	}


	if ((err = snd_cx25821_pcm(chip, 0, "cx25821 Digital")) < 0)
	{
	    printk(KERN_INFO "DEBUG ERROR: cannot create snd_cx25821_pcm %s\n", __func__);
	if ((err = snd_cx25821_pcm(chip, 0, "cx25821 Digital")) < 0) {
		printk(KERN_INFO
		       "DEBUG ERROR: cannot create snd_cx25821_pcm %s\n",
		       __func__);
		goto error;
	}

	snd_card_set_dev(card, &chip->pci->dev);


	strcpy(card->shortname, "cx25821");
	sprintf(card->longname, "%s at 0x%lx irq %d", chip->dev->name, chip->iobase, chip->irq);
	sprintf(card->longname, "%s at 0x%lx irq %d", chip->dev->name,
		chip->iobase, chip->irq);
	strcpy(card->mixername, "CX25821");

	printk(KERN_INFO "%s/%i: ALSA support for cx25821 boards\n", card->driver, devno);
	printk(KERN_INFO "%s/%i: ALSA support for cx25821 boards\n",
	       card->driver, devno);

	err = snd_card_register(card);
	if (err < 0)
	{
	    printk(KERN_INFO "DEBUG ERROR: cannot register sound card %s\n", __func__);
	if (err < 0) {
		printk(KERN_INFO "DEBUG ERROR: cannot register sound card %s\n",
		       __func__);
		goto error;
	}

@@ -747,7 +746,6 @@ static int cx25821_audio_initdev(struct cx25821_dev *dev)
	return err;
}


/****************************************************************************
				LINUX MODULE INIT
 ****************************************************************************/
@@ -774,7 +772,8 @@ static int cx25821_alsa_init(void)
	}

	if (dev == NULL)
		printk(KERN_INFO "cx25821 ERROR ALSA: no cx25821 cards found\n");
		printk(KERN_INFO
		       "cx25821 ERROR ALSA: no cx25821 cards found\n");

	return 0;

+804 −824

File changed.

Preview size limit exceeded, changes collapsed.

+57 −62
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@
#include <linux/mutex.h>
#include <linux/workqueue.h>


#define NUM_AUDIO_PROGS       8
#define NUM_AUDIO_FRAMES      8
#define END_OF_FILE           0
@@ -33,7 +32,6 @@
#define FIFO_ENABLE           1
#define NUM_NO_OPS            4


#define RISC_READ_INSTRUCTION_SIZE      12
#define RISC_JUMP_INSTRUCTION_SIZE      12
#define RISC_WRITECR_INSTRUCTION_SIZE   16
@@ -41,7 +39,6 @@
#define DWORD_SIZE                      4
#define AUDIO_SYNC_LINE                 4


#define LINES_PER_AUDIO_BUFFER      15
#define AUDIO_LINE_SIZE             128
#define AUDIO_DATA_BUF_SZ           (AUDIO_LINE_SIZE * LINES_PER_AUDIO_BUFFER)
@@ -52,11 +49,9 @@
#define AUDIO_RISC_DMA_BUF_SIZE    ( LINES_PER_AUDIO_BUFFER*RISC_READ_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + NUM_NO_OPS*DWORD_SIZE + RISC_JUMP_INSTRUCTION_SIZE)
#endif


#ifndef USE_RISC_NOOP_AUDIO
#define AUDIO_RISC_DMA_BUF_SIZE    ( LINES_PER_AUDIO_BUFFER*RISC_READ_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + RISC_JUMP_INSTRUCTION_SIZE)
#endif

static int _line_size;
char *_defaultAudioName = "/root/audioGOOD.wav";
    
+57 −60
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@
#ifndef __CX25821_AUDIO_H__
#define __CX25821_AUDIO_H__


#define USE_RISC_NOOP               1
#define LINES_PER_BUFFER            15
#define AUDIO_LINE_SIZE             128
@@ -45,7 +44,6 @@
    (2*LINES_PER_BUFFER*RISC_WRITE_INSTRUCTION_SIZE + RISC_NOOP_INSTRUCTION_SIZE*4)
#endif


//Sizes of various instructions in bytes.  Used when adding instructions.
#define RISC_WRITE_INSTRUCTION_SIZE 12
#define RISC_JUMP_INSTRUCTION_SIZE  12
@@ -57,4 +55,3 @@
#define MAX_AUDIO_DMA_BUFFER_SIZE (MAX_BUFFER_PROGRAM_SIZE * NUMBER_OF_PROGRAMS + RISC_SYNC_INSTRUCTION_SIZE)

#endif
+304 −311
Original line number Diff line number Diff line
@@ -23,10 +23,10 @@

#include "cx25821-video.h"


static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
{
    struct cx25821_buffer   *buf = container_of(vb, struct cx25821_buffer, vb);
	struct cx25821_buffer *buf =
	    container_of(vb, struct cx25821_buffer, vb);
	struct cx25821_buffer *prev;
	struct cx25821_fh *fh = vq->priv_data;
	struct cx25821_dev *dev = fh->dev;
@@ -42,21 +42,25 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
	if (!list_empty(&q->queued)) {
		list_add_tail(&buf->vb.queue, &q->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)) {
		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->count = q->count++;
		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);
	} else {
	prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue);
	if (prev->vb.width  == buf->vb.width  &&
	    prev->vb.height == buf->vb.height &&
	    prev->fmt       == buf->fmt) {
		prev =
		    list_entry(q->active.prev, struct cx25821_buffer, vb.queue);
		if (prev->vb.width == buf->vb.width
		    && prev->vb.height == buf->vb.height
		    && prev->fmt == buf->fmt) {
			list_add_tail(&buf->vb.queue, &q->active);
			buf->vb.state = VIDEOBUF_ACTIVE;
			buf->count = q->count++;
@@ -64,22 +68,23 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)

			/* 64 bit bits 63-32 */
			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 {
			list_add_tail(&buf->vb.queue, &q->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)) {
		dprintk(2, "active queue empty!\n");
	}
}


static struct videobuf_queue_ops cx25821_video_qops = {
	.buf_setup = buffer_setup,
	.buf_prepare = buffer_prepare,
@@ -87,7 +92,6 @@ static struct videobuf_queue_ops cx25821_video_qops = {
	.buf_release = buffer_release,
};


static int video_open(struct file *file)
{
	int minor = video_devdata(file)->minor;
@@ -97,12 +101,11 @@ static int video_open(struct file *file)
	enum v4l2_buf_type type = 0;

	lock_kernel();
    list_for_each(list, &cx25821_devlist)
    {
	list_for_each(list, &cx25821_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;
			type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
		}
@@ -141,8 +144,7 @@ static int video_open(struct file *file)
			       &dev->pci->dev, &dev->slock,
			       V4L2_BUF_TYPE_VIDEO_CAPTURE,
			       V4L2_FIELD_INTERLACED,
		sizeof(struct cx25821_buffer),
		fh);
			       sizeof(struct cx25821_buffer), fh);

	dprintk(1, "post videobuf_queue_init()\n");
	unlock_kernel();
@@ -150,17 +152,18 @@ static int video_open(struct file *file)
	return 0;
}

static ssize_t video_read(struct file *file, char __user *data, size_t count, loff_t *ppos)
static ssize_t video_read(struct file *file, char __user * data, size_t count,
			  loff_t * ppos)
{
	struct cx25821_fh *fh = file->private_data;

    switch (fh->type)
    {
	switch (fh->type) {
	case V4L2_BUF_TYPE_VIDEO_CAPTURE:
		if (res_locked(fh->dev, RESOURCE_VIDEO11))
			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:
		BUG();
@@ -168,7 +171,8 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo
	}
}

static unsigned int video_poll(struct file *file, struct poll_table_struct *wait)
static unsigned int video_poll(struct file *file,
			       struct poll_table_struct *wait)
{
	struct cx25821_fh *fh = file->private_data;
	struct cx25821_buffer *buf;
@@ -192,7 +196,6 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait
	return 0;
}


static int video_release(struct file *file)
{
	struct cx25821_fh *fh = file->private_data;
@@ -222,24 +225,20 @@ static int video_release(struct file *file)
	return 0;
}


static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
{
	struct cx25821_fh *fh = priv;
	struct cx25821_dev *dev = fh->dev;

    if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE))
    {
	if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) {
		return -EINVAL;
	}

    if (unlikely(i != fh->type))
    {
	if (unlikely(i != fh->type)) {
		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;
	}

@@ -265,15 +264,14 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
	return 0;
}


static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_format *f)
static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
				struct v4l2_format *f)
{
	struct cx25821_fh *fh = priv;
	struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
	int err;

    if (fh)
    {
	if (fh) {
		err = v4l2_prio_check(&dev->prio, &fh->prio);
		if (0 != err)
			return err;
@@ -288,35 +286,35 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
	fh->width = f->fmt.pix.width;
	fh->height = f->fmt.pix.height;
	fh->vidq.field = f->fmt.pix.field;
    dprintk(2, "%s() width=%d height=%d field=%d\n", __func__, fh->width, fh->height, fh->vidq.field);
	dprintk(2, "%s() width=%d height=%d field=%d\n", __func__, fh->width,
		fh->height, fh->vidq.field);
	cx25821_call_all(dev, video, s_fmt, f);
	return 0;
}

static long video_ioctl_upstream11(struct file *file, unsigned int cmd, unsigned long arg)
static long video_ioctl_upstream11(struct file *file, unsigned int cmd,
				   unsigned long arg)
{
	struct cx25821_fh *fh = file->private_data;
	struct cx25821_dev *dev = fh->dev;
	int command = 0;
	struct upstream_user_struct *data_from_user;


	data_from_user = (struct upstream_user_struct *)arg;

    if( !data_from_user )
    {
	printk("cx25821 in %s(): Upstream data is INVALID. Returning.\n", __func__);
	if (!data_from_user) {
		printk
		    ("cx25821 in %s(): Upstream data is INVALID. Returning.\n",
		     __func__);
		return 0;
	}

	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;
	}


	dev->input_filename = data_from_user->input_filename;
	dev->input_audiofilename = data_from_user->input_filename;
	dev->vid_stdname = data_from_user->vid_stdname;
@@ -324,9 +322,7 @@ static long video_ioctl_upstream11(struct file *file, unsigned int cmd, unsigned
	dev->channel_select = data_from_user->channel_select;
	dev->command = data_from_user->command;


    switch(command)
    {
	switch (command) {
	case UPSTREAM_START_AUDIO:
		cx25821_start_upstream_audio(dev, data_from_user);
		break;
@@ -366,14 +362,14 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
	struct cx25821_dev *dev = fh->dev;
	int err;

    if (fh)
    {
	if (fh) {
		err = v4l2_prio_check(&dev->prio, &fh->prio);
		if (0 != err)
			return err;
	}
	return 0;
}

// exported stuff
static const struct v4l2_file_operations video_fops = {
	.owner = THIS_MODULE,
@@ -436,6 +432,3 @@ struct video_device cx25821_video_template11 = {
	.tvnorms = CX25821_NORMS,
	.current_norm = V4L2_STD_NTSC_M,
};


Loading