Commit f50ba1be authored by Jean-Francois Moine's avatar Jean-Francois Moine Committed by Mauro Carvalho Chehab
Browse files

V4L/DVB (8814): gspca: Set DISABLED the disabled controls at query control time.

parent 221e7dbe
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -81,6 +81,7 @@ static struct ctrl sd_ctrls[] = {
	 .set = sd_setcontrast,
	 .get = sd_getcontrast,
	 },
#define COLOR_IDX 2
	{
	 {
	  .id = V4L2_CID_SATURATION,
@@ -665,6 +666,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
	} else {
		cam->cam_mode = vga_mode;
		cam->nmodes = sizeof vga_mode / sizeof vga_mode[0];
		gspca_dev->ctrl_dis = (1 << COLOR_IDX);
	}
	sd->brightness = BRIGHTNESS_DEF;
	sd->contrast = CONTRAST_DEF;
+20 −13
Original line number Diff line number Diff line
@@ -856,37 +856,44 @@ static int vidioc_querycap(struct file *file, void *priv,
	return 0;
}

/* the use of V4L2_CTRL_FLAG_NEXT_CTRL asks for the controls to be sorted */
static int vidioc_queryctrl(struct file *file, void *priv,
			   struct v4l2_queryctrl *q_ctrl)
{
	struct gspca_dev *gspca_dev = priv;
	int i;
	int i, ix;
	u32 id;

	ix = -1;
	id = q_ctrl->id;
	if (id & V4L2_CTRL_FLAG_NEXT_CTRL) {
		id &= V4L2_CTRL_ID_MASK;
		id++;
		for (i = 0; i < gspca_dev->sd_desc->nctrls; i++) {
			if (id >= gspca_dev->sd_desc->ctrls[i].qctrl.id) {
				memcpy(q_ctrl,
					&gspca_dev->sd_desc->ctrls[i].qctrl,
					sizeof *q_ctrl);
				return 0;
			if (id < gspca_dev->sd_desc->ctrls[i].qctrl.id)
				continue;
			if (ix < 0) {
				ix = i;
				continue;
			}
			if (gspca_dev->sd_desc->ctrls[i].qctrl.id
				    > gspca_dev->sd_desc->ctrls[ix].qctrl.id)
				continue;
			ix = i;
		}
		return -EINVAL;
	}
	for (i = 0; i < gspca_dev->sd_desc->nctrls; i++) {
		if (id == gspca_dev->sd_desc->ctrls[i].qctrl.id) {
			memcpy(q_ctrl,
				&gspca_dev->sd_desc->ctrls[i].qctrl,
				sizeof *q_ctrl);
			return 0;
			ix = i;
			break;
		}
	}
	if (ix < 0)
		return -EINVAL;
	memcpy(q_ctrl, &gspca_dev->sd_desc->ctrls[ix].qctrl,
		sizeof *q_ctrl);
	if (gspca_dev->ctrl_dis & (1 << ix))
		q_ctrl->flags |= V4L2_CTRL_FLAG_DISABLED;
	return 0;
}

static int vidioc_s_ctrl(struct file *file, void *priv,
+1 −0
Original line number Diff line number Diff line
@@ -126,6 +126,7 @@ struct gspca_dev {

	struct cam cam;				/* device information */
	const struct sd_desc *sd_desc;		/* subdriver description */
	unsigned ctrl_dis;		/* disabled controls (bit map) */

	__u8 usb_buf[8];			/* buffer for USB exchanges */
	struct urb *urb[MAX_NURBS];
+4 −0
Original line number Diff line number Diff line
@@ -150,6 +150,7 @@ static struct ctrl sd_ctrls[] = {
	    .get = sd_getautogain,
	},
/* next controls work with pac7302 only */
#define HFLIP_IDX 4
	{
	    {
		.id      = V4L2_CID_HFLIP,
@@ -164,6 +165,7 @@ static struct ctrl sd_ctrls[] = {
	    .set = sd_sethflip,
	    .get = sd_gethflip,
	},
#define VFLIP_IDX 5
	{
	    {
		.id      = V4L2_CID_VFLIP,
@@ -467,6 +469,8 @@ static int sd_config(struct gspca_dev *gspca_dev,

		cam->cam_mode = vga_mode;
		cam->nmodes = ARRAY_SIZE(vga_mode);
		gspca_dev->ctrl_dis = (1 << HFLIP_IDX)
				| (1 << VFLIP_IDX);
	}

	sd->brightness = BRIGHTNESS_DEF;
+15 −10
Original line number Diff line number Diff line
@@ -116,6 +116,7 @@ static struct ctrl sd_ctrls[] = {
	    .set = sd_setcolors,
	    .get = sd_getcolors,
	},
#define AUTOGAIN_IDX 3
	{
	    {
		.id      = V4L2_CID_AUTOGAIN,
@@ -936,6 +937,14 @@ static int sd_config(struct gspca_dev *gspca_dev,
	sd->autogain = AUTOGAIN_DEF;
	sd->ag_cnt = -1;

	switch (sd->sensor) {
	case SENSOR_OV7630:
	case SENSOR_OV7648:
	case SENSOR_OV7660:
		gspca_dev->ctrl_dis = (1 << AUTOGAIN_IDX);
		break;
	}

	return 0;
}

@@ -1150,16 +1159,12 @@ static void setautogain(struct gspca_dev *gspca_dev)
{
	struct sd *sd = (struct sd *) gspca_dev;

	switch (sd->sensor) {
	case SENSOR_HV7131R:
	case SENSOR_MO4000:
	case SENSOR_MI0360:
	if (gspca_dev->ctrl_dis & (1 << AUTOGAIN_IDX))
		return;
	if (sd->autogain)
		sd->ag_cnt = AG_CNT_START;
	else
		sd->ag_cnt = -1;
		break;
	}
}

/* -- start the camera -- */
Loading