Ejemplo n.º 1
0
static int cx18_s_fmt_vid_cap(struct file *file, void *fh,
				struct v4l2_format *fmt)
{
	struct cx18_open_id *id = fh;
	struct cx18 *cx = id->cx;
	int ret;
	int w, h;

	ret = v4l2_prio_check(&cx->prio, &id->prio);
	if (ret)
		return ret;

	ret = cx18_try_fmt_vid_cap(file, fh, fmt);
	if (ret)
		return ret;
	w = fmt->fmt.pix.width;
	h = fmt->fmt.pix.height;

	if (cx->params.width == w && cx->params.height == h)
		return 0;

	if (atomic_read(&cx->ana_capturing) > 0)
		return -EBUSY;

	cx->params.width = w;
	cx->params.height = h;
	cx18_av_cmd(cx, VIDIOC_S_FMT, fmt);
	return cx18_g_fmt_vid_cap(file, fh, fmt);
}
Ejemplo n.º 2
0
static int cx18_g_crop(struct file *file, void *fh, struct v4l2_crop *crop)
{
	struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;

	if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
		return -EINVAL;
	return cx18_av_cmd(cx, VIDIOC_G_CROP, crop);
}
Ejemplo n.º 3
0
/* broadcast cmd for all I2C clients and for the gpio subsystem */
void cx18_call_i2c_clients(struct cx18 *cx, unsigned int cmd, void *arg)
{
	if (cx->i2c_adap[0].algo == NULL || cx->i2c_adap[1].algo == NULL) {
		CX18_ERR("adapter is not set\n");
		return;
	}
	cx18_av_cmd(cx, cmd, arg);
	i2c_clients_command(&cx->i2c_adap[0], cmd, arg);
	i2c_clients_command(&cx->i2c_adap[1], cmd, arg);
}
Ejemplo n.º 4
0
static int cx18_s_crop(struct file *file, void *fh, struct v4l2_crop *crop)
{
	struct cx18_open_id *id = fh;
	struct cx18 *cx = id->cx;
	int ret;

	ret = v4l2_prio_check(&cx->prio, &id->prio);
	if (ret)
		return ret;

	if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
		return -EINVAL;
	return cx18_av_cmd(cx, VIDIOC_S_CROP, crop);
}
Ejemplo n.º 5
0
/* Calls i2c device based on CX18_HW_ flag. If hw == 0, then do nothing.
   If hw == CX18_HW_GPIO then call the gpio handler. */
int cx18_i2c_hw(struct cx18 *cx, u32 hw, unsigned int cmd, void *arg)
{
	int addr;

	if (hw == CX18_HW_GPIO || hw == 0)
		return 0;
	if (hw == CX18_HW_CX23418)
		return cx18_av_cmd(cx, cmd, arg);

	addr = cx18_i2c_hw_addr(cx, hw);
	if (addr < 0) {
		CX18_ERR("i2c hardware 0x%08x (%s) not found for cmd 0x%x!\n",
			       hw, cx18_i2c_hw_name(hw), cmd);
		return addr;
	}
	return cx18_call_i2c_client(cx, addr, cmd, arg);
}
Ejemplo n.º 6
0
static int cx18_s_fmt_vbi_cap(struct file *file, void *fh,
				struct v4l2_format *fmt)
{
	struct cx18_open_id *id = fh;
	struct cx18 *cx = id->cx;
	int ret;

	ret = v4l2_prio_check(&cx->prio, &id->prio);
	if (ret)
		return ret;

	if (!cx18_raw_vbi(cx) && atomic_read(&cx->ana_capturing) > 0)
		return -EBUSY;

	cx->vbi.sliced_in->service_set = 0;
	cx->vbi.in.type = V4L2_BUF_TYPE_VBI_CAPTURE;
	cx18_av_cmd(cx, VIDIOC_S_FMT, fmt);
	return cx18_g_fmt_vbi_cap(file, fh, fmt);
}
Ejemplo n.º 7
0
void cx18_video_set_io(struct cx18 *cx)
{
	struct v4l2_routing route;
	int inp = cx->active_input;
	u32 type;

	route.input = cx->card->video_inputs[inp].video_input;
	route.output = 0;
	cx18_av_cmd(cx, VIDIOC_INT_S_VIDEO_ROUTING, &route);

	type = cx->card->video_inputs[inp].video_type;

	if (type == CX18_CARD_INPUT_VID_TUNER)
		route.input = 0;  /* Tuner */
	else if (type < CX18_CARD_INPUT_COMPOSITE1)
		route.input = 2;  /* S-Video */
	else
		route.input = 1;  /* Composite */
}
Ejemplo n.º 8
0
static int cx18_s_fmt_vbi_cap(struct file *file, void *fh,
				struct v4l2_format *fmt)
{
	struct cx18_open_id *id = fh;
	struct cx18 *cx = id->cx;
	int ret;

	ret = v4l2_prio_check(&cx->prio, &id->prio);
	if (ret)
		return ret;

	if (id->type == CX18_ENC_STREAM_TYPE_VBI &&
			cx->vbi.sliced_in->service_set &&
			atomic_read(&cx->ana_capturing) > 0)
		return -EBUSY;

	cx->vbi.sliced_in->service_set = 0;
	cx18_av_cmd(cx, VIDIOC_S_FMT, &cx->vbi.in);
	return cx18_g_fmt_vbi_cap(file, fh, fmt);
}