2009-09-27 09:50:44 +08:00
|
|
|
/*
|
|
|
|
* Driver for the Conexant CX23885/7/8 PCIe bridge
|
|
|
|
*
|
|
|
|
* Various common ioctl() support functions
|
|
|
|
*
|
2010-05-24 05:53:35 +08:00
|
|
|
* Copyright (c) 2009 Andy Walls <awalls@md.metrocast.net>
|
2009-09-27 09:50:44 +08:00
|
|
|
*
|
|
|
|
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "cx23885.h"
|
2012-10-27 22:29:23 +08:00
|
|
|
#include "cx23885-ioctl.h"
|
|
|
|
|
2013-05-29 17:59:39 +08:00
|
|
|
#ifdef CONFIG_VIDEO_ADV_DEBUG
|
|
|
|
int cx23885_g_chip_info(struct file *file, void *fh,
|
|
|
|
struct v4l2_dbg_chip_info *chip)
|
2009-09-27 09:50:44 +08:00
|
|
|
{
|
|
|
|
struct cx23885_dev *dev = ((struct cx23885_fh *)fh)->dev;
|
|
|
|
|
2013-05-29 17:59:39 +08:00
|
|
|
if (chip->match.addr > 1)
|
2009-09-27 09:50:44 +08:00
|
|
|
return -EINVAL;
|
2013-05-29 17:59:39 +08:00
|
|
|
if (chip->match.addr == 1) {
|
|
|
|
if (dev->v4l_device == NULL)
|
|
|
|
return -EINVAL;
|
|
|
|
strlcpy(chip->name, "cx23417", sizeof(chip->name));
|
|
|
|
} else {
|
|
|
|
strlcpy(chip->name, dev->v4l2_dev.name, sizeof(chip->name));
|
|
|
|
}
|
2009-09-27 09:50:44 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int cx23417_g_register(struct cx23885_dev *dev,
|
|
|
|
struct v4l2_dbg_register *reg)
|
|
|
|
{
|
|
|
|
u32 value;
|
|
|
|
|
|
|
|
if (dev->v4l_device == NULL)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if ((reg->reg & 0x3) != 0 || reg->reg >= 0x10000)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (mc417_register_read(dev, (u16) reg->reg, &value))
|
|
|
|
return -EINVAL; /* V4L2 spec, but -EREMOTEIO really */
|
|
|
|
|
|
|
|
reg->size = 4;
|
|
|
|
reg->val = value;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int cx23885_g_register(struct file *file, void *fh,
|
|
|
|
struct v4l2_dbg_register *reg)
|
|
|
|
{
|
|
|
|
struct cx23885_dev *dev = ((struct cx23885_fh *)fh)->dev;
|
|
|
|
|
2013-05-29 17:59:39 +08:00
|
|
|
if (reg->match.addr > 1)
|
|
|
|
return -EINVAL;
|
|
|
|
if (reg->match.addr)
|
|
|
|
return cx23417_g_register(dev, reg);
|
2009-09-27 09:50:44 +08:00
|
|
|
|
|
|
|
if ((reg->reg & 0x3) != 0 || reg->reg >= pci_resource_len(dev->pci, 0))
|
|
|
|
return -EINVAL;
|
|
|
|
|
2013-05-29 17:59:39 +08:00
|
|
|
reg->size = 4;
|
|
|
|
reg->val = cx_read(reg->reg);
|
2009-09-27 09:50:44 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int cx23417_s_register(struct cx23885_dev *dev,
|
2013-03-24 19:28:46 +08:00
|
|
|
const struct v4l2_dbg_register *reg)
|
2009-09-27 09:50:44 +08:00
|
|
|
{
|
|
|
|
if (dev->v4l_device == NULL)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if ((reg->reg & 0x3) != 0 || reg->reg >= 0x10000)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (mc417_register_write(dev, (u16) reg->reg, (u32) reg->val))
|
|
|
|
return -EINVAL; /* V4L2 spec, but -EREMOTEIO really */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int cx23885_s_register(struct file *file, void *fh,
|
2013-03-24 19:28:46 +08:00
|
|
|
const struct v4l2_dbg_register *reg)
|
2009-09-27 09:50:44 +08:00
|
|
|
{
|
|
|
|
struct cx23885_dev *dev = ((struct cx23885_fh *)fh)->dev;
|
|
|
|
|
2013-05-29 17:59:39 +08:00
|
|
|
if (reg->match.addr > 1)
|
|
|
|
return -EINVAL;
|
|
|
|
if (reg->match.addr)
|
|
|
|
return cx23417_s_register(dev, reg);
|
|
|
|
|
|
|
|
if ((reg->reg & 0x3) != 0 || reg->reg >= pci_resource_len(dev->pci, 0))
|
|
|
|
return -EINVAL;
|
2009-09-27 09:50:44 +08:00
|
|
|
|
2013-05-29 17:59:39 +08:00
|
|
|
cx_write(reg->reg, reg->val);
|
2009-09-27 09:50:44 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|