[media] pwc: Remove driver specific ioctls
This stems from the v4l1 era, with v4l2 everything can be done with standardized v4l2 API calls. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
parent
dc8a7e83aa
commit
a08d2c7271
@ -460,15 +460,6 @@ Who: Jean Delvare <khali@linux-fr.org>
|
||||
|
||||
----------------------------
|
||||
|
||||
What: Support for driver specific ioctls in the pwc driver (everything
|
||||
defined in media/pwc-ioctl.h)
|
||||
When: 3.3
|
||||
Why: This stems from the v4l1 era, with v4l2 everything can be done with
|
||||
standardized v4l2 API calls
|
||||
Who: Hans de Goede <hdegoede@redhat.com>
|
||||
|
||||
----------------------------
|
||||
|
||||
What: Software emulation of arbritary resolutions in the pwc driver
|
||||
When: 3.3
|
||||
Why: The pwc driver claims to support any resolution between 160x120
|
||||
|
@ -604,136 +604,6 @@ int pwc_set_leds(struct pwc_device *pdev, int on_value, int off_value)
|
||||
return r;
|
||||
}
|
||||
|
||||
static int pwc_get_leds(struct pwc_device *pdev, int *on_value, int *off_value)
|
||||
{
|
||||
unsigned char buf[2];
|
||||
int ret;
|
||||
|
||||
if (pdev->type < 730) {
|
||||
*on_value = -1;
|
||||
*off_value = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = recv_control_msg(pdev,
|
||||
GET_STATUS_CTL, LED_FORMATTER, &buf, sizeof(buf));
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
*on_value = buf[0] * 100;
|
||||
*off_value = buf[1] * 100;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _pwc_mpt_reset(struct pwc_device *pdev, int flags)
|
||||
{
|
||||
unsigned char buf;
|
||||
int r;
|
||||
|
||||
mutex_lock(&pdev->udevlock);
|
||||
if (!pdev->udev) {
|
||||
r = -ENODEV;
|
||||
goto leave;
|
||||
}
|
||||
|
||||
buf = flags & 0x03; // only lower two bits are currently used
|
||||
r = send_control_msg(pdev,
|
||||
SET_MPT_CTL, PT_RESET_CONTROL_FORMATTER, &buf, sizeof(buf));
|
||||
leave:
|
||||
mutex_unlock(&pdev->udevlock);
|
||||
return r;
|
||||
}
|
||||
|
||||
int pwc_mpt_reset(struct pwc_device *pdev, int flags)
|
||||
{
|
||||
int ret;
|
||||
ret = _pwc_mpt_reset(pdev, flags);
|
||||
if (ret >= 0) {
|
||||
pdev->pan_angle = 0;
|
||||
pdev->tilt_angle = 0;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int _pwc_mpt_set_angle(struct pwc_device *pdev, int pan, int tilt)
|
||||
{
|
||||
unsigned char buf[4];
|
||||
int r;
|
||||
|
||||
mutex_lock(&pdev->udevlock);
|
||||
if (!pdev->udev) {
|
||||
r = -ENODEV;
|
||||
goto leave;
|
||||
}
|
||||
|
||||
/* set new relative angle; angles are expressed in degrees * 100,
|
||||
but cam as .5 degree resolution, hence divide by 200. Also
|
||||
the angle must be multiplied by 64 before it's send to
|
||||
the cam (??)
|
||||
*/
|
||||
pan = 64 * pan / 100;
|
||||
tilt = -64 * tilt / 100; /* positive tilt is down, which is not what the user would expect */
|
||||
buf[0] = pan & 0xFF;
|
||||
buf[1] = (pan >> 8) & 0xFF;
|
||||
buf[2] = tilt & 0xFF;
|
||||
buf[3] = (tilt >> 8) & 0xFF;
|
||||
r = send_control_msg(pdev,
|
||||
SET_MPT_CTL, PT_RELATIVE_CONTROL_FORMATTER, &buf, sizeof(buf));
|
||||
leave:
|
||||
mutex_unlock(&pdev->udevlock);
|
||||
return r;
|
||||
}
|
||||
|
||||
int pwc_mpt_set_angle(struct pwc_device *pdev, int pan, int tilt)
|
||||
{
|
||||
int ret;
|
||||
|
||||
/* check absolute ranges */
|
||||
if (pan < pdev->angle_range.pan_min ||
|
||||
pan > pdev->angle_range.pan_max ||
|
||||
tilt < pdev->angle_range.tilt_min ||
|
||||
tilt > pdev->angle_range.tilt_max)
|
||||
return -ERANGE;
|
||||
|
||||
/* go to relative range, check again */
|
||||
pan -= pdev->pan_angle;
|
||||
tilt -= pdev->tilt_angle;
|
||||
/* angles are specified in degrees * 100, thus the limit = 36000 */
|
||||
if (pan < -36000 || pan > 36000 || tilt < -36000 || tilt > 36000)
|
||||
return -ERANGE;
|
||||
|
||||
ret = _pwc_mpt_set_angle(pdev, pan, tilt);
|
||||
if (ret >= 0) {
|
||||
pdev->pan_angle += pan;
|
||||
pdev->tilt_angle += tilt;
|
||||
}
|
||||
if (ret == -EPIPE) /* stall -> out of range */
|
||||
ret = -ERANGE;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int pwc_mpt_get_status(struct pwc_device *pdev, struct pwc_mpt_status *status)
|
||||
{
|
||||
int ret;
|
||||
unsigned char buf[5];
|
||||
|
||||
mutex_lock(&pdev->udevlock);
|
||||
if (!pdev->udev) {
|
||||
ret = -ENODEV;
|
||||
goto leave;
|
||||
}
|
||||
|
||||
ret = recv_control_msg(pdev,
|
||||
GET_MPT_CTL, PT_STATUS_FORMATTER, &buf, sizeof(buf));
|
||||
if (ret < 0)
|
||||
goto leave;
|
||||
status->status = buf[0] & 0x7; // 3 bits are used for reporting
|
||||
status->time_pan = (buf[1] << 8) + buf[2];
|
||||
status->time_tilt = (buf[3] << 8) + buf[4];
|
||||
leave:
|
||||
mutex_unlock(&pdev->udevlock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_USB_PWC_DEBUG
|
||||
int pwc_get_cmos_sensor(struct pwc_device *pdev, int *sensor)
|
||||
{
|
||||
@ -758,444 +628,3 @@ int pwc_get_cmos_sensor(struct pwc_device *pdev, int *sensor)
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* End of Add-Ons */
|
||||
/* ************************************************* */
|
||||
|
||||
/* Linux 2.5.something and 2.6 pass direct pointers to arguments of
|
||||
ioctl() calls. With 2.4, you have to do tedious copy_from_user()
|
||||
and copy_to_user() calls. With these macros we circumvent this,
|
||||
and let me maintain only one source file. The functionality is
|
||||
exactly the same otherwise.
|
||||
*/
|
||||
|
||||
/* define local variable for arg */
|
||||
#define ARG_DEF(ARG_type, ARG_name)\
|
||||
ARG_type *ARG_name = arg;
|
||||
/* copy arg to local variable */
|
||||
#define ARG_IN(ARG_name) /* nothing */
|
||||
/* argument itself (referenced) */
|
||||
#define ARGR(ARG_name) (*ARG_name)
|
||||
/* argument address */
|
||||
#define ARGA(ARG_name) ARG_name
|
||||
/* copy local variable to arg */
|
||||
#define ARG_OUT(ARG_name) /* nothing */
|
||||
|
||||
/*
|
||||
* Our ctrls use native values, but the old custom pwc ioctl interface expects
|
||||
* values from 0 - 65535, define 2 helper functions to scale things. */
|
||||
static int pwc_ioctl_g_ctrl(struct v4l2_ctrl *ctrl)
|
||||
{
|
||||
return v4l2_ctrl_g_ctrl(ctrl) * 65535 / ctrl->maximum;
|
||||
}
|
||||
|
||||
static int pwc_ioctl_s_ctrl(struct v4l2_ctrl *ctrl, int val)
|
||||
{
|
||||
return v4l2_ctrl_s_ctrl(ctrl, val * ctrl->maximum / 65535);
|
||||
}
|
||||
|
||||
long pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
|
||||
{
|
||||
long ret = 0;
|
||||
|
||||
switch(cmd) {
|
||||
case VIDIOCPWCRUSER:
|
||||
ret = v4l2_ctrl_s_ctrl(pdev->restore_user, 0);
|
||||
break;
|
||||
|
||||
case VIDIOCPWCSUSER:
|
||||
ret = v4l2_ctrl_s_ctrl(pdev->save_user, 0);
|
||||
break;
|
||||
|
||||
case VIDIOCPWCFACTORY:
|
||||
ret = v4l2_ctrl_s_ctrl(pdev->restore_factory, 0);
|
||||
break;
|
||||
|
||||
case VIDIOCPWCSCQUAL:
|
||||
{
|
||||
ARG_DEF(int, qual)
|
||||
|
||||
mutex_lock(&pdev->udevlock);
|
||||
if (!pdev->udev) {
|
||||
ret = -ENODEV;
|
||||
goto leave;
|
||||
}
|
||||
|
||||
if (pdev->iso_init) {
|
||||
ret = -EBUSY;
|
||||
goto leave;
|
||||
}
|
||||
|
||||
ARG_IN(qual)
|
||||
if (ARGR(qual) < 0 || ARGR(qual) > 3)
|
||||
ret = -EINVAL;
|
||||
else
|
||||
ret = pwc_set_video_mode(pdev,
|
||||
pdev->view.x, pdev->view.y,
|
||||
pdev->vframes, ARGR(qual));
|
||||
leave:
|
||||
mutex_unlock(&pdev->udevlock);
|
||||
break;
|
||||
}
|
||||
|
||||
case VIDIOCPWCGCQUAL:
|
||||
{
|
||||
ARG_DEF(int, qual)
|
||||
|
||||
ARGR(qual) = pdev->vcompression;
|
||||
ARG_OUT(qual)
|
||||
break;
|
||||
}
|
||||
|
||||
case VIDIOCPWCPROBE:
|
||||
{
|
||||
ARG_DEF(struct pwc_probe, probe)
|
||||
|
||||
strcpy(ARGR(probe).name, pdev->vdev.name);
|
||||
ARGR(probe).type = pdev->type;
|
||||
ARG_OUT(probe)
|
||||
break;
|
||||
}
|
||||
|
||||
case VIDIOCPWCGSERIAL:
|
||||
{
|
||||
ARG_DEF(struct pwc_serial, serial)
|
||||
|
||||
strcpy(ARGR(serial).serial, pdev->serial);
|
||||
ARG_OUT(serial)
|
||||
break;
|
||||
}
|
||||
|
||||
case VIDIOCPWCSAGC:
|
||||
{
|
||||
ARG_DEF(int, agc)
|
||||
ARG_IN(agc)
|
||||
ret = v4l2_ctrl_s_ctrl(pdev->autogain, ARGR(agc) < 0);
|
||||
if (ret == 0 && ARGR(agc) >= 0)
|
||||
ret = pwc_ioctl_s_ctrl(pdev->gain, ARGR(agc));
|
||||
break;
|
||||
}
|
||||
|
||||
case VIDIOCPWCGAGC:
|
||||
{
|
||||
ARG_DEF(int, agc)
|
||||
if (v4l2_ctrl_g_ctrl(pdev->autogain))
|
||||
ARGR(agc) = -1;
|
||||
else
|
||||
ARGR(agc) = pwc_ioctl_g_ctrl(pdev->gain);
|
||||
ARG_OUT(agc)
|
||||
break;
|
||||
}
|
||||
|
||||
case VIDIOCPWCSSHUTTER:
|
||||
{
|
||||
ARG_DEF(int, shutter)
|
||||
ARG_IN(shutter)
|
||||
ret = v4l2_ctrl_s_ctrl(pdev->exposure_auto,
|
||||
/* Menu idx 0 = auto, idx 1 = manual */
|
||||
ARGR(shutter) >= 0);
|
||||
if (ret == 0 && ARGR(shutter) >= 0)
|
||||
ret = pwc_ioctl_s_ctrl(pdev->exposure, ARGR(shutter));
|
||||
break;
|
||||
}
|
||||
|
||||
case VIDIOCPWCSAWB:
|
||||
{
|
||||
ARG_DEF(struct pwc_whitebalance, wb)
|
||||
ARG_IN(wb)
|
||||
ret = v4l2_ctrl_s_ctrl(pdev->auto_white_balance,
|
||||
ARGR(wb).mode);
|
||||
if (ret == 0 && ARGR(wb).mode == PWC_WB_MANUAL)
|
||||
ret = pwc_ioctl_s_ctrl(pdev->red_balance,
|
||||
ARGR(wb).manual_red);
|
||||
if (ret == 0 && ARGR(wb).mode == PWC_WB_MANUAL)
|
||||
ret = pwc_ioctl_s_ctrl(pdev->blue_balance,
|
||||
ARGR(wb).manual_blue);
|
||||
break;
|
||||
}
|
||||
|
||||
case VIDIOCPWCGAWB:
|
||||
{
|
||||
ARG_DEF(struct pwc_whitebalance, wb)
|
||||
ARGR(wb).mode = v4l2_ctrl_g_ctrl(pdev->auto_white_balance);
|
||||
ARGR(wb).manual_red = ARGR(wb).read_red =
|
||||
pwc_ioctl_g_ctrl(pdev->red_balance);
|
||||
ARGR(wb).manual_blue = ARGR(wb).read_blue =
|
||||
pwc_ioctl_g_ctrl(pdev->blue_balance);
|
||||
ARG_OUT(wb)
|
||||
break;
|
||||
}
|
||||
|
||||
case VIDIOCPWCSAWBSPEED:
|
||||
{
|
||||
ARG_DEF(struct pwc_wb_speed, wbs)
|
||||
|
||||
if (ARGR(wbs).control_speed > 0) {
|
||||
ret = pwc_ioctl_s_ctrl(pdev->awb_speed,
|
||||
ARGR(wbs).control_speed);
|
||||
}
|
||||
if (ret == 0 && ARGR(wbs).control_delay > 0) {
|
||||
ret = pwc_ioctl_s_ctrl(pdev->awb_delay,
|
||||
ARGR(wbs).control_delay);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VIDIOCPWCGAWBSPEED:
|
||||
{
|
||||
ARG_DEF(struct pwc_wb_speed, wbs)
|
||||
|
||||
ARGR(wbs).control_speed = v4l2_ctrl_g_ctrl(pdev->awb_speed);
|
||||
ARGR(wbs).control_delay = v4l2_ctrl_g_ctrl(pdev->awb_delay);
|
||||
ARG_OUT(wbs)
|
||||
break;
|
||||
}
|
||||
|
||||
case VIDIOCPWCSLED:
|
||||
{
|
||||
ARG_DEF(struct pwc_leds, leds)
|
||||
|
||||
mutex_lock(&pdev->udevlock);
|
||||
if (!pdev->udev) {
|
||||
ret = -ENODEV;
|
||||
break;
|
||||
}
|
||||
|
||||
ARG_IN(leds)
|
||||
ret = pwc_set_leds(pdev, ARGR(leds).led_on, ARGR(leds).led_off);
|
||||
|
||||
mutex_unlock(&pdev->udevlock);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case VIDIOCPWCGLED:
|
||||
{
|
||||
ARG_DEF(struct pwc_leds, leds)
|
||||
|
||||
mutex_lock(&pdev->udevlock);
|
||||
if (!pdev->udev) {
|
||||
ret = -ENODEV;
|
||||
break;
|
||||
}
|
||||
|
||||
ret = pwc_get_leds(pdev, &ARGR(leds).led_on, &ARGR(leds).led_off);
|
||||
ARG_OUT(leds)
|
||||
|
||||
mutex_unlock(&pdev->udevlock);
|
||||
break;
|
||||
}
|
||||
|
||||
case VIDIOCPWCSCONTOUR:
|
||||
{
|
||||
ARG_DEF(int, contour)
|
||||
ARG_IN(contour)
|
||||
ret = v4l2_ctrl_s_ctrl(pdev->autocontour, ARGR(contour) < 0);
|
||||
if (ret == 0 && ARGR(contour) >= 0)
|
||||
ret = pwc_ioctl_s_ctrl(pdev->contour, ARGR(contour));
|
||||
break;
|
||||
}
|
||||
|
||||
case VIDIOCPWCGCONTOUR:
|
||||
{
|
||||
ARG_DEF(int, contour)
|
||||
if (v4l2_ctrl_g_ctrl(pdev->autocontour))
|
||||
ARGR(contour) = -1;
|
||||
else
|
||||
ARGR(contour) = pwc_ioctl_g_ctrl(pdev->contour);
|
||||
ARG_OUT(contour)
|
||||
break;
|
||||
}
|
||||
|
||||
case VIDIOCPWCSBACKLIGHT:
|
||||
{
|
||||
ARG_DEF(int, backlight)
|
||||
ARG_IN(backlight)
|
||||
ret = v4l2_ctrl_s_ctrl(pdev->backlight, ARGR(backlight));
|
||||
break;
|
||||
}
|
||||
|
||||
case VIDIOCPWCGBACKLIGHT:
|
||||
{
|
||||
ARG_DEF(int, backlight)
|
||||
ARGR(backlight) = v4l2_ctrl_g_ctrl(pdev->backlight);
|
||||
ARG_OUT(backlight)
|
||||
break;
|
||||
}
|
||||
|
||||
case VIDIOCPWCSFLICKER:
|
||||
{
|
||||
ARG_DEF(int, flicker)
|
||||
ARG_IN(flicker)
|
||||
ret = v4l2_ctrl_s_ctrl(pdev->flicker, ARGR(flicker));
|
||||
break;
|
||||
}
|
||||
|
||||
case VIDIOCPWCGFLICKER:
|
||||
{
|
||||
ARG_DEF(int, flicker)
|
||||
ARGR(flicker) = v4l2_ctrl_g_ctrl(pdev->flicker);
|
||||
ARG_OUT(flicker)
|
||||
break;
|
||||
}
|
||||
|
||||
case VIDIOCPWCSDYNNOISE:
|
||||
{
|
||||
ARG_DEF(int, dynnoise)
|
||||
ARG_IN(dynnoise)
|
||||
ret = v4l2_ctrl_s_ctrl(pdev->noise_reduction, ARGR(dynnoise));
|
||||
break;
|
||||
}
|
||||
|
||||
case VIDIOCPWCGDYNNOISE:
|
||||
{
|
||||
ARG_DEF(int, dynnoise)
|
||||
ARGR(dynnoise) = v4l2_ctrl_g_ctrl(pdev->noise_reduction);
|
||||
ARG_OUT(dynnoise);
|
||||
break;
|
||||
}
|
||||
|
||||
case VIDIOCPWCGREALSIZE:
|
||||
{
|
||||
ARG_DEF(struct pwc_imagesize, size)
|
||||
|
||||
ARGR(size).width = pdev->image.x;
|
||||
ARGR(size).height = pdev->image.y;
|
||||
ARG_OUT(size)
|
||||
break;
|
||||
}
|
||||
|
||||
case VIDIOCPWCMPTRESET:
|
||||
{
|
||||
if (pdev->features & FEATURE_MOTOR_PANTILT)
|
||||
{
|
||||
ARG_DEF(int, flags)
|
||||
|
||||
ARG_IN(flags)
|
||||
ret = pwc_mpt_reset(pdev, ARGR(flags));
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = -ENXIO;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VIDIOCPWCMPTGRANGE:
|
||||
{
|
||||
if (pdev->features & FEATURE_MOTOR_PANTILT)
|
||||
{
|
||||
ARG_DEF(struct pwc_mpt_range, range)
|
||||
|
||||
ARGR(range) = pdev->angle_range;
|
||||
ARG_OUT(range)
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = -ENXIO;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VIDIOCPWCMPTSANGLE:
|
||||
{
|
||||
int new_pan, new_tilt;
|
||||
|
||||
if (pdev->features & FEATURE_MOTOR_PANTILT)
|
||||
{
|
||||
ARG_DEF(struct pwc_mpt_angles, angles)
|
||||
|
||||
ARG_IN(angles)
|
||||
/* The camera can only set relative angles, so
|
||||
do some calculations when getting an absolute angle .
|
||||
*/
|
||||
if (ARGR(angles).absolute)
|
||||
{
|
||||
new_pan = ARGR(angles).pan;
|
||||
new_tilt = ARGR(angles).tilt;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_pan = pdev->pan_angle + ARGR(angles).pan;
|
||||
new_tilt = pdev->tilt_angle + ARGR(angles).tilt;
|
||||
}
|
||||
ret = pwc_mpt_set_angle(pdev, new_pan, new_tilt);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = -ENXIO;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VIDIOCPWCMPTGANGLE:
|
||||
{
|
||||
|
||||
if (pdev->features & FEATURE_MOTOR_PANTILT)
|
||||
{
|
||||
ARG_DEF(struct pwc_mpt_angles, angles)
|
||||
|
||||
ARGR(angles).absolute = 1;
|
||||
ARGR(angles).pan = pdev->pan_angle;
|
||||
ARGR(angles).tilt = pdev->tilt_angle;
|
||||
ARG_OUT(angles)
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = -ENXIO;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VIDIOCPWCMPTSTATUS:
|
||||
{
|
||||
if (pdev->features & FEATURE_MOTOR_PANTILT)
|
||||
{
|
||||
ARG_DEF(struct pwc_mpt_status, status)
|
||||
|
||||
ret = pwc_mpt_get_status(pdev, ARGA(status));
|
||||
ARG_OUT(status)
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = -ENXIO;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VIDIOCPWCGVIDCMD:
|
||||
{
|
||||
ARG_DEF(struct pwc_video_command, vcmd);
|
||||
|
||||
ARGR(vcmd).type = pdev->type;
|
||||
ARGR(vcmd).release = pdev->release;
|
||||
ARGR(vcmd).command_len = pdev->cmd_len;
|
||||
memcpy(&ARGR(vcmd).command_buf, pdev->cmd_buf, pdev->cmd_len);
|
||||
ARGR(vcmd).bandlength = pdev->vbandlength;
|
||||
ARGR(vcmd).frame_size = pdev->frame_size;
|
||||
ARG_OUT(vcmd)
|
||||
break;
|
||||
}
|
||||
/*
|
||||
case VIDIOCPWCGVIDTABLE:
|
||||
{
|
||||
ARG_DEF(struct pwc_table_init_buffer, table);
|
||||
ARGR(table).len = pdev->cmd_len;
|
||||
memcpy(&ARGR(table).buffer, pdev->decompress_data, pdev->decompressor->table_size);
|
||||
ARG_OUT(table)
|
||||
break;
|
||||
}
|
||||
*/
|
||||
|
||||
default:
|
||||
ret = -ENOIOCTLCMD;
|
||||
break;
|
||||
}
|
||||
|
||||
if (ret > 0)
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* vim: set cinoptions= formatoptions=croql cindent shiftwidth=8 tabstop=8: */
|
||||
|
@ -27,7 +27,6 @@
|
||||
#include "pwc-timon.h"
|
||||
#include "pwc-kiara.h"
|
||||
#include "pwc-dec23.h"
|
||||
#include <media/pwc-ioctl.h>
|
||||
|
||||
#include <linux/string.h>
|
||||
#include <linux/slab.h>
|
||||
|
@ -1058,16 +1058,6 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
|
||||
pdev->vframes = default_fps;
|
||||
strcpy(pdev->serial, serial_number);
|
||||
pdev->features = features;
|
||||
if (vendor_id == 0x046D && product_id == 0x08B5) {
|
||||
/* Logitech QuickCam Orbit
|
||||
The ranges have been determined experimentally; they may differ from cam to cam.
|
||||
Also, the exact ranges left-right and up-down are different for my cam
|
||||
*/
|
||||
pdev->angle_range.pan_min = -7000;
|
||||
pdev->angle_range.pan_max = 7000;
|
||||
pdev->angle_range.tilt_min = -3000;
|
||||
pdev->angle_range.tilt_max = 2500;
|
||||
}
|
||||
pwc_construct(pdev); /* set min/max sizes correct */
|
||||
|
||||
mutex_init(&pdev->capt_file_lock);
|
||||
|
@ -27,7 +27,7 @@
|
||||
#ifndef PWC_KIARA_H
|
||||
#define PWC_KIARA_H
|
||||
|
||||
#include <media/pwc-ioctl.h>
|
||||
#include "pwc.h"
|
||||
|
||||
#define PWC_FPS_MAX_KIARA 6
|
||||
|
||||
|
@ -42,7 +42,7 @@
|
||||
#ifndef PWC_TIMON_H
|
||||
#define PWC_TIMON_H
|
||||
|
||||
#include <media/pwc-ioctl.h>
|
||||
#include "pwc.h"
|
||||
|
||||
#define PWC_FPS_MAX_TIMON 6
|
||||
|
||||
|
@ -1122,14 +1122,6 @@ static int pwc_log_status(struct file *file, void *priv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static long pwc_default(struct file *file, void *fh, bool valid_prio,
|
||||
int cmd, void *arg)
|
||||
{
|
||||
struct pwc_device *pdev = video_drvdata(file);
|
||||
|
||||
return pwc_ioctl(pdev, cmd, arg);
|
||||
}
|
||||
|
||||
const struct v4l2_ioctl_ops pwc_ioctl_ops = {
|
||||
.vidioc_querycap = pwc_querycap,
|
||||
.vidioc_enum_input = pwc_enum_input,
|
||||
@ -1148,8 +1140,4 @@ const struct v4l2_ioctl_ops pwc_ioctl_ops = {
|
||||
.vidioc_log_status = pwc_log_status,
|
||||
.vidioc_enum_framesizes = pwc_enum_framesizes,
|
||||
.vidioc_enum_frameintervals = pwc_enum_frameintervals,
|
||||
.vidioc_default = pwc_default,
|
||||
};
|
||||
|
||||
|
||||
/* vim: set cino= formatoptions=croql cindent shiftwidth=8 tabstop=8: */
|
||||
|
@ -45,8 +45,6 @@
|
||||
#include <linux/input.h>
|
||||
#endif
|
||||
|
||||
#include <media/pwc-ioctl.h>
|
||||
|
||||
/* Version block */
|
||||
#define PWC_VERSION "10.0.15"
|
||||
#define PWC_NAME "pwc"
|
||||
@ -189,6 +187,30 @@
|
||||
#define PT_RESET_CONTROL_FORMATTER 0x02
|
||||
#define PT_STATUS_FORMATTER 0x03
|
||||
|
||||
/* Enumeration of image sizes */
|
||||
#define PSZ_SQCIF 0x00
|
||||
#define PSZ_QSIF 0x01
|
||||
#define PSZ_QCIF 0x02
|
||||
#define PSZ_SIF 0x03
|
||||
#define PSZ_CIF 0x04
|
||||
#define PSZ_VGA 0x05
|
||||
#define PSZ_MAX 6
|
||||
|
||||
struct pwc_raw_frame {
|
||||
__le16 type; /* type of the webcam */
|
||||
__le16 vbandlength; /* Size of 4 lines compressed (used by the
|
||||
decompressor) */
|
||||
__u8 cmd[4]; /* the four byte of the command (in case of
|
||||
nala, only the first 3 bytes is filled) */
|
||||
__u8 rawframe[0]; /* frame_size = H / 4 * vbandlength */
|
||||
} __packed;
|
||||
|
||||
/* structure for transferring x & y coordinates */
|
||||
struct pwc_coord {
|
||||
int x, y; /* guess what */
|
||||
int size; /* size, or offset */
|
||||
};
|
||||
|
||||
/* intermediate buffers with raw data from the USB cam */
|
||||
struct pwc_frame_buf
|
||||
{
|
||||
@ -269,11 +291,6 @@ struct pwc_device
|
||||
struct pwc_coord image, view; /* image and viewport size */
|
||||
struct pwc_coord offset; /* offset of the viewport */
|
||||
|
||||
/*** motorized pan/tilt feature */
|
||||
struct pwc_mpt_range angle_range;
|
||||
int pan_angle; /* in degrees * 100 */
|
||||
int tilt_angle; /* absolute angle; 0,0 is home */
|
||||
|
||||
#ifdef CONFIG_USB_PWC_INPUT_EVDEV
|
||||
struct input_dev *button_dev; /* webcam snapshot button input */
|
||||
char button_phys[64];
|
||||
@ -357,8 +374,6 @@ void pwc_construct(struct pwc_device *pdev);
|
||||
extern int pwc_set_video_mode(struct pwc_device *pdev, int width, int height,
|
||||
int frames, int compression);
|
||||
extern unsigned int pwc_get_fps(struct pwc_device *pdev, unsigned int index, unsigned int size);
|
||||
extern int pwc_mpt_reset(struct pwc_device *pdev, int flags);
|
||||
extern int pwc_mpt_set_angle(struct pwc_device *pdev, int pan, int tilt);
|
||||
extern int pwc_set_leds(struct pwc_device *pdev, int on_value, int off_value);
|
||||
extern int pwc_get_cmos_sensor(struct pwc_device *pdev, int *sensor);
|
||||
extern int send_control_msg(struct pwc_device *pdev,
|
||||
@ -377,9 +392,6 @@ int pwc_init_controls(struct pwc_device *pdev);
|
||||
/* Power down or up the camera; not supported by all models */
|
||||
extern void pwc_camera_power(struct pwc_device *pdev, int power);
|
||||
|
||||
/* Private ioctl()s; see pwc-ioctl.h */
|
||||
extern long pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg);
|
||||
|
||||
extern const struct v4l2_ioctl_ops pwc_ioctl_ops;
|
||||
|
||||
/** pwc-uncompress.c */
|
||||
|
@ -1,323 +0,0 @@
|
||||
#ifndef PWC_IOCTL_H
|
||||
#define PWC_IOCTL_H
|
||||
|
||||
/* (C) 2001-2004 Nemosoft Unv.
|
||||
(C) 2004-2006 Luc Saillard (luc@saillard.org)
|
||||
|
||||
NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
|
||||
driver and thus may have bugs that are not present in the original version.
|
||||
Please send bug reports and support requests to <luc@saillard.org>.
|
||||
The decompression routines have been implemented by reverse-engineering the
|
||||
Nemosoft binary pwcx module. Caveat emptor.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* This is pwc-ioctl.h belonging to PWC 10.0.10
|
||||
It contains structures and defines to communicate from user space
|
||||
directly to the driver.
|
||||
*/
|
||||
|
||||
/*
|
||||
Changes
|
||||
2001/08/03 Alvarado Added ioctl constants to access methods for
|
||||
changing white balance and red/blue gains
|
||||
2002/12/15 G. H. Fernandez-Toribio VIDIOCGREALSIZE
|
||||
2003/12/13 Nemosft Unv. Some modifications to make interfacing to
|
||||
PWCX easier
|
||||
2006/01/01 Luc Saillard Add raw format definition
|
||||
*/
|
||||
|
||||
/* These are private ioctl() commands, specific for the Philips webcams.
|
||||
They contain functions not found in other webcams, and settings not
|
||||
specified in the Video4Linux API.
|
||||
|
||||
The #define names are built up like follows:
|
||||
VIDIOC VIDeo IOCtl prefix
|
||||
PWC Philps WebCam
|
||||
G optional: Get
|
||||
S optional: Set
|
||||
... the function
|
||||
*/
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
/* Enumeration of image sizes */
|
||||
#define PSZ_SQCIF 0x00
|
||||
#define PSZ_QSIF 0x01
|
||||
#define PSZ_QCIF 0x02
|
||||
#define PSZ_SIF 0x03
|
||||
#define PSZ_CIF 0x04
|
||||
#define PSZ_VGA 0x05
|
||||
#define PSZ_MAX 6
|
||||
|
||||
|
||||
/* The frame rate is encoded in the video_window.flags parameter using
|
||||
the upper 16 bits, since some flags are defined nowadays. The following
|
||||
defines provide a mask and shift to filter out this value.
|
||||
This value can also be passing using the private flag when using v4l2 and
|
||||
VIDIOC_S_FMT ioctl.
|
||||
|
||||
In 'Snapshot' mode the camera freezes its automatic exposure and colour
|
||||
balance controls.
|
||||
*/
|
||||
#define PWC_FPS_SHIFT 16
|
||||
#define PWC_FPS_MASK 0x00FF0000
|
||||
#define PWC_FPS_FRMASK 0x003F0000
|
||||
#define PWC_FPS_SNAPSHOT 0x00400000
|
||||
#define PWC_QLT_MASK 0x03000000
|
||||
#define PWC_QLT_SHIFT 24
|
||||
|
||||
|
||||
/* structure for transferring x & y coordinates */
|
||||
struct pwc_coord
|
||||
{
|
||||
int x, y; /* guess what */
|
||||
int size; /* size, or offset */
|
||||
};
|
||||
|
||||
|
||||
/* Used with VIDIOCPWCPROBE */
|
||||
struct pwc_probe
|
||||
{
|
||||
char name[32];
|
||||
int type;
|
||||
};
|
||||
|
||||
struct pwc_serial
|
||||
{
|
||||
char serial[30]; /* String with serial number. Contains terminating 0 */
|
||||
};
|
||||
|
||||
/* pwc_whitebalance.mode values */
|
||||
#define PWC_WB_INDOOR 0
|
||||
#define PWC_WB_OUTDOOR 1
|
||||
#define PWC_WB_FL 2
|
||||
#define PWC_WB_MANUAL 3
|
||||
#define PWC_WB_AUTO 4
|
||||
|
||||
/* Used with VIDIOCPWC[SG]AWB (Auto White Balance).
|
||||
Set mode to one of the PWC_WB_* values above.
|
||||
*red and *blue are the respective gains of these colour components inside
|
||||
the camera; range 0..65535
|
||||
When 'mode' == PWC_WB_MANUAL, 'manual_red' and 'manual_blue' are set or read;
|
||||
otherwise undefined.
|
||||
'read_red' and 'read_blue' are read-only.
|
||||
*/
|
||||
struct pwc_whitebalance
|
||||
{
|
||||
int mode;
|
||||
int manual_red, manual_blue; /* R/W */
|
||||
int read_red, read_blue; /* R/O */
|
||||
};
|
||||
|
||||
/*
|
||||
'control_speed' and 'control_delay' are used in automatic whitebalance mode,
|
||||
and tell the camera how fast it should react to changes in lighting, and
|
||||
with how much delay. Valid values are 0..65535.
|
||||
*/
|
||||
struct pwc_wb_speed
|
||||
{
|
||||
int control_speed;
|
||||
int control_delay;
|
||||
|
||||
};
|
||||
|
||||
/* Used with VIDIOCPWC[SG]LED */
|
||||
struct pwc_leds
|
||||
{
|
||||
int led_on; /* Led on-time; range = 0..25000 */
|
||||
int led_off; /* Led off-time; range = 0..25000 */
|
||||
};
|
||||
|
||||
/* Image size (used with GREALSIZE) */
|
||||
struct pwc_imagesize
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
};
|
||||
|
||||
/* Defines and structures for Motorized Pan & Tilt */
|
||||
#define PWC_MPT_PAN 0x01
|
||||
#define PWC_MPT_TILT 0x02
|
||||
#define PWC_MPT_TIMEOUT 0x04 /* for status */
|
||||
|
||||
/* Set angles; when absolute != 0, the angle is absolute and the
|
||||
driver calculates the relative offset for you. This can only
|
||||
be used with VIDIOCPWCSANGLE; VIDIOCPWCGANGLE always returns
|
||||
absolute angles.
|
||||
*/
|
||||
struct pwc_mpt_angles
|
||||
{
|
||||
int absolute; /* write-only */
|
||||
int pan; /* degrees * 100 */
|
||||
int tilt; /* degress * 100 */
|
||||
};
|
||||
|
||||
/* Range of angles of the camera, both horizontally and vertically.
|
||||
*/
|
||||
struct pwc_mpt_range
|
||||
{
|
||||
int pan_min, pan_max; /* degrees * 100 */
|
||||
int tilt_min, tilt_max;
|
||||
};
|
||||
|
||||
struct pwc_mpt_status
|
||||
{
|
||||
int status;
|
||||
int time_pan;
|
||||
int time_tilt;
|
||||
};
|
||||
|
||||
|
||||
/* This is used for out-of-kernel decompression. With it, you can get
|
||||
all the necessary information to initialize and use the decompressor
|
||||
routines in standalone applications.
|
||||
*/
|
||||
struct pwc_video_command
|
||||
{
|
||||
int type; /* camera type (645, 675, 730, etc.) */
|
||||
int release; /* release number */
|
||||
|
||||
int size; /* one of PSZ_* */
|
||||
int alternate;
|
||||
int command_len; /* length of USB video command */
|
||||
unsigned char command_buf[13]; /* Actual USB video command */
|
||||
int bandlength; /* >0 = compressed */
|
||||
int frame_size; /* Size of one (un)compressed frame */
|
||||
};
|
||||
|
||||
/* Flags for PWCX subroutines. Not all modules honour all flags. */
|
||||
#define PWCX_FLAG_PLANAR 0x0001
|
||||
#define PWCX_FLAG_BAYER 0x0008
|
||||
|
||||
|
||||
/* IOCTL definitions */
|
||||
|
||||
/* Restore user settings */
|
||||
#define VIDIOCPWCRUSER _IO('v', 192)
|
||||
/* Save user settings */
|
||||
#define VIDIOCPWCSUSER _IO('v', 193)
|
||||
/* Restore factory settings */
|
||||
#define VIDIOCPWCFACTORY _IO('v', 194)
|
||||
|
||||
/* You can manipulate the compression factor. A compression preference of 0
|
||||
means use uncompressed modes when available; 1 is low compression, 2 is
|
||||
medium and 3 is high compression preferred. Of course, the higher the
|
||||
compression, the lower the bandwidth used but more chance of artefacts
|
||||
in the image. The driver automatically chooses a higher compression when
|
||||
the preferred mode is not available.
|
||||
*/
|
||||
/* Set preferred compression quality (0 = uncompressed, 3 = highest compression) */
|
||||
#define VIDIOCPWCSCQUAL _IOW('v', 195, int)
|
||||
/* Get preferred compression quality */
|
||||
#define VIDIOCPWCGCQUAL _IOR('v', 195, int)
|
||||
|
||||
|
||||
/* Retrieve serial number of camera */
|
||||
#define VIDIOCPWCGSERIAL _IOR('v', 198, struct pwc_serial)
|
||||
|
||||
/* This is a probe function; since so many devices are supported, it
|
||||
becomes difficult to include all the names in programs that want to
|
||||
check for the enhanced Philips stuff. So in stead, try this PROBE;
|
||||
it returns a structure with the original name, and the corresponding
|
||||
Philips type.
|
||||
To use, fill the structure with zeroes, call PROBE and if that succeeds,
|
||||
compare the name with that returned from VIDIOCGCAP; they should be the
|
||||
same. If so, you can be assured it is a Philips (OEM) cam and the type
|
||||
is valid.
|
||||
*/
|
||||
#define VIDIOCPWCPROBE _IOR('v', 199, struct pwc_probe)
|
||||
|
||||
/* Set AGC (Automatic Gain Control); int < 0 = auto, 0..65535 = fixed */
|
||||
#define VIDIOCPWCSAGC _IOW('v', 200, int)
|
||||
/* Get AGC; int < 0 = auto; >= 0 = fixed, range 0..65535 */
|
||||
#define VIDIOCPWCGAGC _IOR('v', 200, int)
|
||||
/* Set shutter speed; int < 0 = auto; >= 0 = fixed, range 0..65535 */
|
||||
#define VIDIOCPWCSSHUTTER _IOW('v', 201, int)
|
||||
|
||||
/* Color compensation (Auto White Balance) */
|
||||
#define VIDIOCPWCSAWB _IOW('v', 202, struct pwc_whitebalance)
|
||||
#define VIDIOCPWCGAWB _IOR('v', 202, struct pwc_whitebalance)
|
||||
|
||||
/* Auto WB speed */
|
||||
#define VIDIOCPWCSAWBSPEED _IOW('v', 203, struct pwc_wb_speed)
|
||||
#define VIDIOCPWCGAWBSPEED _IOR('v', 203, struct pwc_wb_speed)
|
||||
|
||||
/* LEDs on/off/blink; int range 0..65535 */
|
||||
#define VIDIOCPWCSLED _IOW('v', 205, struct pwc_leds)
|
||||
#define VIDIOCPWCGLED _IOR('v', 205, struct pwc_leds)
|
||||
|
||||
/* Contour (sharpness); int < 0 = auto, 0..65536 = fixed */
|
||||
#define VIDIOCPWCSCONTOUR _IOW('v', 206, int)
|
||||
#define VIDIOCPWCGCONTOUR _IOR('v', 206, int)
|
||||
|
||||
/* Backlight compensation; 0 = off, otherwise on */
|
||||
#define VIDIOCPWCSBACKLIGHT _IOW('v', 207, int)
|
||||
#define VIDIOCPWCGBACKLIGHT _IOR('v', 207, int)
|
||||
|
||||
/* Flickerless mode; = 0 off, otherwise on */
|
||||
#define VIDIOCPWCSFLICKER _IOW('v', 208, int)
|
||||
#define VIDIOCPWCGFLICKER _IOR('v', 208, int)
|
||||
|
||||
/* Dynamic noise reduction; 0 off, 3 = high noise reduction */
|
||||
#define VIDIOCPWCSDYNNOISE _IOW('v', 209, int)
|
||||
#define VIDIOCPWCGDYNNOISE _IOR('v', 209, int)
|
||||
|
||||
/* Real image size as used by the camera; tells you whether or not there's a gray border around the image */
|
||||
#define VIDIOCPWCGREALSIZE _IOR('v', 210, struct pwc_imagesize)
|
||||
|
||||
/* Motorized pan & tilt functions */
|
||||
#define VIDIOCPWCMPTRESET _IOW('v', 211, int)
|
||||
#define VIDIOCPWCMPTGRANGE _IOR('v', 211, struct pwc_mpt_range)
|
||||
#define VIDIOCPWCMPTSANGLE _IOW('v', 212, struct pwc_mpt_angles)
|
||||
#define VIDIOCPWCMPTGANGLE _IOR('v', 212, struct pwc_mpt_angles)
|
||||
#define VIDIOCPWCMPTSTATUS _IOR('v', 213, struct pwc_mpt_status)
|
||||
|
||||
/* Get the USB set-video command; needed for initializing libpwcx */
|
||||
#define VIDIOCPWCGVIDCMD _IOR('v', 215, struct pwc_video_command)
|
||||
struct pwc_table_init_buffer {
|
||||
int len;
|
||||
char *buffer;
|
||||
|
||||
};
|
||||
#define VIDIOCPWCGVIDTABLE _IOR('v', 216, struct pwc_table_init_buffer)
|
||||
|
||||
/*
|
||||
* This is private command used when communicating with v4l2.
|
||||
* In the future all private ioctl will be remove/replace to
|
||||
* use interface offer by v4l2.
|
||||
*/
|
||||
|
||||
#define V4L2_CID_PRIVATE_SAVE_USER (V4L2_CID_PRIVATE_BASE + 0)
|
||||
#define V4L2_CID_PRIVATE_RESTORE_USER (V4L2_CID_PRIVATE_BASE + 1)
|
||||
#define V4L2_CID_PRIVATE_RESTORE_FACTORY (V4L2_CID_PRIVATE_BASE + 2)
|
||||
#define V4L2_CID_PRIVATE_COLOUR_MODE (V4L2_CID_PRIVATE_BASE + 3)
|
||||
#define V4L2_CID_PRIVATE_AUTOCONTOUR (V4L2_CID_PRIVATE_BASE + 4)
|
||||
#define V4L2_CID_PRIVATE_CONTOUR (V4L2_CID_PRIVATE_BASE + 5)
|
||||
#define V4L2_CID_PRIVATE_BACKLIGHT (V4L2_CID_PRIVATE_BASE + 6)
|
||||
#define V4L2_CID_PRIVATE_FLICKERLESS (V4L2_CID_PRIVATE_BASE + 7)
|
||||
#define V4L2_CID_PRIVATE_NOISE_REDUCTION (V4L2_CID_PRIVATE_BASE + 8)
|
||||
|
||||
struct pwc_raw_frame {
|
||||
__le16 type; /* type of the webcam */
|
||||
__le16 vbandlength; /* Size of 4lines compressed (used by the decompressor) */
|
||||
__u8 cmd[4]; /* the four byte of the command (in case of nala,
|
||||
only the first 3 bytes is filled) */
|
||||
__u8 rawframe[0]; /* frame_size = H/4*vbandlength */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user