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

Commit 8cad7f06 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
* 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6:
  [media] gspca - sonixj: Better handling of the bridge registers 0x01 and 0x17
  [media] gspca - sonixj: Add the bit definitions of the bridge reg 0x01 and 0x17
  [media] gspca - sonixj: Set the flag for some devices
  [media] gspca - sonixj: Add a flag in the driver_info table
  [media] gspca - sonixj: Fix a bad probe exchange
  [media] gspca - sonixj: Move bridge init to sd start
  [media] bttv: remove unneeded locking comments
  [media] bttv: fix mutex use before init (BZ#24602)
  [media] Don't export format_by_forcc on two different drivers
parents 92d7c9b2 0e4d413a
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -558,7 +558,7 @@ static void saa7146_set_window(struct saa7146_dev *dev, int width, int height, e
static void saa7146_set_position(struct saa7146_dev *dev, int w_x, int w_y, int w_height, enum v4l2_field field, u32 pixelformat)
{
	struct saa7146_vv *vv = dev->vv_data;
	struct saa7146_format *sfmt = format_by_fourcc(dev, pixelformat);
	struct saa7146_format *sfmt = saa7146_format_by_fourcc(dev, pixelformat);

	int b_depth = vv->ov_fmt->depth;
	int b_bpl = vv->ov_fb.fmt.bytesperline;
@@ -702,7 +702,7 @@ static int calculate_video_dma_grab_packed(struct saa7146_dev* dev, struct saa71
	struct saa7146_vv *vv = dev->vv_data;
	struct saa7146_video_dma vdma1;

	struct saa7146_format *sfmt = format_by_fourcc(dev,buf->fmt->pixelformat);
	struct saa7146_format *sfmt = saa7146_format_by_fourcc(dev,buf->fmt->pixelformat);

	int width = buf->fmt->width;
	int height = buf->fmt->height;
@@ -827,7 +827,7 @@ static int calculate_video_dma_grab_planar(struct saa7146_dev* dev, struct saa71
	struct saa7146_video_dma vdma2;
	struct saa7146_video_dma vdma3;

	struct saa7146_format *sfmt = format_by_fourcc(dev,buf->fmt->pixelformat);
	struct saa7146_format *sfmt = saa7146_format_by_fourcc(dev,buf->fmt->pixelformat);

	int width = buf->fmt->width;
	int height = buf->fmt->height;
@@ -994,7 +994,7 @@ static void program_capture_engine(struct saa7146_dev *dev, int planar)

void saa7146_set_capture(struct saa7146_dev *dev, struct saa7146_buf *buf, struct saa7146_buf *next)
{
	struct saa7146_format *sfmt = format_by_fourcc(dev,buf->fmt->pixelformat);
	struct saa7146_format *sfmt = saa7146_format_by_fourcc(dev,buf->fmt->pixelformat);
	struct saa7146_vv *vv = dev->vv_data;
	u32 vdma1_prot_addr;

+8 −8
Original line number Diff line number Diff line
@@ -84,7 +84,7 @@ static struct saa7146_format formats[] = {

static int NUM_FORMATS = sizeof(formats)/sizeof(struct saa7146_format);

struct saa7146_format* format_by_fourcc(struct saa7146_dev *dev, int fourcc)
struct saa7146_format* saa7146_format_by_fourcc(struct saa7146_dev *dev, int fourcc)
{
	int i, j = NUM_FORMATS;

@@ -266,7 +266,7 @@ static int saa7146_pgtable_build(struct saa7146_dev *dev, struct saa7146_buf *bu
	struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb);
	struct scatterlist *list = dma->sglist;
	int length = dma->sglen;
	struct saa7146_format *sfmt = format_by_fourcc(dev,buf->fmt->pixelformat);
	struct saa7146_format *sfmt = saa7146_format_by_fourcc(dev,buf->fmt->pixelformat);

	DEB_EE(("dev:%p, buf:%p, sg_len:%d\n",dev,buf,length));

@@ -408,7 +408,7 @@ static int video_begin(struct saa7146_fh *fh)
		}
	}

	fmt = format_by_fourcc(dev,fh->video_fmt.pixelformat);
	fmt = saa7146_format_by_fourcc(dev,fh->video_fmt.pixelformat);
	/* we need to have a valid format set here */
	BUG_ON(NULL == fmt);

@@ -460,7 +460,7 @@ static int video_end(struct saa7146_fh *fh, struct file *file)
		return -EBUSY;
	}

	fmt = format_by_fourcc(dev,fh->video_fmt.pixelformat);
	fmt = saa7146_format_by_fourcc(dev,fh->video_fmt.pixelformat);
	/* we need to have a valid format set here */
	BUG_ON(NULL == fmt);

@@ -536,7 +536,7 @@ static int vidioc_s_fbuf(struct file *file, void *fh, struct v4l2_framebuffer *f
		return -EPERM;

	/* check args */
	fmt = format_by_fourcc(dev, fb->fmt.pixelformat);
	fmt = saa7146_format_by_fourcc(dev, fb->fmt.pixelformat);
	if (NULL == fmt)
		return -EINVAL;

@@ -760,7 +760,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *fh, struct v4l2_forma

	DEB_EE(("V4L2_BUF_TYPE_VIDEO_CAPTURE: dev:%p, fh:%p\n", dev, fh));

	fmt = format_by_fourcc(dev, f->fmt.pix.pixelformat);
	fmt = saa7146_format_by_fourcc(dev, f->fmt.pix.pixelformat);
	if (NULL == fmt)
		return -EINVAL;

@@ -1264,7 +1264,7 @@ static int buffer_prepare(struct videobuf_queue *q,
		buf->fmt       = &fh->video_fmt;
		buf->vb.field  = fh->video_fmt.field;

		sfmt = format_by_fourcc(dev,buf->fmt->pixelformat);
		sfmt = saa7146_format_by_fourcc(dev,buf->fmt->pixelformat);

		release_all_pagetables(dev, buf);
		if( 0 != IS_PLANAR(sfmt->trans)) {
@@ -1378,7 +1378,7 @@ static int video_open(struct saa7146_dev *dev, struct file *file)
	fh->video_fmt.pixelformat = V4L2_PIX_FMT_BGR24;
	fh->video_fmt.bytesperline = 0;
	fh->video_fmt.field = V4L2_FIELD_ANY;
	sfmt = format_by_fourcc(dev,fh->video_fmt.pixelformat);
	sfmt = saa7146_format_by_fourcc(dev,fh->video_fmt.pixelformat);
	fh->video_fmt.sizeimage = (fh->video_fmt.width * fh->video_fmt.height * sfmt->depth)/8;

	videobuf_queue_sg_init(&fh->video_q, &video_qops,
+3 −114
Original line number Diff line number Diff line
@@ -854,7 +854,6 @@ int check_alloc_btres_lock(struct bttv *btv, struct bttv_fh *fh, int bit)
		xbits |= RESOURCE_VIDEO_READ | RESOURCE_VIDEO_STREAM;

	/* is it free? */
	mutex_lock(&btv->lock);
	if (btv->resources & xbits) {
		/* no, someone else uses it */
		goto fail;
@@ -884,11 +883,9 @@ int check_alloc_btres_lock(struct bttv *btv, struct bttv_fh *fh, int bit)
	/* it's free, grab it */
	fh->resources  |= bit;
	btv->resources |= bit;
	mutex_unlock(&btv->lock);
	return 1;

 fail:
	mutex_unlock(&btv->lock);
	return 0;
}

@@ -940,7 +937,6 @@ void free_btres_lock(struct bttv *btv, struct bttv_fh *fh, int bits)
		/* trying to free ressources not allocated by us ... */
		printk("bttv: BUG! (btres)\n");
	}
	mutex_lock(&btv->lock);
	fh->resources  &= ~bits;
	btv->resources &= ~bits;

@@ -951,8 +947,6 @@ void free_btres_lock(struct bttv *btv, struct bttv_fh *fh, int bits)

	if (0 == (bits & VBI_RESOURCES))
		disclaim_vbi_lines(btv);

	mutex_unlock(&btv->lock);
}

/* ----------------------------------------------------------------------- */
@@ -1713,28 +1707,20 @@ static int bttv_prepare_buffer(struct videobuf_queue *q,struct bttv *btv,

		/* Make sure tvnorm and vbi_end remain consistent
		   until we're done. */
		mutex_lock(&btv->lock);

		norm = btv->tvnorm;

		/* In this mode capturing always starts at defrect.top
		   (default VDELAY), ignoring cropping parameters. */
		if (btv->vbi_end > bttv_tvnorms[norm].cropcap.defrect.top) {
			mutex_unlock(&btv->lock);
			return -EINVAL;
		}

		mutex_unlock(&btv->lock);

		c.rect = bttv_tvnorms[norm].cropcap.defrect;
	} else {
		mutex_lock(&btv->lock);

		norm = btv->tvnorm;
		c = btv->crop[!!fh->do_crop];

		mutex_unlock(&btv->lock);

		if (width < c.min_scaled_width ||
		    width > c.max_scaled_width ||
		    height < c.min_scaled_height)
@@ -1858,7 +1844,6 @@ static int bttv_s_std(struct file *file, void *priv, v4l2_std_id *id)
	unsigned int i;
	int err;

	mutex_lock(&btv->lock);
	err = v4l2_prio_check(&btv->prio, fh->prio);
	if (err)
		goto err;
@@ -1874,7 +1859,6 @@ static int bttv_s_std(struct file *file, void *priv, v4l2_std_id *id)
	set_tvnorm(btv, i);

err:
	mutex_unlock(&btv->lock);

	return err;
}
@@ -1898,7 +1882,6 @@ static int bttv_enum_input(struct file *file, void *priv,
	struct bttv *btv = fh->btv;
	int rc = 0;

	mutex_lock(&btv->lock);
	if (i->index >= bttv_tvcards[btv->c.type].video_inputs) {
		rc = -EINVAL;
		goto err;
@@ -1928,7 +1911,6 @@ static int bttv_enum_input(struct file *file, void *priv,
	i->std = BTTV_NORMS;

err:
	mutex_unlock(&btv->lock);

	return rc;
}
@@ -1938,9 +1920,7 @@ static int bttv_g_input(struct file *file, void *priv, unsigned int *i)
	struct bttv_fh *fh = priv;
	struct bttv *btv = fh->btv;

	mutex_lock(&btv->lock);
	*i = btv->input;
	mutex_unlock(&btv->lock);

	return 0;
}
@@ -1952,7 +1932,6 @@ static int bttv_s_input(struct file *file, void *priv, unsigned int i)

	int err;

	mutex_lock(&btv->lock);
	err = v4l2_prio_check(&btv->prio, fh->prio);
	if (unlikely(err))
		goto err;
@@ -1965,7 +1944,6 @@ static int bttv_s_input(struct file *file, void *priv, unsigned int i)
	set_input(btv, i, btv->tvnorm);

err:
	mutex_unlock(&btv->lock);
	return 0;
}

@@ -1979,7 +1957,6 @@ static int bttv_s_tuner(struct file *file, void *priv,
	if (unlikely(0 != t->index))
		return -EINVAL;

	mutex_lock(&btv->lock);
	if (unlikely(btv->tuner_type == TUNER_ABSENT)) {
		err = -EINVAL;
		goto err;
@@ -1995,7 +1972,6 @@ static int bttv_s_tuner(struct file *file, void *priv,
		btv->audio_mode_gpio(btv, t, 1);

err:
	mutex_unlock(&btv->lock);

	return 0;
}
@@ -2006,10 +1982,8 @@ static int bttv_g_frequency(struct file *file, void *priv,
	struct bttv_fh *fh  = priv;
	struct bttv *btv = fh->btv;

	mutex_lock(&btv->lock);
	f->type = btv->radio_user ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
	f->frequency = btv->freq;
	mutex_unlock(&btv->lock);

	return 0;
}
@@ -2024,7 +1998,6 @@ static int bttv_s_frequency(struct file *file, void *priv,
	if (unlikely(f->tuner != 0))
		return -EINVAL;

	mutex_lock(&btv->lock);
	err = v4l2_prio_check(&btv->prio, fh->prio);
	if (unlikely(err))
		goto err;
@@ -2039,7 +2012,6 @@ static int bttv_s_frequency(struct file *file, void *priv,
	if (btv->has_matchbox && btv->radio_user)
		tea5757_set_freq(btv, btv->freq);
err:
	mutex_unlock(&btv->lock);

	return 0;
}
@@ -2172,7 +2144,6 @@ limit_scaled_size_lock (struct bttv_fh * fh,

	/* Make sure tvnorm, vbi_end and the current cropping parameters
	   remain consistent until we're done. */
	mutex_lock(&btv->lock);

	b = &bttv_tvnorms[btv->tvnorm].cropcap.bounds;

@@ -2250,7 +2221,6 @@ limit_scaled_size_lock (struct bttv_fh * fh,
	rc = 0; /* success */

 fail:
	mutex_unlock(&btv->lock);

	return rc;
}
@@ -2282,9 +2252,7 @@ verify_window_lock (struct bttv_fh * fh,
	if (V4L2_FIELD_ANY == field) {
		__s32 height2;

		mutex_lock(&fh->btv->lock);
		height2 = fh->btv->crop[!!fh->do_crop].rect.height >> 1;
		mutex_unlock(&fh->btv->lock);
		field = (win->w.height > height2)
			? V4L2_FIELD_INTERLACED
			: V4L2_FIELD_TOP;
@@ -2360,7 +2328,6 @@ static int setup_window_lock(struct bttv_fh *fh, struct bttv *btv,
		}
	}

	mutex_lock(&fh->cap.vb_lock);
	/* clip against screen */
	if (NULL != btv->fbuf.base)
		n = btcx_screen_clips(btv->fbuf.fmt.width, btv->fbuf.fmt.height,
@@ -2391,13 +2358,6 @@ static int setup_window_lock(struct bttv_fh *fh, struct bttv *btv,
	fh->ov.field    = win->field;
	fh->ov.setup_ok = 1;

	/*
	 * FIXME: btv is protected by btv->lock mutex, while btv->init
	 *	  is protected by fh->cap.vb_lock. This seems to open the
	 *	  possibility for some race situations. Maybe the better would
	 *	  be to unify those locks or to use another way to store the
	 *	  init values that will be consumed by videobuf callbacks
	 */
	btv->init.ov.w.width   = win->w.width;
	btv->init.ov.w.height  = win->w.height;
	btv->init.ov.field     = win->field;
@@ -2412,7 +2372,6 @@ static int setup_window_lock(struct bttv_fh *fh, struct bttv *btv,
		bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new);
		retval = bttv_switch_overlay(btv,fh,new);
	}
	mutex_unlock(&fh->cap.vb_lock);
	return retval;
}

@@ -2526,9 +2485,7 @@ static int bttv_try_fmt_vid_cap(struct file *file, void *priv,
	if (V4L2_FIELD_ANY == field) {
		__s32 height2;

		mutex_lock(&btv->lock);
		height2 = btv->crop[!!fh->do_crop].rect.height >> 1;
		mutex_unlock(&btv->lock);
		field = (f->fmt.pix.height > height2)
			? V4L2_FIELD_INTERLACED
			: V4L2_FIELD_BOTTOM;
@@ -2614,7 +2571,6 @@ static int bttv_s_fmt_vid_cap(struct file *file, void *priv,
	fmt = format_by_fourcc(f->fmt.pix.pixelformat);

	/* update our state informations */
	mutex_lock(&fh->cap.vb_lock);
	fh->fmt              = fmt;
	fh->cap.field        = f->fmt.pix.field;
	fh->cap.last         = V4L2_FIELD_NONE;
@@ -2623,7 +2579,6 @@ static int bttv_s_fmt_vid_cap(struct file *file, void *priv,
	btv->init.fmt        = fmt;
	btv->init.width      = f->fmt.pix.width;
	btv->init.height     = f->fmt.pix.height;
	mutex_unlock(&fh->cap.vb_lock);

	return 0;
}
@@ -2649,11 +2604,9 @@ static int vidiocgmbuf(struct file *file, void *priv, struct video_mbuf *mbuf)
	unsigned int i;
	struct bttv_fh *fh = priv;

	mutex_lock(&fh->cap.vb_lock);
	retval = __videobuf_mmap_setup(&fh->cap, gbuffers, gbufsize,
				     V4L2_MEMORY_MMAP);
	if (retval < 0) {
		mutex_unlock(&fh->cap.vb_lock);
		return retval;
	}

@@ -2665,7 +2618,6 @@ static int vidiocgmbuf(struct file *file, void *priv, struct video_mbuf *mbuf)
	for (i = 0; i < gbuffers; i++)
		mbuf->offsets[i] = i * gbufsize;

	mutex_unlock(&fh->cap.vb_lock);
	return 0;
}
#endif
@@ -2775,10 +2727,8 @@ static int bttv_overlay(struct file *file, void *f, unsigned int on)
	int retval = 0;

	if (on) {
		mutex_lock(&fh->cap.vb_lock);
		/* verify args */
		if (unlikely(!btv->fbuf.base)) {
			mutex_unlock(&fh->cap.vb_lock);
			return -EINVAL;
		}
		if (unlikely(!fh->ov.setup_ok)) {
@@ -2787,13 +2737,11 @@ static int bttv_overlay(struct file *file, void *f, unsigned int on)
		}
		if (retval)
			return retval;
		mutex_unlock(&fh->cap.vb_lock);
	}

	if (!check_alloc_btres_lock(btv, fh, RESOURCE_OVERLAY))
		return -EBUSY;

	mutex_lock(&fh->cap.vb_lock);
	if (on) {
		fh->ov.tvnorm = btv->tvnorm;
		new = videobuf_sg_alloc(sizeof(*new));
@@ -2805,7 +2753,6 @@ static int bttv_overlay(struct file *file, void *f, unsigned int on)

	/* switch over */
	retval = bttv_switch_overlay(btv, fh, new);
	mutex_unlock(&fh->cap.vb_lock);
	return retval;
}

@@ -2844,7 +2791,6 @@ static int bttv_s_fbuf(struct file *file, void *f,
	}

	/* ok, accept it */
	mutex_lock(&fh->cap.vb_lock);
	btv->fbuf.base       = fb->base;
	btv->fbuf.fmt.width  = fb->fmt.width;
	btv->fbuf.fmt.height = fb->fmt.height;
@@ -2876,7 +2822,6 @@ static int bttv_s_fbuf(struct file *file, void *f,
			retval = bttv_switch_overlay(btv, fh, new);
		}
	}
	mutex_unlock(&fh->cap.vb_lock);
	return retval;
}

@@ -2955,7 +2900,6 @@ static int bttv_queryctrl(struct file *file, void *priv,
	     c->id >= V4L2_CID_PRIVATE_LASTP1))
		return -EINVAL;

	mutex_lock(&btv->lock);
	if (!btv->volume_gpio && (c->id == V4L2_CID_AUDIO_VOLUME))
		*c = no_ctl;
	else {
@@ -2963,7 +2907,6 @@ static int bttv_queryctrl(struct file *file, void *priv,

		*c = (NULL != ctrl) ? *ctrl : no_ctl;
	}
	mutex_unlock(&btv->lock);

	return 0;
}
@@ -2974,10 +2917,8 @@ static int bttv_g_parm(struct file *file, void *f,
	struct bttv_fh *fh = f;
	struct bttv *btv = fh->btv;

	mutex_lock(&btv->lock);
	v4l2_video_std_frame_period(bttv_tvnorms[btv->tvnorm].v4l2_id,
				    &parm->parm.capture.timeperframe);
	mutex_unlock(&btv->lock);

	return 0;
}
@@ -2993,7 +2934,6 @@ static int bttv_g_tuner(struct file *file, void *priv,
	if (0 != t->index)
		return -EINVAL;

	mutex_lock(&btv->lock);
	t->rxsubchans = V4L2_TUNER_SUB_MONO;
	bttv_call_all(btv, tuner, g_tuner, t);
	strcpy(t->name, "Television");
@@ -3005,7 +2945,6 @@ static int bttv_g_tuner(struct file *file, void *priv,
	if (btv->audio_mode_gpio)
		btv->audio_mode_gpio(btv, t, 0);

	mutex_unlock(&btv->lock);
	return 0;
}

@@ -3014,9 +2953,7 @@ static int bttv_g_priority(struct file *file, void *f, enum v4l2_priority *p)
	struct bttv_fh *fh = f;
	struct bttv *btv = fh->btv;

	mutex_lock(&btv->lock);
	*p = v4l2_prio_max(&btv->prio);
	mutex_unlock(&btv->lock);

	return 0;
}
@@ -3028,9 +2965,7 @@ static int bttv_s_priority(struct file *file, void *f,
	struct bttv *btv = fh->btv;
	int	rc;

	mutex_lock(&btv->lock);
	rc = v4l2_prio_change(&btv->prio, &fh->prio, prio);
	mutex_unlock(&btv->lock);

	return rc;
}
@@ -3045,9 +2980,7 @@ static int bttv_cropcap(struct file *file, void *priv,
	    cap->type != V4L2_BUF_TYPE_VIDEO_OVERLAY)
		return -EINVAL;

	mutex_lock(&btv->lock);
	*cap = bttv_tvnorms[btv->tvnorm].cropcap;
	mutex_unlock(&btv->lock);

	return 0;
}
@@ -3065,9 +2998,7 @@ static int bttv_g_crop(struct file *file, void *f, struct v4l2_crop *crop)
	   inconsistent with fh->width or fh->height and apps
	   do not expect a change here. */

	mutex_lock(&btv->lock);
	crop->c = btv->crop[!!fh->do_crop].rect;
	mutex_unlock(&btv->lock);

	return 0;
}
@@ -3091,17 +3022,14 @@ static int bttv_s_crop(struct file *file, void *f, struct v4l2_crop *crop)
	/* Make sure tvnorm, vbi_end and the current cropping
	   parameters remain consistent until we're done. Note
	   read() may change vbi_end in check_alloc_btres_lock(). */
	mutex_lock(&btv->lock);
	retval = v4l2_prio_check(&btv->prio, fh->prio);
	if (0 != retval) {
		mutex_unlock(&btv->lock);
		return retval;
	}

	retval = -EBUSY;

	if (locked_btres(fh->btv, VIDEO_RESOURCES)) {
		mutex_unlock(&btv->lock);
		return retval;
	}

@@ -3113,7 +3041,6 @@ static int bttv_s_crop(struct file *file, void *f, struct v4l2_crop *crop)

	b_top = max(b->top, btv->vbi_end);
	if (b_top + 32 >= b_bottom) {
		mutex_unlock(&btv->lock);
		return retval;
	}

@@ -3136,12 +3063,8 @@ static int bttv_s_crop(struct file *file, void *f, struct v4l2_crop *crop)

	btv->crop[1] = c;

	mutex_unlock(&btv->lock);

	fh->do_crop = 1;

	mutex_lock(&fh->cap.vb_lock);

	if (fh->width < c.min_scaled_width) {
		fh->width = c.min_scaled_width;
		btv->init.width = c.min_scaled_width;
@@ -3158,8 +3081,6 @@ static int bttv_s_crop(struct file *file, void *f, struct v4l2_crop *crop)
		btv->init.height = c.max_scaled_height;
	}

	mutex_unlock(&fh->cap.vb_lock);

	return 0;
}

@@ -3227,7 +3148,6 @@ static unsigned int bttv_poll(struct file *file, poll_table *wait)
		return videobuf_poll_stream(file, &fh->vbi, wait);
	}

	mutex_lock(&fh->cap.vb_lock);
	if (check_btres(fh,RESOURCE_VIDEO_STREAM)) {
		/* streaming capture */
		if (list_empty(&fh->cap.stream))
@@ -3262,7 +3182,6 @@ static unsigned int bttv_poll(struct file *file, poll_table *wait)
	else
		rc = 0;
err:
	mutex_unlock(&fh->cap.vb_lock);
	return rc;
}

@@ -3293,23 +3212,11 @@ static int bttv_open(struct file *file)
		return -ENOMEM;
	file->private_data = fh;

	/*
	 * btv is protected by btv->lock mutex, while btv->init and other
	 * streaming vars are protected by fh->cap.vb_lock. We need to take
	 * care of both locks to avoid troubles. However, vb_lock is used also
	 * inside videobuf, without calling buf->lock. So, it is a very bad
	 * idea to hold both locks at the same time.
	 * Let's first copy btv->init at fh, holding cap.vb_lock, and then work
	 * with the rest of init, holding btv->lock.
	 */
	mutex_lock(&fh->cap.vb_lock);
	*fh = btv->init;
	mutex_unlock(&fh->cap.vb_lock);

	fh->type = type;
	fh->ov.setup_ok = 0;

	mutex_lock(&btv->lock);
	v4l2_prio_open(&btv->prio, &fh->prio);

	videobuf_queue_sg_init(&fh->cap, &bttv_video_qops,
@@ -3317,13 +3224,13 @@ static int bttv_open(struct file *file)
			    V4L2_BUF_TYPE_VIDEO_CAPTURE,
			    V4L2_FIELD_INTERLACED,
			    sizeof(struct bttv_buffer),
			    fh, NULL);
			    fh, &btv->lock);
	videobuf_queue_sg_init(&fh->vbi, &bttv_vbi_qops,
			    &btv->c.pci->dev, &btv->s_lock,
			    V4L2_BUF_TYPE_VBI_CAPTURE,
			    V4L2_FIELD_SEQ_TB,
			    sizeof(struct bttv_buffer),
			    fh, NULL);
			    fh, &btv->lock);
	set_tvnorm(btv,btv->tvnorm);
	set_input(btv, btv->input, btv->tvnorm);

@@ -3346,7 +3253,6 @@ static int bttv_open(struct file *file)
	bttv_vbi_fmt_reset(&fh->vbi_fmt, btv->tvnorm);

	bttv_field_count(btv);
	mutex_unlock(&btv->lock);
	return 0;
}

@@ -3355,7 +3261,6 @@ static int bttv_release(struct file *file)
	struct bttv_fh *fh = file->private_data;
	struct bttv *btv = fh->btv;

	mutex_lock(&btv->lock);
	/* turn off overlay */
	if (check_btres(fh, RESOURCE_OVERLAY))
		bttv_switch_overlay(btv,fh,NULL);
@@ -3381,14 +3286,8 @@ static int bttv_release(struct file *file)

	/* free stuff */

	/*
	 * videobuf uses cap.vb_lock - we should avoid holding btv->lock,
	 * otherwise we may have dead lock conditions
	 */
	mutex_unlock(&btv->lock);
	videobuf_mmap_free(&fh->cap);
	videobuf_mmap_free(&fh->vbi);
	mutex_lock(&btv->lock);
	v4l2_prio_close(&btv->prio, fh->prio);
	file->private_data = NULL;
	kfree(fh);
@@ -3398,7 +3297,6 @@ static int bttv_release(struct file *file)

	if (!btv->users)
		audio_mute(btv, 1);
	mutex_unlock(&btv->lock);

	return 0;
}
@@ -3502,11 +3400,8 @@ static int radio_open(struct file *file)
	if (unlikely(!fh))
		return -ENOMEM;
	file->private_data = fh;
	mutex_lock(&fh->cap.vb_lock);
	*fh = btv->init;
	mutex_unlock(&fh->cap.vb_lock);

	mutex_lock(&btv->lock);
	v4l2_prio_open(&btv->prio, &fh->prio);

	btv->radio_user++;
@@ -3514,7 +3409,6 @@ static int radio_open(struct file *file)
	bttv_call_all(btv, tuner, s_radio);
	audio_input(btv,TVAUDIO_INPUT_RADIO);

	mutex_unlock(&btv->lock);
	return 0;
}

@@ -3524,7 +3418,6 @@ static int radio_release(struct file *file)
	struct bttv *btv = fh->btv;
	struct rds_command cmd;

	mutex_lock(&btv->lock);
	v4l2_prio_close(&btv->prio, fh->prio);
	file->private_data = NULL;
	kfree(fh);
@@ -3532,7 +3425,6 @@ static int radio_release(struct file *file)
	btv->radio_user--;

	bttv_call_all(btv, core, ioctl, RDS_CMD_CLOSE, &cmd);
	mutex_unlock(&btv->lock);

	return 0;
}
@@ -3561,7 +3453,6 @@ static int radio_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t)
		return -EINVAL;
	if (0 != t->index)
		return -EINVAL;
	mutex_lock(&btv->lock);
	strcpy(t->name, "Radio");
	t->type = V4L2_TUNER_RADIO;

@@ -3570,8 +3461,6 @@ static int radio_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t)
	if (btv->audio_mode_gpio)
		btv->audio_mode_gpio(btv, t, 0);

	mutex_unlock(&btv->lock);

	return 0;
}

@@ -3692,7 +3581,7 @@ static const struct v4l2_file_operations radio_fops =
	.open	  = radio_open,
	.read     = radio_read,
	.release  = radio_release,
	.ioctl	  = video_ioctl2,
	.unlocked_ioctl = video_ioctl2,
	.poll     = radio_poll,
};

+184 −232

File changed.

Preview size limit exceeded, changes collapsed.

+4 −4
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@ int cx25821_get_format_size(void)
	return ARRAY_SIZE(formats);
}

struct cx25821_fmt *format_by_fourcc(unsigned int fourcc)
struct cx25821_fmt *cx25821_format_by_fourcc(unsigned int fourcc)
{
	unsigned int i;

@@ -848,7 +848,7 @@ static int video_open(struct file *file)
       pix_format =
	   (dev->channels[ch_id].pixel_formats ==
	    PIXEL_FRMT_411) ? V4L2_PIX_FMT_Y41P : V4L2_PIX_FMT_YUYV;
       fh->fmt = format_by_fourcc(pix_format);
       fh->fmt = cx25821_format_by_fourcc(pix_format);

       v4l2_prio_open(&dev->channels[ch_id].prio, &fh->prio);

@@ -1010,7 +1010,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
       if (0 != err)
	       return err;

       fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat);
       fh->fmt = cx25821_format_by_fourcc(f->fmt.pix.pixelformat);
       fh->vidq.field = f->fmt.pix.field;

       /* check if width and height is valid based on set standard */
@@ -1119,7 +1119,7 @@ int cx25821_vidioc_try_fmt_vid_cap(struct file *file, void *priv, struct v4l2_fo
	enum v4l2_field field;
	unsigned int maxw, maxh;

	fmt = format_by_fourcc(f->fmt.pix.pixelformat);
	fmt = cx25821_format_by_fourcc(f->fmt.pix.pixelformat);
	if (NULL == fmt)
		return -EINVAL;

Loading