Commit 766231ab authored by Erik Andren's avatar Erik Andren Committed by Mauro Carvalho Chehab
Browse files

V4L/DVB (10334): gspca - stv06xx: Rework control description.

parent 50e06dee
Loading
Loading
Loading
Loading
+68 −8
Original line number Diff line number Diff line
@@ -30,6 +30,66 @@

#include "stv06xx_hdcs.h"

static const struct ctrl hdcs1x00_ctrl[] = {
	{
		{
			.id		= V4L2_CID_EXPOSURE,
			.type		= V4L2_CTRL_TYPE_INTEGER,
			.name		= "exposure",
			.minimum	= 0x00,
			.maximum	= 0xffff,
			.step		= 0x1,
			.default_value 	= HDCS_DEFAULT_EXPOSURE,
			.flags         	= V4L2_CTRL_FLAG_SLIDER
		},
		.set = hdcs_set_exposure,
		.get = hdcs_get_exposure
	}, {
		{
			.id		= V4L2_CID_GAIN,
			.type		= V4L2_CTRL_TYPE_INTEGER,
			.name		= "gain",
			.minimum	= 0x00,
			.maximum	= 0xff,
			.step		= 0x1,
			.default_value 	= HDCS_DEFAULT_GAIN,
			.flags         	= V4L2_CTRL_FLAG_SLIDER
		},
		.set = hdcs_set_gain,
		.get = hdcs_get_gain
	}
};

static struct v4l2_pix_format hdcs1x00_mode[] = {
	{
		HDCS_1X00_DEF_WIDTH,
		HDCS_1X00_DEF_HEIGHT,
		V4L2_PIX_FMT_SBGGR8,
		V4L2_FIELD_NONE,
		.sizeimage =
			HDCS_1X00_DEF_WIDTH * HDCS_1X00_DEF_HEIGHT,
		.bytesperline = HDCS_1X00_DEF_WIDTH,
		.colorspace = V4L2_COLORSPACE_SRGB,
		.priv = 1
	}
};

static const struct ctrl hdcs1020_ctrl[] = {};

static struct v4l2_pix_format hdcs1020_mode[] = {
	{
		HDCS_1020_DEF_WIDTH,
		HDCS_1020_DEF_HEIGHT,
		V4L2_PIX_FMT_SBGGR8,
		V4L2_FIELD_NONE,
		.sizeimage =
			HDCS_1020_DEF_WIDTH * HDCS_1020_DEF_HEIGHT,
		.bytesperline = HDCS_1020_DEF_WIDTH,
		.colorspace = V4L2_COLORSPACE_SRGB,
		.priv = 1
	}
};

enum hdcs_power_state {
	HDCS_STATE_SLEEP,
	HDCS_STATE_IDLE,
@@ -353,10 +413,10 @@ static int hdcs_probe_1x00(struct sd *sd)

	info("HDCS-1000/1100 sensor detected");

	sd->gspca_dev.cam.cam_mode = stv06xx_sensor_hdcs1x00.modes;
	sd->gspca_dev.cam.nmodes = stv06xx_sensor_hdcs1x00.nmodes;
	sd->desc.ctrls = stv06xx_sensor_hdcs1x00.ctrls;
	sd->desc.nctrls = stv06xx_sensor_hdcs1x00.nctrls;
	sd->gspca_dev.cam.cam_mode = hdcs1x00_mode;
	sd->gspca_dev.cam.nmodes = ARRAY_SIZE(hdcs1x00_mode);
	sd->desc.ctrls = hdcs1x00_ctrl;
	sd->desc.nctrls = ARRAY_SIZE(hdcs1x00_ctrl);

	hdcs = kmalloc(sizeof(struct hdcs), GFP_KERNEL);
	if (!hdcs)
@@ -412,10 +472,10 @@ static int hdcs_probe_1020(struct sd *sd)

	info("HDCS-1020 sensor detected");

	sd->gspca_dev.cam.cam_mode = stv06xx_sensor_hdcs1020.modes;
	sd->gspca_dev.cam.nmodes = stv06xx_sensor_hdcs1020.nmodes;
	sd->desc.ctrls = stv06xx_sensor_hdcs1020.ctrls;
	sd->desc.nctrls = stv06xx_sensor_hdcs1020.nctrls;
	sd->gspca_dev.cam.cam_mode = hdcs1020_mode;
	sd->gspca_dev.cam.nmodes = ARRAY_SIZE(hdcs1020_mode);
	sd->desc.ctrls = hdcs1020_ctrl;
	sd->desc.nctrls = ARRAY_SIZE(hdcs1020_ctrl);

	hdcs = kmalloc(sizeof(struct hdcs), GFP_KERNEL);
	if (!hdcs)
+0 −65
Original line number Diff line number Diff line
@@ -152,53 +152,6 @@ const struct stv06xx_sensor stv06xx_sensor_hdcs1x00 = {
	.stop = hdcs_stop,
	.disconnect = hdcs_disconnect,
	.dump = hdcs_dump,

	.nctrls = 2,
	.ctrls = {
	{
		{
			.id		= V4L2_CID_EXPOSURE,
			.type		= V4L2_CTRL_TYPE_INTEGER,
			.name		= "exposure",
			.minimum	= 0x00,
			.maximum	= 0xffff,
			.step		= 0x1,
			.default_value 	= HDCS_DEFAULT_EXPOSURE,
			.flags         	= V4L2_CTRL_FLAG_SLIDER
		},
		.set = hdcs_set_exposure,
		.get = hdcs_get_exposure
	},
	{
		{
			.id		= V4L2_CID_GAIN,
			.type		= V4L2_CTRL_TYPE_INTEGER,
			.name		= "gain",
			.minimum	= 0x00,
			.maximum	= 0xff,
			.step		= 0x1,
			.default_value 	= HDCS_DEFAULT_GAIN,
			.flags         	= V4L2_CTRL_FLAG_SLIDER
		},
		.set = hdcs_set_gain,
		.get = hdcs_get_gain
	}
	},

	.nmodes = 1,
	.modes = {
	{
		HDCS_1X00_DEF_WIDTH,
		HDCS_1X00_DEF_HEIGHT,
		V4L2_PIX_FMT_SBGGR8,
		V4L2_FIELD_NONE,
		.sizeimage =
			HDCS_1X00_DEF_WIDTH * HDCS_1X00_DEF_HEIGHT,
		.bytesperline = HDCS_1X00_DEF_WIDTH,
		.colorspace = V4L2_COLORSPACE_SRGB,
		.priv = 1
	}
	}
};

const struct stv06xx_sensor stv06xx_sensor_hdcs1020 = {
@@ -207,29 +160,11 @@ const struct stv06xx_sensor stv06xx_sensor_hdcs1020 = {
	.i2c_addr = (0x55 << 1),
	.i2c_len = 1,

	.nctrls = 0,
	.ctrls = {},

	.init = hdcs_init,
	.probe = hdcs_probe_1020,
	.start = hdcs_start,
	.stop = hdcs_stop,
	.dump = hdcs_dump,

	.nmodes = 1,
	.modes = {
	{
		HDCS_1020_DEF_WIDTH,
		HDCS_1020_DEF_HEIGHT,
		V4L2_PIX_FMT_SBGGR8,
		V4L2_FIELD_NONE,
		.sizeimage =
			HDCS_1020_DEF_WIDTH * HDCS_1020_DEF_HEIGHT,
		.bytesperline = HDCS_1020_DEF_WIDTH,
		.colorspace = V4L2_COLORSPACE_SRGB,
		.priv = 1
	}
	}
};

static const u16 stv_bridge_init[][2] = {
+133 −8
Original line number Diff line number Diff line
@@ -46,6 +46,132 @@

#include "stv06xx_pb0100.h"

static const struct ctrl pb0100_ctrl[] = {
#define GAIN_IDX 0
	{
		{
			.id		= V4L2_CID_GAIN,
			.type		= V4L2_CTRL_TYPE_INTEGER,
			.name		= "Gain",
			.minimum	= 0,
			.maximum	= 255,
			.step		= 1,
			.default_value  = 128
		},
		.set = pb0100_set_gain,
		.get = pb0100_get_gain
	},
#define RED_BALANCE_IDX 1
	{
		{
			.id		= V4L2_CID_RED_BALANCE,
			.type		= V4L2_CTRL_TYPE_INTEGER,
			.name		= "Red Balance",
			.minimum	= -255,
			.maximum	= 255,
			.step		= 1,
			.default_value  = 0
		},
		.set = pb0100_set_red_balance,
		.get = pb0100_get_red_balance
	},
#define BLUE_BALANCE_IDX 2
	{
		{
			.id		= V4L2_CID_BLUE_BALANCE,
			.type		= V4L2_CTRL_TYPE_INTEGER,
			.name		= "Blue Balance",
			.minimum	= -255,
			.maximum	= 255,
			.step		= 1,
			.default_value  = 0
		},
		.set = pb0100_set_blue_balance,
		.get = pb0100_get_blue_balance
	},
#define EXPOSURE_IDX 3
	{
		{
			.id		= V4L2_CID_EXPOSURE,
			.type		= V4L2_CTRL_TYPE_INTEGER,
			.name		= "Exposure",
			.minimum	= 0,
			.maximum	= 511,
			.step		= 1,
			.default_value  = 12
		},
		.set = pb0100_set_exposure,
		.get = pb0100_get_exposure
	},
#define AUTOGAIN_IDX 4
	{
		{
			.id		= V4L2_CID_AUTOGAIN,
			.type		= V4L2_CTRL_TYPE_BOOLEAN,
			.name		= "Automatic Gain and Exposure",
			.minimum	= 0,
			.maximum	= 1,
			.step		= 1,
			.default_value  = 1
		},
		.set = pb0100_set_autogain,
		.get = pb0100_get_autogain
	},
#define AUTOGAIN_TARGET_IDX 5
	{
		{
			.id		= V4L2_CTRL_CLASS_USER + 0x1000,
			.type		= V4L2_CTRL_TYPE_INTEGER,
			.name		= "Automatic Gain Target",
			.minimum	= 0,
			.maximum	= 255,
			.step		= 1,
			.default_value  = 128
		},
		.set = pb0100_set_autogain_target,
		.get = pb0100_get_autogain_target
	},
#define NATURAL_IDX 6
	{
		{
			.id		= V4L2_CTRL_CLASS_USER + 0x1001,
			.type		= V4L2_CTRL_TYPE_BOOLEAN,
			.name		= "Natural Light Source",
			.minimum	= 0,
			.maximum	= 1,
			.step		= 1,
			.default_value  = 1
		},
		.set = pb0100_set_natural,
		.get = pb0100_get_natural
	}
};

static struct v4l2_pix_format pb0100_mode[] = {
/* low res / subsample modes disabled as they are only half res horizontal,
   halving the vertical resolution does not seem to work */
	{
		320,
		240,
		V4L2_PIX_FMT_SGRBG8,
		V4L2_FIELD_NONE,
		.sizeimage = 320 * 240,
		.bytesperline = 320,
		.colorspace = V4L2_COLORSPACE_SRGB,
		.priv = PB0100_CROP_TO_VGA
	},
	{
		352,
		288,
		V4L2_PIX_FMT_SGRBG8,
		V4L2_FIELD_NONE,
		.sizeimage = 352 * 288,
		.bytesperline = 352,
		.colorspace = V4L2_COLORSPACE_SRGB,
		.priv = 0
	}
};

static int pb0100_probe(struct sd *sd)
{
	u16 sensor;
@@ -59,20 +185,19 @@ static int pb0100_probe(struct sd *sd)

	if ((sensor >> 8) == 0x64) {
		sensor_settings = kmalloc(
				stv06xx_sensor_pb0100.nctrls * sizeof(s32),
				ARRAY_SIZE(pb0100_ctrl) * sizeof(s32),
				GFP_KERNEL);
		if (!sensor_settings)
			return -ENOMEM;

		info("Photobit pb0100 sensor detected");

		sd->gspca_dev.cam.cam_mode = stv06xx_sensor_pb0100.modes;
		sd->gspca_dev.cam.nmodes = stv06xx_sensor_pb0100.nmodes;
		sd->desc.ctrls = stv06xx_sensor_pb0100.ctrls;
		sd->desc.nctrls = stv06xx_sensor_pb0100.nctrls;
		for (i = 0; i < stv06xx_sensor_pb0100.nctrls; i++)
			sensor_settings[i] = stv06xx_sensor_pb0100.
					     ctrls[i].qctrl.default_value;
		sd->gspca_dev.cam.cam_mode = pb0100_mode;
		sd->gspca_dev.cam.nmodes = ARRAY_SIZE(pb0100_mode);
		sd->desc.ctrls = pb0100_ctrl;
		sd->desc.nctrls = ARRAY_SIZE(pb0100_ctrl);
		for (i = 0; i < sd->desc.nctrls; i++)
			sensor_settings[i] = pb0100_ctrl[i].qctrl.default_value;
		sd->sensor_priv = sensor_settings;

		return 0;
+0 −128
Original line number Diff line number Diff line
@@ -137,139 +137,11 @@ const struct stv06xx_sensor stv06xx_sensor_pb0100 = {
	.i2c_addr = 0xba,
	.i2c_len = 2,

	.nctrls = 7,
	.ctrls = {
#define GAIN_IDX 0
	{
		{
			.id		= V4L2_CID_GAIN,
			.type		= V4L2_CTRL_TYPE_INTEGER,
			.name		= "Gain",
			.minimum	= 0,
			.maximum	= 255,
			.step		= 1,
			.default_value  = 128
		},
		.set = pb0100_set_gain,
		.get = pb0100_get_gain
	},
#define RED_BALANCE_IDX 1
	{
		{
			.id		= V4L2_CID_RED_BALANCE,
			.type		= V4L2_CTRL_TYPE_INTEGER,
			.name		= "Red Balance",
			.minimum	= -255,
			.maximum	= 255,
			.step		= 1,
			.default_value  = 0
		},
		.set = pb0100_set_red_balance,
		.get = pb0100_get_red_balance
	},
#define BLUE_BALANCE_IDX 2
	{
		{
			.id		= V4L2_CID_BLUE_BALANCE,
			.type		= V4L2_CTRL_TYPE_INTEGER,
			.name		= "Blue Balance",
			.minimum	= -255,
			.maximum	= 255,
			.step		= 1,
			.default_value  = 0
		},
		.set = pb0100_set_blue_balance,
		.get = pb0100_get_blue_balance
	},
#define EXPOSURE_IDX 3
	{
		{
			.id		= V4L2_CID_EXPOSURE,
			.type		= V4L2_CTRL_TYPE_INTEGER,
			.name		= "Exposure",
			.minimum	= 0,
			.maximum	= 511,
			.step		= 1,
			.default_value  = 12
		},
		.set = pb0100_set_exposure,
		.get = pb0100_get_exposure
	},
#define AUTOGAIN_IDX 4
	{
		{
			.id		= V4L2_CID_AUTOGAIN,
			.type		= V4L2_CTRL_TYPE_BOOLEAN,
			.name		= "Automatic Gain and Exposure",
			.minimum	= 0,
			.maximum	= 1,
			.step		= 1,
			.default_value  = 1
		},
		.set = pb0100_set_autogain,
		.get = pb0100_get_autogain
	},
#define AUTOGAIN_TARGET_IDX 5
	{
		{
			.id		= V4L2_CTRL_CLASS_USER + 0x1000,
			.type		= V4L2_CTRL_TYPE_INTEGER,
			.name		= "Automatic Gain Target",
			.minimum	= 0,
			.maximum	= 255,
			.step		= 1,
			.default_value  = 128
		},
		.set = pb0100_set_autogain_target,
		.get = pb0100_get_autogain_target
	},
#define NATURAL_IDX 6
	{
		{
			.id		= V4L2_CTRL_CLASS_USER + 0x1001,
			.type		= V4L2_CTRL_TYPE_BOOLEAN,
			.name		= "Natural Light Source",
			.minimum	= 0,
			.maximum	= 1,
			.step		= 1,
			.default_value  = 1
		},
		.set = pb0100_set_natural,
		.get = pb0100_get_natural
	},
	},

	.init = pb0100_init,
	.probe = pb0100_probe,
	.start = pb0100_start,
	.stop = pb0100_stop,
	.dump = pb0100_dump,

	.nmodes = 2,
	.modes = {
/* low res / subsample modes disabled as they are only half res horizontal,
   halving the vertical resolution does not seem to work */
	{
		320,
		240,
		V4L2_PIX_FMT_SGRBG8,
		V4L2_FIELD_NONE,
		.sizeimage = 320 * 240,
		.bytesperline = 320,
		.colorspace = V4L2_COLORSPACE_SRGB,
		.priv = PB0100_CROP_TO_VGA
	},
	{
		352,
		288,
		V4L2_PIX_FMT_SGRBG8,
		V4L2_FIELD_NONE,
		.sizeimage = 352 * 288,
		.bytesperline = 352,
		.colorspace = V4L2_COLORSPACE_SRGB,
		.priv = 0
	},
	}
};

#endif
+0 −8
Original line number Diff line number Diff line
@@ -41,8 +41,6 @@ extern const struct stv06xx_sensor stv06xx_sensor_hdcs1x00;
extern const struct stv06xx_sensor stv06xx_sensor_hdcs1020;
extern const struct stv06xx_sensor stv06xx_sensor_pb0100;

#define STV06XX_MAX_CTRLS		(V4L2_CID_LASTP1 - V4L2_CID_BASE + 10)

struct stv06xx_sensor {
	/* Defines the name of a sensor */
	char name[32];
@@ -81,12 +79,6 @@ struct stv06xx_sensor {

	/* Instructs the sensor to dump all its contents */
	int (*dump)(struct sd *sd);

	int nctrls;
	struct ctrl ctrls[STV06XX_MAX_CTRLS];

	char nmodes;
	struct v4l2_pix_format modes[];
};

#endif
Loading