mirror of
https://github.com/patjak/facetimehd.git
synced 2026-04-09 19:10:01 +02:00
Merge branch 'my_fixes' of git://github.com/sschnelle/facetimehd
This commit is contained in:
@@ -199,7 +199,6 @@ static void fthd_handle_irq(struct fthd_private *dev_priv, struct fw_channel *ch
|
|||||||
} else if (chan == dev_priv->channel_buf_t2h) {
|
} else if (chan == dev_priv->channel_buf_t2h) {
|
||||||
buf_t2h_handler(dev_priv, chan, entry);
|
buf_t2h_handler(dev_priv, chan, entry);
|
||||||
} else if (chan == dev_priv->channel_io) {
|
} else if (chan == dev_priv->channel_io) {
|
||||||
dev_priv->cmd_ready = 1;
|
|
||||||
wake_up_interruptible(&dev_priv->cmd_wq);
|
wake_up_interruptible(&dev_priv->cmd_wq);
|
||||||
} else if (chan == dev_priv->channel_io_t2h) {
|
} else if (chan == dev_priv->channel_io_t2h) {
|
||||||
io_t2h_handler(dev_priv, chan, entry);
|
io_t2h_handler(dev_priv, chan, entry);
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include <linux/mutex.h>
|
#include <linux/mutex.h>
|
||||||
#include <media/videobuf2-dma-sg.h>
|
#include <media/videobuf2-dma-sg.h>
|
||||||
#include <media/v4l2-device.h>
|
#include <media/v4l2-device.h>
|
||||||
|
#include <media/v4l2-ctrls.h>
|
||||||
#include "fthd_reg.h"
|
#include "fthd_reg.h"
|
||||||
#include "fthd_ringbuf.h"
|
#include "fthd_ringbuf.h"
|
||||||
#include "fthd_buffer.h"
|
#include "fthd_buffer.h"
|
||||||
@@ -69,7 +70,7 @@ struct fthd_private {
|
|||||||
|
|
||||||
/* waitqueue for signaling command completion */
|
/* waitqueue for signaling command completion */
|
||||||
wait_queue_head_t cmd_wq;
|
wait_queue_head_t cmd_wq;
|
||||||
int cmd_ready;
|
|
||||||
/* Mapped PCI resources */
|
/* Mapped PCI resources */
|
||||||
void __iomem *s2_io;
|
void __iomem *s2_io;
|
||||||
u32 s2_io_len;
|
u32 s2_io_len;
|
||||||
@@ -124,6 +125,7 @@ struct fthd_private {
|
|||||||
struct vb2_alloc_ctx *alloc_ctx;
|
struct vb2_alloc_ctx *alloc_ctx;
|
||||||
struct h2t_buf_ctx h2t_bufs[FTHD_BUFFERS];
|
struct h2t_buf_ctx h2t_bufs[FTHD_BUFFERS];
|
||||||
|
|
||||||
|
struct v4l2_ctrl_handler v4l2_ctrl_handler;
|
||||||
int frametime;
|
int frametime;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
33
fthd_isp.c
33
fthd_isp.c
@@ -311,7 +311,8 @@ static int fthd_isp_cmd(struct fthd_private *dev_priv, enum fthd_isp_cmds comman
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wait_event_interruptible_timeout(dev_priv->cmd_wq, dev_priv->cmd_ready, HZ) <= 0) {
|
if (wait_event_interruptible_timeout(dev_priv->cmd_wq,
|
||||||
|
FTHD_S2_MEM_READ(entry + FTHD_RINGBUF_ADDRESS_FLAGS) & 1, HZ) <= 0) {
|
||||||
dev_err(&dev_priv->pdev->dev, "timeout wait for command %d\n", cmd.opcode);
|
dev_err(&dev_priv->pdev->dev, "timeout wait for command %d\n", cmd.opcode);
|
||||||
fthd_channel_ringbuf_dump(dev_priv, dev_priv->channel_io);
|
fthd_channel_ringbuf_dump(dev_priv, dev_priv->channel_io);
|
||||||
if (response_len)
|
if (response_len)
|
||||||
@@ -320,8 +321,6 @@ static int fthd_isp_cmd(struct fthd_private *dev_priv, enum fthd_isp_cmds comman
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
dev_priv->cmd_ready = 0;
|
|
||||||
|
|
||||||
FTHD_S2_MEMCPY_FROMIO(&cmd, request->offset, sizeof(struct isp_cmd_hdr));
|
FTHD_S2_MEMCPY_FROMIO(&cmd, request->offset, sizeof(struct isp_cmd_hdr));
|
||||||
address = FTHD_S2_MEM_READ(entry + FTHD_RINGBUF_ADDRESS_FLAGS);
|
address = FTHD_S2_MEM_READ(entry + FTHD_RINGBUF_ADDRESS_FLAGS);
|
||||||
request_size = FTHD_S2_MEM_READ(entry + FTHD_RINGBUF_REQUEST_SIZE);
|
request_size = FTHD_S2_MEM_READ(entry + FTHD_RINGBUF_REQUEST_SIZE);
|
||||||
@@ -1003,6 +1002,34 @@ int fthd_isp_cmd_channel_contrast_set(struct fthd_private *dev_priv, int channel
|
|||||||
return fthd_isp_cmd(dev_priv, CISP_CMD_CH_SCALER_CONTRAST_SET, &cmd, sizeof(cmd), &len);
|
return fthd_isp_cmd(dev_priv, CISP_CMD_CH_SCALER_CONTRAST_SET, &cmd, sizeof(cmd), &len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int fthd_isp_cmd_channel_saturation_set(struct fthd_private *dev_priv, int channel, int saturation)
|
||||||
|
{
|
||||||
|
struct isp_cmd_channel_saturation_set cmd;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
pr_debug("set saturation %d\n", saturation);
|
||||||
|
|
||||||
|
memset(&cmd, 0, sizeof(cmd));
|
||||||
|
cmd.channel = channel;
|
||||||
|
cmd.contrast = saturation;
|
||||||
|
len = sizeof(cmd);
|
||||||
|
return fthd_isp_cmd(dev_priv, CISP_CMD_CH_SCALER_SATURATION_SET, &cmd, sizeof(cmd), &len);
|
||||||
|
}
|
||||||
|
|
||||||
|
int fthd_isp_cmd_channel_hue_set(struct fthd_private *dev_priv, int channel, int hue)
|
||||||
|
{
|
||||||
|
struct isp_cmd_channel_hue_set cmd;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
pr_debug("set hue %d\n", hue);
|
||||||
|
|
||||||
|
memset(&cmd, 0, sizeof(cmd));
|
||||||
|
cmd.channel = channel;
|
||||||
|
cmd.contrast = hue;
|
||||||
|
len = sizeof(cmd);
|
||||||
|
return fthd_isp_cmd(dev_priv, CISP_CMD_CH_SCALER_HUE_SET, &cmd, sizeof(cmd), &len);
|
||||||
|
}
|
||||||
|
|
||||||
int fthd_start_channel(struct fthd_private *dev_priv, int channel)
|
int fthd_start_channel(struct fthd_private *dev_priv, int channel)
|
||||||
{
|
{
|
||||||
int ret, x1 = 0, x2 = 0, pixelformat;
|
int ret, x1 = 0, x2 = 0, pixelformat;
|
||||||
|
|||||||
12
fthd_isp.h
12
fthd_isp.h
@@ -661,6 +661,16 @@ struct isp_cmd_channel_contrast_set {
|
|||||||
u32 contrast;
|
u32 contrast;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct isp_cmd_channel_saturation_set {
|
||||||
|
u32 channel;
|
||||||
|
u32 contrast;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct isp_cmd_channel_hue_set {
|
||||||
|
u32 channel;
|
||||||
|
u32 contrast;
|
||||||
|
};
|
||||||
|
|
||||||
struct isp_cmd_channel_buffer_return {
|
struct isp_cmd_channel_buffer_return {
|
||||||
u32 channel;
|
u32 channel;
|
||||||
};
|
};
|
||||||
@@ -714,6 +724,8 @@ extern int fthd_isp_cmd_channel_motion_history_stop(struct fthd_private *dev_pri
|
|||||||
extern int fthd_isp_cmd_channel_ae_metering_mode_set(struct fthd_private *dev_priv, int channel, int mode);
|
extern int fthd_isp_cmd_channel_ae_metering_mode_set(struct fthd_private *dev_priv, int channel, int mode);
|
||||||
extern int fthd_isp_cmd_channel_brightness_set(struct fthd_private *dev_priv, int channel, int brightness);
|
extern int fthd_isp_cmd_channel_brightness_set(struct fthd_private *dev_priv, int channel, int brightness);
|
||||||
extern int fthd_isp_cmd_channel_contrast_set(struct fthd_private *dev_priv, int channel, int contrast);
|
extern int fthd_isp_cmd_channel_contrast_set(struct fthd_private *dev_priv, int channel, int contrast);
|
||||||
|
extern int fthd_isp_cmd_channel_saturation_set(struct fthd_private *dev_priv, int channel, int saturation);
|
||||||
|
extern int fthd_isp_cmd_channel_hue_set(struct fthd_private *dev_priv, int channel, int hue);
|
||||||
extern int fthd_isp_cmd_channel_buffer_return(struct fthd_private *dev_priv, int channel);
|
extern int fthd_isp_cmd_channel_buffer_return(struct fthd_private *dev_priv, int channel);
|
||||||
extern int fthd_start_channel(struct fthd_private *dev_priv, int channel);
|
extern int fthd_start_channel(struct fthd_private *dev_priv, int channel);
|
||||||
extern int fthd_stop_channel(struct fthd_private *dev_priv, int channel);
|
extern int fthd_stop_channel(struct fthd_private *dev_priv, int channel);
|
||||||
|
|||||||
80
fthd_v4l2.c
80
fthd_v4l2.c
@@ -25,6 +25,7 @@
|
|||||||
#include <linux/videodev2.h>
|
#include <linux/videodev2.h>
|
||||||
#include <media/v4l2-dev.h>
|
#include <media/v4l2-dev.h>
|
||||||
#include <media/v4l2-ioctl.h>
|
#include <media/v4l2-ioctl.h>
|
||||||
|
#include <media/v4l2-ctrls.h>
|
||||||
#include <media/videobuf2-dma-sg.h>
|
#include <media/videobuf2-dma-sg.h>
|
||||||
#include "fthd_drv.h"
|
#include "fthd_drv.h"
|
||||||
#include "fthd_hw.h"
|
#include "fthd_hw.h"
|
||||||
@@ -387,8 +388,13 @@ static int fthd_v4l2_ioctl_g_std(struct file *filp, void *priv, v4l2_std_id *std
|
|||||||
static int fthd_v4l2_ioctl_querycap(struct file *filp, void *priv,
|
static int fthd_v4l2_ioctl_querycap(struct file *filp, void *priv,
|
||||||
struct v4l2_capability *cap)
|
struct v4l2_capability *cap)
|
||||||
{
|
{
|
||||||
|
struct fthd_private *dev_priv = video_drvdata(filp);
|
||||||
|
|
||||||
strcpy(cap->driver, "bcwc");
|
strcpy(cap->driver, "bcwc");
|
||||||
strcpy(cap->card, "Apple Facetime HD");
|
strcpy(cap->card, "Apple Facetime HD");
|
||||||
|
snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s",
|
||||||
|
pci_name(dev_priv->pdev));
|
||||||
|
|
||||||
cap->device_caps = V4L2_CAP_VIDEO_CAPTURE |
|
cap->device_caps = V4L2_CAP_VIDEO_CAPTURE |
|
||||||
V4L2_CAP_READWRITE | V4L2_CAP_STREAMING | V4L2_CAP_TIMEPERFRAME;
|
V4L2_CAP_READWRITE | V4L2_CAP_STREAMING | V4L2_CAP_TIMEPERFRAME;
|
||||||
cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
|
cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
|
||||||
@@ -411,8 +417,7 @@ static int fthd_v4l2_ioctl_try_fmt_vid_cap(struct file *filp, void *_priv,
|
|||||||
{
|
{
|
||||||
struct fthd_private *dev_priv = video_drvdata(filp);
|
struct fthd_private *dev_priv = video_drvdata(filp);
|
||||||
|
|
||||||
|
pr_debug("%s: %dx%d\n", __FUNCTION__, fmt->fmt.pix.width, fmt->fmt.pix.height);
|
||||||
pr_info("%s: %dx%d\n", __FUNCTION__, fmt->fmt.pix.width, fmt->fmt.pix.height);
|
|
||||||
|
|
||||||
dev_priv->fmt.fmt = fmt->fmt.pix;
|
dev_priv->fmt.fmt = fmt->fmt.pix;
|
||||||
|
|
||||||
@@ -501,7 +506,7 @@ static int fthd_v4l2_ioctl_g_parm(struct file *filp, void *priv,
|
|||||||
if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
|
if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
parm->parm.capture.readbuffers = 2;
|
parm->parm.capture.readbuffers = FTHD_BUFFERS;
|
||||||
parm->parm.capture.capability = V4L2_CAP_TIMEPERFRAME;
|
parm->parm.capture.capability = V4L2_CAP_TIMEPERFRAME;
|
||||||
parm->parm.capture.timeperframe = timeperframe;
|
parm->parm.capture.timeperframe = timeperframe;
|
||||||
return 0;
|
return 0;
|
||||||
@@ -533,6 +538,9 @@ static int fthd_v4l2_ioctl_s_parm(struct file *filp, void *priv,
|
|||||||
static int fthd_v4l2_ioctl_enum_framesizes(struct file *filp, void *priv,
|
static int fthd_v4l2_ioctl_enum_framesizes(struct file *filp, void *priv,
|
||||||
struct v4l2_frmsizeenum *sizes)
|
struct v4l2_frmsizeenum *sizes)
|
||||||
{
|
{
|
||||||
|
if (sizes->index)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
sizes->type = V4L2_FRMSIZE_TYPE_CONTINUOUS;
|
sizes->type = V4L2_FRMSIZE_TYPE_CONTINUOUS;
|
||||||
sizes->stepwise.min_width = 320;
|
sizes->stepwise.min_width = 320;
|
||||||
sizes->stepwise.max_width = 2560;
|
sizes->stepwise.max_width = 2560;
|
||||||
@@ -548,6 +556,9 @@ static int fthd_v4l2_ioctl_enum_frameintervals(struct file *filp, void *priv,
|
|||||||
{
|
{
|
||||||
pr_debug("%s\n", __FUNCTION__);
|
pr_debug("%s\n", __FUNCTION__);
|
||||||
|
|
||||||
|
if (interval->index)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
if (interval->pixel_format != V4L2_PIX_FMT_YUYV &&
|
if (interval->pixel_format != V4L2_PIX_FMT_YUYV &&
|
||||||
interval->pixel_format != V4L2_PIX_FMT_YVYU &&
|
interval->pixel_format != V4L2_PIX_FMT_YVYU &&
|
||||||
interval->pixel_format != V4L2_PIX_FMT_NV16)
|
interval->pixel_format != V4L2_PIX_FMT_NV16)
|
||||||
@@ -591,6 +602,46 @@ static struct v4l2_ioctl_ops fthd_ioctl_ops = {
|
|||||||
.vidioc_enum_frameintervals = fthd_v4l2_ioctl_enum_frameintervals,
|
.vidioc_enum_frameintervals = fthd_v4l2_ioctl_enum_frameintervals,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int fthd_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
|
||||||
|
{
|
||||||
|
pr_debug("id = %x\n", ctrl->id);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int fthd_s_ctrl(struct v4l2_ctrl *ctrl)
|
||||||
|
{
|
||||||
|
struct fthd_private *dev_priv = container_of(ctrl->handler, struct fthd_private, v4l2_ctrl_handler);
|
||||||
|
int ret = -EINVAL;
|
||||||
|
|
||||||
|
pr_info("id = %x, val = %d\n", ctrl->id, ctrl->val);
|
||||||
|
|
||||||
|
switch(ctrl->id) {
|
||||||
|
case V4L2_CID_CONTRAST:
|
||||||
|
ret = fthd_isp_cmd_channel_contrast_set(dev_priv, 0, ctrl->val);
|
||||||
|
break;
|
||||||
|
case V4L2_CID_BRIGHTNESS:
|
||||||
|
ret = fthd_isp_cmd_channel_brightness_set(dev_priv, 0, ctrl->val);
|
||||||
|
break;
|
||||||
|
case V4L2_CID_SATURATION:
|
||||||
|
ret = fthd_isp_cmd_channel_saturation_set(dev_priv, 0, ctrl->val);
|
||||||
|
break;
|
||||||
|
case V4L2_CID_HUE:
|
||||||
|
ret = fthd_isp_cmd_channel_hue_set(dev_priv, 0, ctrl->val);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
pr_debug("ret = %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct v4l2_ctrl_ops fthd_ctrl_ops = {
|
||||||
|
.g_volatile_ctrl = fthd_g_volatile_ctrl,
|
||||||
|
.s_ctrl = fthd_s_ctrl,
|
||||||
|
};
|
||||||
|
|
||||||
int fthd_v4l2_register(struct fthd_private *dev_priv)
|
int fthd_v4l2_register(struct fthd_private *dev_priv)
|
||||||
{
|
{
|
||||||
struct v4l2_device *v4l2_dev = &dev_priv->v4l2_dev;
|
struct v4l2_device *v4l2_dev = &dev_priv->v4l2_dev;
|
||||||
@@ -626,6 +677,21 @@ int fthd_v4l2_register(struct fthd_private *dev_priv)
|
|||||||
if (ret)
|
if (ret)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
v4l2_ctrl_handler_init(&dev_priv->v4l2_ctrl_handler, 4);
|
||||||
|
v4l2_ctrl_new_std(&dev_priv->v4l2_ctrl_handler, &fthd_ctrl_ops,
|
||||||
|
V4L2_CID_BRIGHTNESS, 0, 0xff, 1, 0x80);
|
||||||
|
v4l2_ctrl_new_std(&dev_priv->v4l2_ctrl_handler, &fthd_ctrl_ops,
|
||||||
|
V4L2_CID_CONTRAST, 0, 0xff, 1, 0x80);
|
||||||
|
v4l2_ctrl_new_std(&dev_priv->v4l2_ctrl_handler, &fthd_ctrl_ops,
|
||||||
|
V4L2_CID_SATURATION, 0, 0xff, 1, 0x80);
|
||||||
|
v4l2_ctrl_new_std(&dev_priv->v4l2_ctrl_handler, &fthd_ctrl_ops,
|
||||||
|
V4L2_CID_HUE, 0, 0xff, 1, 0x80);
|
||||||
|
|
||||||
|
if (dev_priv->v4l2_ctrl_handler.error) {
|
||||||
|
pr_err("failed to setup control handlers\n");
|
||||||
|
v4l2_ctrl_handler_free(&dev_priv->v4l2_ctrl_handler);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
dev_priv->alloc_ctx = vb2_dma_sg_init_ctx(&dev_priv->pdev->dev);
|
dev_priv->alloc_ctx = vb2_dma_sg_init_ctx(&dev_priv->pdev->dev);
|
||||||
vdev->v4l2_dev = v4l2_dev;
|
vdev->v4l2_dev = v4l2_dev;
|
||||||
strcpy(vdev->name, "Apple Facetime HD"); // XXX: Length?
|
strcpy(vdev->name, "Apple Facetime HD"); // XXX: Length?
|
||||||
@@ -634,19 +700,22 @@ int fthd_v4l2_register(struct fthd_private *dev_priv)
|
|||||||
vdev->ioctl_ops = &fthd_ioctl_ops;
|
vdev->ioctl_ops = &fthd_ioctl_ops;
|
||||||
vdev->queue = q;
|
vdev->queue = q;
|
||||||
vdev->release = video_device_release;
|
vdev->release = video_device_release;
|
||||||
|
vdev->ctrl_handler = &dev_priv->v4l2_ctrl_handler;
|
||||||
video_set_drvdata(vdev, dev_priv);
|
video_set_drvdata(vdev, dev_priv);
|
||||||
ret = video_register_device(vdev, VFL_TYPE_GRABBER, -1);
|
ret = video_register_device(vdev, VFL_TYPE_GRABBER, -1);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
video_device_release(vdev);
|
video_device_release(vdev);
|
||||||
goto fail;
|
goto fail_vdev;
|
||||||
}
|
}
|
||||||
dev_priv->fmt.fmt.sizeimage = 1280 * 720 * 2;
|
dev_priv->fmt.fmt.sizeimage = 1280 * 720 * 2;
|
||||||
dev_priv->fmt.fmt.pixelformat = V4L2_PIX_FMT_YUYV;
|
dev_priv->fmt.fmt.pixelformat = V4L2_PIX_FMT_YUYV;
|
||||||
dev_priv->fmt.fmt.width = 1280;
|
dev_priv->fmt.fmt.width = 1280;
|
||||||
dev_priv->fmt.fmt.height = 720;
|
dev_priv->fmt.fmt.height = 720;
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
fail_vdev:
|
||||||
|
v4l2_ctrl_handler_free(&dev_priv->v4l2_ctrl_handler);
|
||||||
fail:
|
fail:
|
||||||
v4l2_device_unregister(&dev_priv->v4l2_dev);
|
v4l2_device_unregister(&dev_priv->v4l2_dev);
|
||||||
return ret;
|
return ret;
|
||||||
@@ -655,6 +724,7 @@ fail:
|
|||||||
void fthd_v4l2_unregister(struct fthd_private *dev_priv)
|
void fthd_v4l2_unregister(struct fthd_private *dev_priv)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
v4l2_ctrl_handler_free(&dev_priv->v4l2_ctrl_handler);
|
||||||
vb2_dma_sg_cleanup_ctx(dev_priv->alloc_ctx);
|
vb2_dma_sg_cleanup_ctx(dev_priv->alloc_ctx);
|
||||||
video_unregister_device(dev_priv->videodev);
|
video_unregister_device(dev_priv->videodev);
|
||||||
v4l2_device_unregister(&dev_priv->v4l2_dev);
|
v4l2_device_unregister(&dev_priv->v4l2_dev);
|
||||||
|
|||||||
Reference in New Issue
Block a user