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

Commit cde4362f authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab
Browse files

V4L/DVB (10956): cx231xx: First series of manual CodingStyle fixes



This patch cleans up CodingStyle on the following source files:

There are still much more to be fixed on later patches

Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 84b5dbf3
Loading
Loading
Loading
Loading
+15 −22
Original line number Diff line number Diff line
@@ -70,7 +70,6 @@ static int cx231xx_isoc_audio_deinit(struct cx231xx *dev)

			kfree(dev->adev.transfer_buffer[i]);
			dev->adev.transfer_buffer[i] = NULL;

		}
	}

@@ -108,8 +107,8 @@ static void cx231xx_audio_isocirq(struct urb *urb)
		stride = runtime->frame_bits >> 3;

		for (i = 0; i < urb->number_of_packets; i++) {
			int length =
			    urb->iso_frame_desc[i].actual_length / stride;
			int length = urb->iso_frame_desc[i].actual_length /
				     stride;
			cp = (unsigned char *)urb->transfer_buffer +
					      urb->iso_frame_desc[i].offset;

@@ -118,8 +117,9 @@ static void cx231xx_audio_isocirq(struct urb *urb)

			oldptr = dev->adev.hwptr_done_capture;
			if (oldptr + length >= runtime->buffer_size) {
				unsigned int cnt =
				    runtime->buffer_size - oldptr;
				unsigned int cnt;

				cnt = runtime->buffer_size - oldptr;
				memcpy(runtime->dma_area + oldptr * stride, cp,
				       cnt * stride);
				memcpy(runtime->dma_area, cp + cnt * stride,
@@ -132,16 +132,12 @@ static void cx231xx_audio_isocirq(struct urb *urb)
			snd_pcm_stream_lock(substream);

			dev->adev.hwptr_done_capture += length;
			if (dev->adev.hwptr_done_capture >=
			    runtime->buffer_size)
				dev->adev.hwptr_done_capture -=
				    runtime->buffer_size;
			if (dev->adev.hwptr_done_capture >= runtime->buffer_size)
				dev->adev.hwptr_done_capture -= runtime->buffer_size;

			dev->adev.capture_transfer_done += length;
			if (dev->adev.capture_transfer_done >=
			    runtime->period_size) {
				dev->adev.capture_transfer_done -=
				    runtime->period_size;
			if (dev->adev.capture_transfer_done >= runtime->period_size) {
				dev->adev.capture_transfer_done -= runtime->period_size;
				period_elapsed = 1;
			}
			snd_pcm_stream_unlock(substream);
@@ -189,8 +185,7 @@ static int cx231xx_init_audio_isoc(struct cx231xx *dev)

		urb->dev = dev->udev;
		urb->context = dev;
		urb->pipe =
		    usb_rcvisocpipe(dev->udev, dev->adev.end_point_addr);
		urb->pipe = usb_rcvisocpipe(dev->udev, dev->adev.end_point_addr);
		urb->transfer_flags = URB_ISO_ASAP;
		urb->transfer_buffer = dev->adev.transfer_buffer[i];
		urb->interval = 1;
@@ -198,8 +193,7 @@ static int cx231xx_init_audio_isoc(struct cx231xx *dev)
		urb->number_of_packets = CX231XX_NUM_AUDIO_PACKETS;
		urb->transfer_buffer_length = sb_size;

		for (j = k = 0; j < CX231XX_NUM_AUDIO_PACKETS;
		     j++, k += dev->adev.max_pkt_size) {
		for (j = k = 0; j < CX231XX_NUM_AUDIO_PACKETS; j++, k += dev->adev.max_pkt_size) {
			urb->iso_frame_desc[j].offset = k;
			urb->iso_frame_desc[j].length = dev->adev.max_pkt_size;
		}
@@ -477,9 +471,8 @@ static int cx231xx_audio_init(struct cx231xx *dev)
		     "non standard usbaudio\n");

	card = snd_card_new(index[devnr], "Cx231xx Audio", THIS_MODULE, 0);
	if (card == NULL) {
	if (card == NULL)
		return -ENOMEM;
	}

	spin_lock_init(&adev->slock);
	err = snd_pcm_new(card, "Cx231xx Audio", 0, 0, 1, &pcm);
+886 −1221

File changed.

Preview size limit exceeded, changes collapsed.

+39 −47
Original line number Diff line number Diff line
@@ -109,25 +109,27 @@ static inline int cx231xx_isoc_vbi_copy(struct cx231xx *dev, struct urb *urb)
	buffer_size = urb->actual_length;

	if (buffer_size > 0) {

		bytes_parsed = 0;

		if (dma_q->is_partial_line) {
			/* Handle the case where we were working on a partial line */
			/* Handle the case where we were working on a partial
			   line */
			sav_eav = dma_q->last_sav;
		} else {
			/* Check for a SAV/EAV overlapping the buffer boundary */
			sav_eav =
			    cx231xx_find_boundary_SAV_EAV(p_buffer,
			/* Check for a SAV/EAV overlapping the
			   buffer boundary */

			sav_eav = cx231xx_find_boundary_SAV_EAV(p_buffer,
							  dma_q->partial_buf,
							  &bytes_parsed);
		}

		sav_eav &= 0xF0;
		/* Get the first line if we have some portion of an SAV/EAV from the last buffer
		   or a partial line */
		/* Get the first line if we have some portion of an SAV/EAV from
		   the last buffer or a partial line */
		if (sav_eav) {
			bytes_parsed += cx231xx_get_vbi_line(dev, dma_q, sav_eav,	/* SAV/EAV */
			bytes_parsed += cx231xx_get_vbi_line(dev, dma_q,
				sav_eav,		       /* SAV/EAV */
				p_buffer + bytes_parsed,       /* p_buffer */
				buffer_size - bytes_parsed);   /* buffer size */
		}
@@ -146,7 +148,8 @@ static inline int cx231xx_isoc_vbi_copy(struct cx231xx *dev, struct urb *urb)

			sav_eav &= 0xF0;
			if (sav_eav && (bytes_parsed < buffer_size)) {
				bytes_parsed += cx231xx_get_vbi_line(dev, dma_q, sav_eav,	/* SAV/EAV */
				bytes_parsed += cx231xx_get_vbi_line(dev,
						dma_q, sav_eav,	/* SAV/EAV */
						p_buffer + bytes_parsed,	/* p_buffer */
						buffer_size - bytes_parsed);	/* buffer size */
			}
@@ -285,12 +288,7 @@ static void vbi_buffer_release(struct videobuf_queue *vq,
{
	struct cx231xx_buffer *buf =
	    container_of(vb, struct cx231xx_buffer, vb);
	/*
	   struct cx231xx_fh       *fh   = vq->priv_data;
	   struct cx231xx          *dev  = (struct cx231xx *)fh->dev;

	   cx231xx_info(DRIVER_NAME "cx231xx: called vbi_buffer_release\n");
	 */

	free_buffer(vq, buf);
}
@@ -387,7 +385,6 @@ void cx231xx_uninit_vbi_isoc(struct cx231xx *dev)

	cx231xx_capture_start(dev, 0, Vbi);
}

EXPORT_SYMBOL_GPL(cx231xx_uninit_vbi_isoc);

/*
@@ -427,8 +424,8 @@ int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets,
	for (i = 0; i < 8; i++)
		dma_q->partial_buf[i] = 0;

	dev->vbi_mode.isoc_ctl.urb =
	    kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL);
	dev->vbi_mode.isoc_ctl.urb = kzalloc(sizeof(void *) * num_bufs,
					     GFP_KERNEL);
	if (!dev->vbi_mode.isoc_ctl.urb) {
		cx231xx_errdev("cannot alloc memory for usb buffers\n");
		return -ENOMEM;
@@ -495,7 +492,6 @@ int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets,

	return 0;
}

EXPORT_SYMBOL_GPL(cx231xx_init_vbi_isoc);

u32 cx231xx_get_vbi_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q,
@@ -556,9 +552,8 @@ u32 cx231xx_copy_vbi_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q,
	struct cx231xx_buffer *buf;
	u32 _line_size = dev->width * 2;

	if (dma_q->current_field != field_number) {
	if (dma_q->current_field != field_number)
		cx231xx_reset_vbi_buffer(dev, dma_q);
	}

	/* get the buffer pointer */
	buf = dev->vbi_mode.isoc_ctl.buf;
@@ -651,7 +646,6 @@ void cx231xx_reset_vbi_buffer(struct cx231xx *dev,
	buf = dev->vbi_mode.isoc_ctl.buf;

	if (buf == NULL) {

		/* first try to get the buffer */
		get_next_vbi_buf(dma_q, &buf);

@@ -675,9 +669,8 @@ int cx231xx_do_vbi_copy(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q,

	buf = dev->vbi_mode.isoc_ctl.buf;

	if (buf == NULL) {
		return -1;
	}
	if (buf == NULL)
		return -EINVAL;

	p_out_buffer = videobuf_to_vmalloc(&buf->vb);

@@ -686,15 +679,14 @@ int cx231xx_do_vbi_copy(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q,
		    _line_size - dma_q->bytes_left_in_line;
	}

	offset =
	    (dma_q->lines_completed * _line_size) + current_line_bytes_copied;
	offset = (dma_q->lines_completed * _line_size) +
		 current_line_bytes_copied;

	/* prepare destination address */
	startwrite = p_out_buffer + offset;

	lencopy =
	    dma_q->bytes_left_in_line >
	    bytes_to_copy ? bytes_to_copy : dma_q->bytes_left_in_line;
	lencopy = dma_q->bytes_left_in_line > bytes_to_copy ?
		  bytes_to_copy : dma_q->bytes_left_in_line;

	memcpy(startwrite, p_buffer, lencopy);

+288 −307
Original line number Diff line number Diff line
/*
   cx231xx-video.c - driver for Conexant Cx23100/101/102 USB video capture devices
   cx231xx-video.c - driver for Conexant Cx23100/101/102
		     USB video capture devices

   Copyright (C) 2008 <srinivasa.deevi at conexant dot com>
	Based on em28xx driver
@@ -373,10 +374,11 @@ static inline int cx231xx_isoc_copy(struct cx231xx *dev, struct urb *urb)
		}

		sav_eav &= 0xF0;
		/* Get the first line if we have some portion of an SAV/EAV from the last buffer
		   or a partial line  */
		/* Get the first line if we have some portion of an SAV/EAV from
		   the last buffer or a partial line  */
		if (sav_eav) {
			bytes_parsed += cx231xx_get_video_line(dev, dma_q, sav_eav,	/* SAV/EAV */
			bytes_parsed += cx231xx_get_video_line(dev, dma_q,
						sav_eav,	/* SAV/EAV */
						p_buffer + bytes_parsed,	/* p_buffer */
						buffer_size - bytes_parsed);	/* buffer size */
		}
@@ -395,14 +397,15 @@ static inline int cx231xx_isoc_copy(struct cx231xx *dev, struct urb *urb)

			sav_eav &= 0xF0;
			if (sav_eav && (bytes_parsed < buffer_size)) {
				bytes_parsed += cx231xx_get_video_line(dev, dma_q, sav_eav,	/* SAV/EAV */
				bytes_parsed += cx231xx_get_video_line(dev,
						dma_q, sav_eav,	/* SAV/EAV */
						p_buffer + bytes_parsed,	/* p_buffer */
						buffer_size - bytes_parsed);	/* buffer size */
			}
		}

		/* Save the last four bytes of the buffer so we can check the buffer boundary
		   condition next time */
		/* Save the last four bytes of the buffer so we can check the
		   buffer boundary condition next time */
		memcpy(dma_q->partial_buf, p_buffer + buffer_size - 4, 4);
		bytes_parsed = 0;

@@ -426,8 +429,8 @@ u8 cx231xx_find_boundary_SAV_EAV(u8 * p_buffer, u8 * partial_buf,
	memcpy(boundary_bytes + 4, p_buffer, 4);

	/* Check for the SAV/EAV in the boundary buffer */
	sav_eav =
	    cx231xx_find_next_SAV_EAV((u8 *) & boundary_bytes, 8, &bytes_used);
	sav_eav = cx231xx_find_next_SAV_EAV((u8 *)&boundary_bytes, 8,
					    &bytes_used);

	if (sav_eav) {
		/* found a boundary SAV/EAV.  Updates the bytes used to reflect
@@ -443,8 +446,11 @@ u8 cx231xx_find_next_SAV_EAV(u8 * p_buffer, u32 buffer_size, u32 * p_bytes_used)
	u32 i;
	u8 sav_eav = 0;

	/* Don't search if the buffer size is less than 4.  It causes a page fault since
	   buffer_size - 4 evaluates to a large number in that case. */
	/*
	 * Don't search if the buffer size is less than 4.  It causes a page
	 * fault since buffer_size - 4 evaluates to a large number in that
	 * case.
	 */
	if (buffer_size < 4) {
		*p_bytes_used = buffer_size;
		return 0;
@@ -474,45 +480,38 @@ u32 cx231xx_get_video_line(struct cx231xx * dev,

	switch (sav_eav) {
	case SAV_ACTIVE_VIDEO_FIELD1:
		/* looking for skipped line which occurred in PAL 720x480 mode. In this case,
		   there will be no active data contained between the SAV and EAV */
		if ((buffer_size > 3) &&
		    (p_buffer[0] == 0xFF) && (p_buffer[1] == 0x00)
		    && (p_buffer[2] == 0x00)
		    && ((p_buffer[3] == EAV_ACTIVE_VIDEO_FIELD1)
			|| (p_buffer[3] == EAV_ACTIVE_VIDEO_FIELD2)
			|| (p_buffer[3] == EAV_VBLANK_FIELD1)
			|| (p_buffer[3] == EAV_VBLANK_FIELD2)
		    )
		    ) {
		/* looking for skipped line which occurred in PAL 720x480 mode.
		   In this case, there will be no active data contained
		   between the SAV and EAV */
		if ((buffer_size > 3) && (p_buffer[0] == 0xFF) &&
		    (p_buffer[1] == 0x00) && (p_buffer[2] == 0x00) &&
		    ((p_buffer[3] == EAV_ACTIVE_VIDEO_FIELD1) ||
		     (p_buffer[3] == EAV_ACTIVE_VIDEO_FIELD2) ||
		     (p_buffer[3] == EAV_VBLANK_FIELD1) ||
		     (p_buffer[3] == EAV_VBLANK_FIELD2)))
			return bytes_copied;
		}
		current_field = 1;
		break;

	case SAV_ACTIVE_VIDEO_FIELD2:
		/* looking for skipped line which occurred in PAL 720x480 mode. In this case,
		   there will be no active data contained between the SAV and EAV */
		if ((buffer_size > 3) &&
		    (p_buffer[0] == 0xFF) && (p_buffer[1] == 0x00)
		    && (p_buffer[2] == 0x00)
		    && ((p_buffer[3] == EAV_ACTIVE_VIDEO_FIELD1)
			|| (p_buffer[3] == EAV_ACTIVE_VIDEO_FIELD2)
			|| (p_buffer[3] == EAV_VBLANK_FIELD1)
			|| (p_buffer[3] == EAV_VBLANK_FIELD2)
		    )
		    ) {
		/* looking for skipped line which occurred in PAL 720x480 mode.
		   In this case, there will be no active data contained between
		   the SAV and EAV */
		if ((buffer_size > 3) && (p_buffer[0] == 0xFF) &&
		    (p_buffer[1] == 0x00) && (p_buffer[2] == 0x00) &&
		    ((p_buffer[3] == EAV_ACTIVE_VIDEO_FIELD1) ||
		     (p_buffer[3] == EAV_ACTIVE_VIDEO_FIELD2) ||
		     (p_buffer[3] == EAV_VBLANK_FIELD1)       ||
		     (p_buffer[3] == EAV_VBLANK_FIELD2)))
			return bytes_copied;
		}
		current_field = 2;
		break;
	}

	dma_q->last_sav = sav_eav;

	bytes_copied =
	    cx231xx_copy_video_line(dev, dma_q, p_buffer, buffer_size,
				    current_field);
	bytes_copied = cx231xx_copy_video_line(dev, dma_q, p_buffer,
					       buffer_size, current_field);

	return bytes_copied;
}
@@ -525,9 +524,8 @@ u32 cx231xx_copy_video_line(struct cx231xx * dev,
	struct cx231xx_buffer *buf;
	u32 _line_size = dev->width * 2;

	if (dma_q->current_field != field_number) {
	if (dma_q->current_field != field_number)
		cx231xx_reset_video_buffer(dev, dma_q);
	}

	/* get the buffer pointer */
	buf = dev->video_mode.isoc_ctl.buf;
@@ -541,8 +539,8 @@ u32 cx231xx_copy_video_line(struct cx231xx * dev,

	if (dma_q->lines_completed >= dma_q->lines_per_field) {
		dma_q->bytes_left_in_line -= bytes_to_copy;
		dma_q->is_partial_line =
		    (dma_q->bytes_left_in_line == 0) ? 0 : 1;
		dma_q->is_partial_line = (dma_q->bytes_left_in_line == 0) ?
					  0 : 1;
		return 0;
	}

@@ -552,8 +550,8 @@ u32 cx231xx_copy_video_line(struct cx231xx * dev,
	   have copied if we had a buffer. */
	if (!buf) {
		dma_q->bytes_left_in_line -= bytes_to_copy;
		dma_q->is_partial_line =
		    (dma_q->bytes_left_in_line == 0) ? 0 : 1;
		dma_q->is_partial_line = (dma_q->bytes_left_in_line == 0)
					 ? 0 : 1;
		return bytes_to_copy;
	}

@@ -564,13 +562,11 @@ u32 cx231xx_copy_video_line(struct cx231xx * dev,
	dma_q->bytes_left_in_line -= bytes_to_copy;

	if (dma_q->bytes_left_in_line == 0) {

		dma_q->bytes_left_in_line = _line_size;
		dma_q->lines_completed++;
		dma_q->is_partial_line = 0;

		if (cx231xx_is_buffer_done(dev, dma_q) && buf) {

			buffer_filled(dev, dma_q, buf);

			dma_q->pos = 0;
@@ -589,12 +585,11 @@ void cx231xx_reset_video_buffer(struct cx231xx *dev,

	/* handle the switch from field 1 to field 2 */
	if (dma_q->current_field == 1) {
		if (dma_q->lines_completed >= dma_q->lines_per_field) {
		if (dma_q->lines_completed >= dma_q->lines_per_field)
			dma_q->field1_done = 1;
		} else {
		else
			dma_q->field1_done = 0;
	}
	}

	buf = dev->video_mode.isoc_ctl.buf;

@@ -647,14 +642,11 @@ int cx231xx_do_copy(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q,
	/* bytes already completed in the current line */
	startwrite += current_line_bytes_copied;

	lencopy =
	    dma_q->bytes_left_in_line >
	    bytes_to_copy ? bytes_to_copy : dma_q->bytes_left_in_line;
	lencopy = dma_q->bytes_left_in_line > bytes_to_copy ?
		  bytes_to_copy : dma_q->bytes_left_in_line;

	if ((u8 *) (startwrite + lencopy) >
	    (u8 *) (p_out_buffer + buf->vb.size)) {
	if ((u8 *)(startwrite + lencopy) > (u8 *)(p_out_buffer + buf->vb.size))
		return 0;
	}

	/* The below copies the UYVY data straight into video buffer */
	cx231xx_swab((u16 *) p_buffer, (u16 *) startwrite, (u16) lencopy);
@@ -669,18 +661,16 @@ void cx231xx_swab(u16 * from, u16 * to, u16 len)
	if (len <= 0)
		return;

	for (i = 0; i < len / 2; i++) {
	for (i = 0; i < len / 2; i++)
		to[i] = (from[i] << 8) | (from[i] >> 8);
}
}

u8 cx231xx_is_buffer_done(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q)
{
	u8 buffer_complete = 0;

	/* Dual field stream */
	buffer_complete =
	    ((dma_q->current_field == 2) &&
	buffer_complete = ((dma_q->current_field == 2) &&
			   (dma_q->lines_completed >= dma_q->lines_per_field) &&
			    dma_q->field1_done);

@@ -698,8 +688,7 @@ buffer_setup(struct videobuf_queue *vq, unsigned int *count, unsigned int *size)
	struct cx231xx *dev = fh->dev;
	struct v4l2_frequency f;

	*size =
	    (fh->dev->width * fh->dev->height * dev->format->depth + 7) >> 3;
	*size = (fh->dev->width * fh->dev->height * dev->format->depth + 7)>>3;
	if (0 == *count)
		*count = CX231XX_DEF_BUF;

@@ -722,6 +711,7 @@ static void free_buffer(struct videobuf_queue *vq, struct cx231xx_buffer *buf)
	struct cx231xx_fh *fh = vq->priv_data;
	struct cx231xx *dev = fh->dev;
	unsigned long flags = 0;

	if (in_interrupt())
		BUG();

@@ -754,9 +744,8 @@ buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
	int rc = 0, urb_init = 0;

	/* The only currently supported format is 16 bits/pixel */
	buf->vb.size =
	    (fh->dev->width * fh->dev->height * dev->format->depth + 7) >> 3;

	buf->vb.size = (fh->dev->width * fh->dev->height * dev->format->depth
			+ 7) >> 3;
	if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size)
		return -EINVAL;

@@ -876,7 +865,7 @@ static int res_get(struct cx231xx_fh *fh)

static int res_check(struct cx231xx_fh *fh)
{
	return (fh->stream_on);
	return fh->stream_on;
}

static void res_free(struct cx231xx_fh *fh)
@@ -948,6 +937,7 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
	f->fmt.pix.field = V4L2_FIELD_INTERLACED;

	mutex_unlock(&dev->lock);

	return 0;
}

@@ -1386,12 +1376,11 @@ static int vidioc_s_frequency(struct file *file, void *priv,
	dev->ctl_freq = f->frequency;

	if (dev->tuner_type == TUNER_XC5000) {
		if (dev->cx231xx_set_analog_freq != NULL) {
		if (dev->cx231xx_set_analog_freq != NULL)
			dev->cx231xx_set_analog_freq(dev, f->frequency);
		}
	} else {
		cx231xx_i2c_call_clients(&dev->i2c_bus[1], VIDIOC_S_FREQUENCY,
					 f);
		cx231xx_i2c_call_clients(&dev->i2c_bus[1],
					 VIDIOC_S_FREQUENCY, f);
	}

	mutex_unlock(&dev->lock);
@@ -1430,41 +1419,36 @@ static int vidioc_g_register(struct file *file, void *priv,
	case V4L2_CHIP_MATCH_HOST:
		switch (reg->match.addr) {
		case 0:	/* Cx231xx - internal registers */
			ret =
			    cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER,
			ret = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER,
						  (u16)reg->reg, value, 4);
			reg->val =
			    value[0] | value[1] << 8 | value[2] << 16 | value[3]
			    << 24;
			reg->val = value[0] | value[1] << 8 |
				   value[2] << 16 | value[3] << 24;
			break;
		case 1:	/* Colibri - read byte */
			ret =
			    cx231xx_read_i2c_data(dev, Colibri_DEVICE_ADDRESS,
			ret = cx231xx_read_i2c_data(dev, Colibri_DEVICE_ADDRESS,
						  (u16)reg->reg, 2, &data, 1);
			reg->val = le32_to_cpu(data & 0xff);
			break;
		case 14:	/* Colibri - read dword */
			ret =
			    cx231xx_read_i2c_data(dev, Colibri_DEVICE_ADDRESS,
			ret = cx231xx_read_i2c_data(dev, Colibri_DEVICE_ADDRESS,
						  (u16)reg->reg, 2, &data, 4);
			reg->val = le32_to_cpu(data);
			break;
		case 2:	/* Hammerhead - read byte */
			ret =
			    cx231xx_read_i2c_data(dev, HAMMERHEAD_I2C_ADDRESS,
			ret = cx231xx_read_i2c_data(dev, HAMMERHEAD_I2C_ADDRESS,
						  (u16)reg->reg, 2, &data, 1);
			reg->val = le32_to_cpu(data & 0xff);
			break;
		case 24:	/* Hammerhead - read dword */
			ret =
			    cx231xx_read_i2c_data(dev, HAMMERHEAD_I2C_ADDRESS,
			ret = cx231xx_read_i2c_data(dev, HAMMERHEAD_I2C_ADDRESS,
						  (u16)reg->reg, 2, &data, 4);
			reg->val = le32_to_cpu(data);
			break;
		case 3:	/* flatiron - read byte */
			ret =
			    cx231xx_read_i2c_data(dev, Flatrion_DEVICE_ADDRESS,
						  (u16) reg->reg, 1, &data, 1);
			ret = cx231xx_read_i2c_data(dev,
						    Flatrion_DEVICE_ADDRESS,
						    (u16)reg->reg, 1,
						    &data, 1);
			reg->val = le32_to_cpu(data & 0xff);
			break;
		case 34:	/* flatiron - read dword */
@@ -1489,9 +1473,7 @@ static int vidioc_g_register(struct file *file, void *priv,
	}

	mutex_lock(&dev->lock);

	cx231xx_i2c_call_clients(&dev->i2c_bus[0], VIDIOC_DBG_G_REGISTER, reg);

	mutex_unlock(&dev->lock);

	return ret;
@@ -1520,22 +1502,19 @@ static int vidioc_s_register(struct file *file, void *priv,
				data[1] = (u8) (value >> 8);
				data[2] = (u8) (value >> 16);
				data[3] = (u8) (value >> 24);
				ret =
				    cx231xx_write_ctrl_reg(dev,
				ret = cx231xx_write_ctrl_reg(dev,
							   VRT_SET_REGISTER,
							   (u16)reg->reg, data,
							   4);
				break;
			case 1:	/* Colibri - read byte */
				ret =
				    cx231xx_write_i2c_data(dev,
				ret = cx231xx_write_i2c_data(dev,
							Colibri_DEVICE_ADDRESS,
							(u16)reg->reg, 2,
							value, 1);
				break;
			case 14:	/* Colibri - read dword */
				ret =
				    cx231xx_write_i2c_data(dev,
				ret = cx231xx_write_i2c_data(dev,
							Colibri_DEVICE_ADDRESS,
							(u16)reg->reg, 2,
							value, 4);
@@ -1805,7 +1784,7 @@ static int vidioc_reqbufs(struct file *file, void *priv,
	if (rc < 0)
		return rc;

	return (videobuf_reqbufs(&fh->vb_vidq, rb));
	return videobuf_reqbufs(&fh->vb_vidq, rb);
}

static int vidioc_querybuf(struct file *file, void *priv, struct v4l2_buffer *b)
@@ -1818,7 +1797,7 @@ static int vidioc_querybuf(struct file *file, void *priv, struct v4l2_buffer *b)
	if (rc < 0)
		return rc;

	return (videobuf_querybuf(&fh->vb_vidq, b));
	return videobuf_querybuf(&fh->vb_vidq, b);
}

static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *b)
@@ -1831,7 +1810,7 @@ static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *b)
	if (rc < 0)
		return rc;

	return (videobuf_qbuf(&fh->vb_vidq, b));
	return videobuf_qbuf(&fh->vb_vidq, b);
}

static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *b)
@@ -1844,7 +1823,7 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *b)
	if (rc < 0)
		return rc;

	return (videobuf_dqbuf(&fh->vb_vidq, b, file->f_flags & O_NONBLOCK));
	return videobuf_dqbuf(&fh->vb_vidq, b, file->f_flags & O_NONBLOCK);
}

#ifdef CONFIG_VIDEO_V4L1_COMPAT
@@ -2030,17 +2009,19 @@ static int cx231xx_v4l2_open(struct file *filp)

	dev->users++;

	if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
		videobuf_queue_vmalloc_init(&fh->vb_vidq, &cx231xx_video_qops, NULL, &dev->video_mode.slock, fh->type, V4L2_FIELD_INTERLACED,	/* V4L2_FIELD_SEQ_TB, */
	if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
		videobuf_queue_vmalloc_init(&fh->vb_vidq, &cx231xx_video_qops,
					    NULL, &dev->video_mode.slock,
					    fh->type, V4L2_FIELD_INTERLACED,
					    sizeof(struct cx231xx_buffer), fh);
	}

	if (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) {

		/* Set the required alternate setting  VBI interface works in Bulk mode only */
		/* Set the required alternate setting  VBI interface works in
		   Bulk mode only */
		cx231xx_set_alt_setting(dev, INDEX_VANC, 0);

		videobuf_queue_vmalloc_init(&fh->vb_vidq, &cx231xx_vbi_qops, NULL, &dev->vbi_mode.slock, fh->type, V4L2_FIELD_SEQ_TB,	/* V4L2_FIELD_INTERLACED,  */
		videobuf_queue_vmalloc_init(&fh->vb_vidq, &cx231xx_vbi_qops,
					    NULL, &dev->vbi_mode.slock,
					    fh->type, V4L2_FIELD_SEQ_TB,
					    sizeof(struct cx231xx_buffer), fh);
	}

@@ -2120,11 +2101,10 @@ static int cx231xx_v4l2_close(struct file *filp)
		cx231xx_uninit_vbi_isoc(dev);

		/* set alternate 0 */
		if (!dev->vbi_or_sliced_cc_mode) {
		if (!dev->vbi_or_sliced_cc_mode)
			cx231xx_set_alt_setting(dev, INDEX_VANC, 0);
		} else {
		else
			cx231xx_set_alt_setting(dev, INDEX_HANC, 0);
		}

		kfree(fh);
		dev->users--;
@@ -2358,6 +2338,7 @@ static struct video_device *cx231xx_vdev_init(struct cx231xx *dev, const struct
	vfd = video_device_alloc();
	if (NULL == vfd)
		return NULL;

	*vfd = *template;
	vfd->minor = -1;
	vfd->parent = &dev->udev->dev;
@@ -2439,8 +2420,8 @@ int cx231xx_register_analog_devices(struct cx231xx *dev)
		     dev->name, dev->vbi_dev->num);

	if (cx231xx_boards[dev->model].radio.type == CX231XX_RADIO) {
		dev->radio_dev =
		    cx231xx_vdev_init(dev, &cx231xx_radio_template, "radio");
		dev->radio_dev = cx231xx_vdev_init(dev, &cx231xx_radio_template,
						   "radio");
		if (!dev->radio_dev) {
			cx231xx_errdev("cannot allocate video_device.\n");
			return -ENODEV;
+29 −31
Original line number Diff line number Diff line
@@ -141,7 +141,6 @@ struct cx231xx_usb_isoc_ctl {

	/* isoc urb callback */
	int (*isoc_copy) (struct cx231xx *dev, struct urb *urb);

};

struct cx231xx_fmt {
@@ -502,8 +501,7 @@ struct cx231xx {
	int (*cx231xx_write_ctrl_reg) (struct cx231xx *dev, u8 req, u16 reg,
				       char *buf, int len);
	int (*cx231xx_send_usb_command) (struct cx231xx_i2c *i2c_bus,
					 struct cx231xx_i2c_xfer_data *
					 req_data);
					 struct cx231xx_i2c_xfer_data *req_data);
	int (*cx231xx_gpio_i2c_read) (struct cx231xx *dev, u8 dev_addr,
				      u8 *buf, u8 len);
	int (*cx231xx_gpio_i2c_write) (struct cx231xx *dev, u8 dev_addr,