Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 367171
b: refs/heads/master
c: be178cb
h: refs/heads/master
i:
  367169: f5821ee
  367167: ced5d21
v: v3
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Apr 16, 2013
1 parent adb34b0 commit deddad1
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 97 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b6f8727e9f4cff765de2b24e82c1b2cfc1a74a86
refs/heads/master: be178cb4f41f70e29108ce4eb5a8a77a62f1922f
44 changes: 0 additions & 44 deletions trunk/drivers/media/pci/cx25821/cx25821-medusa-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ static int medusa_initialize_ntsc(struct cx25821_dev *dev)
u32 value = 0;
u32 tmp = 0;

mutex_lock(&dev->lock);

for (i = 0; i < MAX_DECODERS; i++) {
/* set video format NTSC-M */
value = cx25821_i2c_read(&dev->i2c_bus[0],
Expand Down Expand Up @@ -222,8 +220,6 @@ static int medusa_initialize_ntsc(struct cx25821_dev *dev)
value |= 0x00080200;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], BYP_AB_CTRL, value);

mutex_unlock(&dev->lock);

return ret_val;
}

Expand Down Expand Up @@ -265,8 +261,6 @@ static int medusa_initialize_pal(struct cx25821_dev *dev)
u32 value = 0;
u32 tmp = 0;

mutex_lock(&dev->lock);

for (i = 0; i < MAX_DECODERS; i++) {
/* set video format PAL-BDGHI */
value = cx25821_i2c_read(&dev->i2c_bus[0],
Expand Down Expand Up @@ -397,8 +391,6 @@ static int medusa_initialize_pal(struct cx25821_dev *dev)
value &= 0xFFF7FDFF;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], BYP_AB_CTRL, value);

mutex_unlock(&dev->lock);

return ret_val;
}

Expand Down Expand Up @@ -434,8 +426,6 @@ void medusa_set_resolution(struct cx25821_dev *dev, int width,
u32 vscale = 0x0;
const int MAX_WIDTH = 720;

mutex_lock(&dev->lock);

/* validate the width */
if (width > MAX_WIDTH) {
pr_info("%s(): width %d > MAX_WIDTH %d ! resetting to MAX_WIDTH\n",
Expand Down Expand Up @@ -485,8 +475,6 @@ void medusa_set_resolution(struct cx25821_dev *dev, int width,
cx25821_i2c_write(&dev->i2c_bus[0],
VSCALE_CTRL + (0x200 * decoder), vscale);
}

mutex_unlock(&dev->lock);
}

static void medusa_set_decoderduration(struct cx25821_dev *dev, int decoder,
Expand All @@ -496,11 +484,8 @@ static void medusa_set_decoderduration(struct cx25821_dev *dev, int decoder,
u32 tmp = 0;
u32 disp_cnt_reg = DISP_AB_CNT;

mutex_lock(&dev->lock);

/* no support */
if (decoder < VDEC_A || decoder > VDEC_H) {
mutex_unlock(&dev->lock);
return;
}

Expand Down Expand Up @@ -535,8 +520,6 @@ static void medusa_set_decoderduration(struct cx25821_dev *dev, int decoder,
}

cx25821_i2c_write(&dev->i2c_bus[0], disp_cnt_reg, fld_cnt);

mutex_unlock(&dev->lock);
}

/* Map to Medusa register setting */
Expand Down Expand Up @@ -587,10 +570,8 @@ int medusa_set_brightness(struct cx25821_dev *dev, int brightness, int decoder)
int value = 0;
u32 val = 0, tmp = 0;

mutex_lock(&dev->lock);
if ((brightness > VIDEO_PROCAMP_MAX) ||
(brightness < VIDEO_PROCAMP_MIN)) {
mutex_unlock(&dev->lock);
return -1;
}
ret_val = mapM(VIDEO_PROCAMP_MIN, VIDEO_PROCAMP_MAX, brightness,
Expand All @@ -601,7 +582,6 @@ int medusa_set_brightness(struct cx25821_dev *dev, int brightness, int decoder)
val &= 0xFFFFFF00;
ret_val |= cx25821_i2c_write(&dev->i2c_bus[0],
VDEC_A_BRITE_CTRL + (0x200 * decoder), val | value);
mutex_unlock(&dev->lock);
return ret_val;
}

Expand All @@ -611,10 +591,7 @@ int medusa_set_contrast(struct cx25821_dev *dev, int contrast, int decoder)
int value = 0;
u32 val = 0, tmp = 0;

mutex_lock(&dev->lock);

if ((contrast > VIDEO_PROCAMP_MAX) || (contrast < VIDEO_PROCAMP_MIN)) {
mutex_unlock(&dev->lock);
return -1;
}

Expand All @@ -626,7 +603,6 @@ int medusa_set_contrast(struct cx25821_dev *dev, int contrast, int decoder)
ret_val |= cx25821_i2c_write(&dev->i2c_bus[0],
VDEC_A_CNTRST_CTRL + (0x200 * decoder), val | value);

mutex_unlock(&dev->lock);
return ret_val;
}

Expand All @@ -636,10 +612,7 @@ int medusa_set_hue(struct cx25821_dev *dev, int hue, int decoder)
int value = 0;
u32 val = 0, tmp = 0;

mutex_lock(&dev->lock);

if ((hue > VIDEO_PROCAMP_MAX) || (hue < VIDEO_PROCAMP_MIN)) {
mutex_unlock(&dev->lock);
return -1;
}

Expand All @@ -654,7 +627,6 @@ int medusa_set_hue(struct cx25821_dev *dev, int hue, int decoder)
ret_val |= cx25821_i2c_write(&dev->i2c_bus[0],
VDEC_A_HUE_CTRL + (0x200 * decoder), val | value);

mutex_unlock(&dev->lock);
return ret_val;
}

Expand All @@ -664,11 +636,8 @@ int medusa_set_saturation(struct cx25821_dev *dev, int saturation, int decoder)
int value = 0;
u32 val = 0, tmp = 0;

mutex_lock(&dev->lock);

if ((saturation > VIDEO_PROCAMP_MAX) ||
(saturation < VIDEO_PROCAMP_MIN)) {
mutex_unlock(&dev->lock);
return -1;
}

Expand All @@ -687,7 +656,6 @@ int medusa_set_saturation(struct cx25821_dev *dev, int saturation, int decoder)
ret_val |= cx25821_i2c_write(&dev->i2c_bus[0],
VDEC_A_VSAT_CTRL + (0x200 * decoder), val | value);

mutex_unlock(&dev->lock);
return ret_val;
}

Expand All @@ -699,8 +667,6 @@ int medusa_video_init(struct cx25821_dev *dev)
int ret_val = 0;
int i = 0;

mutex_lock(&dev->lock);

_num_decoders = dev->_max_num_decoders;

/* disable Auto source selection on all video decoders */
Expand All @@ -719,13 +685,9 @@ int medusa_video_init(struct cx25821_dev *dev)
if (ret_val < 0)
goto error;

mutex_unlock(&dev->lock);

for (i = 0; i < _num_decoders; i++)
medusa_set_decoderduration(dev, i, _display_field_cnt[i]);

mutex_lock(&dev->lock);

/* Select monitor as DENC A input, power up the DAC */
value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_AB_CTRL, &tmp);
value &= 0xFF70FF70;
Expand Down Expand Up @@ -774,14 +736,8 @@ int medusa_video_init(struct cx25821_dev *dev)
if (ret_val < 0)
goto error;


mutex_unlock(&dev->lock);

ret_val = medusa_set_videostandard(dev);

return ret_val;

error:
mutex_unlock(&dev->lock);
return ret_val;
}
72 changes: 27 additions & 45 deletions trunk/drivers/media/pci/cx25821/cx25821-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,27 +144,8 @@ static int cx25821_set_tvnorm(struct cx25821_dev *dev, v4l2_std_id norm)
return 0;
}

/*
static int cx25821_ctrl_query(struct v4l2_queryctrl *qctrl)
{
int i;
if (qctrl->id < V4L2_CID_BASE || qctrl->id >= V4L2_CID_LASTP1)
return -EINVAL;
for (i = 0; i < CX25821_CTLS; i++)
if (cx25821_ctls[i].v.id == qctrl->id)
break;
if (i == CX25821_CTLS) {
*qctrl = no_ctl;
return 0;
}
*qctrl = cx25821_ctls[i].v;
return 0;
}
*/

/* resource management */
int cx25821_res_get(struct cx25821_dev *dev, struct cx25821_fh *fh,
static int cx25821_res_get(struct cx25821_dev *dev, struct cx25821_fh *fh,
unsigned int bit)
{
dprintk(1, "%s()\n", __func__);
Expand All @@ -173,41 +154,36 @@ int cx25821_res_get(struct cx25821_dev *dev, struct cx25821_fh *fh,
return 1;

/* is it free? */
mutex_lock(&dev->lock);
if (dev->channels[fh->channel_id].resources & bit) {
/* no, someone else uses it */
mutex_unlock(&dev->lock);
return 0;
}
/* it's free, grab it */
fh->resources |= bit;
dev->channels[fh->channel_id].resources |= bit;
dprintk(1, "res: get %d\n", bit);
mutex_unlock(&dev->lock);
return 1;
}

int cx25821_res_check(struct cx25821_fh *fh, unsigned int bit)
static int cx25821_res_check(struct cx25821_fh *fh, unsigned int bit)
{
return fh->resources & bit;
}

int cx25821_res_locked(struct cx25821_fh *fh, unsigned int bit)
static int cx25821_res_locked(struct cx25821_fh *fh, unsigned int bit)
{
return fh->dev->channels[fh->channel_id].resources & bit;
}

void cx25821_res_free(struct cx25821_dev *dev, struct cx25821_fh *fh,
static void cx25821_res_free(struct cx25821_dev *dev, struct cx25821_fh *fh,
unsigned int bits)
{
BUG_ON((fh->resources & bits) != bits);
dprintk(1, "%s()\n", __func__);

mutex_lock(&dev->lock);
fh->resources &= ~bits;
dev->channels[fh->channel_id].resources &= ~bits;
dprintk(1, "res: put %d\n", bits);
mutex_unlock(&dev->lock);
}

static int cx25821_video_mux(struct cx25821_dev *dev, unsigned int input)
Expand Down Expand Up @@ -669,7 +645,7 @@ static int video_open(struct file *file)
videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops, &dev->pci->dev,
&dev->slock, V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED, sizeof(struct cx25821_buffer),
fh, NULL);
fh, &dev->lock);

dprintk(1, "post videobuf_queue_init()\n");

Expand All @@ -680,19 +656,25 @@ static ssize_t video_read(struct file *file, char __user * data, size_t count,
loff_t *ppos)
{
struct cx25821_fh *fh = file->private_data;
struct cx25821_dev *dev = fh->dev;
int err;

switch (fh->type) {
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
if (mutex_lock_interruptible(&dev->lock))
return -ERESTARTSYS;
if (cx25821_res_locked(fh, RESOURCE_VIDEO0))
return -EBUSY;

return videobuf_read_one(&fh->vidq, data, count, ppos,
err = -EBUSY;
else
err = videobuf_read_one(&fh->vidq, data, count, ppos,
file->f_flags & O_NONBLOCK);
mutex_unlock(&dev->lock);
return err;

default:
BUG();
return 0;
return -ENODEV;
}

}

static unsigned int video_poll(struct file *file,
Expand Down Expand Up @@ -742,6 +724,7 @@ static int video_release(struct file *file)
const struct sram_channel *sram_ch =
dev->channels[0].sram_channels;

mutex_lock(&dev->lock);
/* stop the risc engine and fifo */
cx_write(sram_ch->dma_ctl, 0); /* FIFO and RISC disable */

Expand All @@ -750,6 +733,7 @@ static int video_release(struct file *file)
videobuf_queue_cancel(&fh->vidq);
cx25821_res_free(dev, fh, RESOURCE_VIDEO0);
}
mutex_unlock(&dev->lock);

if (fh->vidq.read_buf) {
cx25821_buffer_release(&fh->vidq, fh->vidq.read_buf);
Expand Down Expand Up @@ -1083,9 +1067,7 @@ int cx25821_vidioc_s_std(struct file *file, void *priv, v4l2_std_id tvnorms)
if (dev->tvnorm == tvnorms)
return 0;

mutex_lock(&dev->lock);
cx25821_set_tvnorm(dev, tvnorms);
mutex_unlock(&dev->lock);

medusa_set_videostandard(dev);

Expand Down Expand Up @@ -1141,9 +1123,7 @@ static int cx25821_vidioc_s_input(struct file *file, void *priv, unsigned int i)
if (i >= CX25821_NR_INPUT || INPUT(i)->type == 0)
return -EINVAL;

mutex_lock(&dev->lock);
cx25821_video_mux(dev, i);
mutex_unlock(&dev->lock);
return 0;
}

Expand Down Expand Up @@ -1465,7 +1445,7 @@ static const struct v4l2_file_operations video_fops = {
.read = video_read,
.poll = video_poll,
.mmap = cx25821_video_mmap,
.ioctl = cx25821_video_ioctl,
.unlocked_ioctl = cx25821_video_ioctl,
};

static const struct v4l2_ioctl_ops video_ioctl_ops = {
Expand Down Expand Up @@ -1521,6 +1501,10 @@ int cx25821_video_register(struct cx25821_dev *dev)
int err;
int i;

/* initial device configuration */
dev->tvnorm = V4L2_STD_NTSC_M,
cx25821_set_tvnorm(dev, dev->tvnorm);

spin_lock_init(&dev->slock);

for (i = 0; i < VID_CHANNEL_NUM; ++i) {
Expand All @@ -1543,6 +1527,9 @@ int cx25821_video_register(struct cx25821_dev *dev)
err = hdl->error;
goto fail_unreg;
}
err = v4l2_ctrl_handler_setup(hdl);
if (err)
goto fail_unreg;

cx25821_risc_stopper(dev->pci, &dev->channels[i].vidq.stopper,
dev->channels[i].sram_channels->dma_ctl, 0x11, 0);
Expand All @@ -1567,6 +1554,7 @@ int cx25821_video_register(struct cx25821_dev *dev)
*vdev = cx25821_video_device;
vdev->v4l2_dev = &dev->v4l2_dev;
vdev->ctrl_handler = hdl;
vdev->lock = &dev->lock;
snprintf(vdev->name, sizeof(vdev->name), "%s #%d", dev->name, i);
video_set_drvdata(vdev, dev);

Expand All @@ -1580,12 +1568,6 @@ int cx25821_video_register(struct cx25821_dev *dev)
/* set PCI interrupt */
cx_set(PCI_INT_MSK, 0xff);

/* initial device configuration */
mutex_lock(&dev->lock);
dev->tvnorm = V4L2_STD_NTSC_M,
cx25821_set_tvnorm(dev, dev->tvnorm);
mutex_unlock(&dev->lock);

return 0;

fail_unreg:
Expand Down
Loading

0 comments on commit deddad1

Please sign in to comment.