aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2009-03-18 12:25:54 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-30 11:43:30 -0400
commit69d94f7ec5edea85da0057c48c4f2877e5bb509e (patch)
tree0be8d9970472357b06250c1bcb6f7c9b7c2d0c6b /drivers/media
parentb794aabff01a704df5c0bcf6537e6a7343a08465 (diff)
V4L/DVB (11118): cafe_ccic: replace debugfs with g/s_register ioctls.
Using VIDIOC_DBG_S/G_REGISTER is the standard way of reading/writing register for advanced debugging under v4l2. In addition, using this means that the cafe_ccic driver doesn't need to have knowledge about the used sensor: the debug ioctl can be passed on to the sensor if it isn't for the host. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Acked-by: Jonathan Corbet <corbet@lwn.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/cafe_ccic.c176
1 files changed, 46 insertions, 130 deletions
diff --git a/drivers/media/video/cafe_ccic.c b/drivers/media/video/cafe_ccic.c
index 3363e501d6d7..2f4293771392 100644
--- a/drivers/media/video/cafe_ccic.c
+++ b/drivers/media/video/cafe_ccic.c
@@ -33,7 +33,6 @@
33#include <linux/list.h> 33#include <linux/list.h>
34#include <linux/dma-mapping.h> 34#include <linux/dma-mapping.h>
35#include <linux/delay.h> 35#include <linux/delay.h>
36#include <linux/debugfs.h>
37#include <linux/jiffies.h> 36#include <linux/jiffies.h>
38#include <linux/vmalloc.h> 37#include <linux/vmalloc.h>
39 38
@@ -182,10 +181,6 @@ struct cafe_camera
182 /* Misc */ 181 /* Misc */
183 wait_queue_head_t smbus_wait; /* Waiting on i2c events */ 182 wait_queue_head_t smbus_wait; /* Waiting on i2c events */
184 wait_queue_head_t iowait; /* Waiting on frame data */ 183 wait_queue_head_t iowait; /* Waiting on frame data */
185#ifdef CONFIG_VIDEO_ADV_DEBUG
186 struct dentry *dfs_regs;
187 struct dentry *dfs_cam_regs;
188#endif
189}; 184};
190 185
191/* 186/*
@@ -1646,6 +1641,47 @@ static int cafe_vidioc_s_parm(struct file *filp, void *priv,
1646 return ret; 1641 return ret;
1647} 1642}
1648 1643
1644static int cafe_vidioc_g_chip_ident(struct file *file, void *priv,
1645 struct v4l2_dbg_chip_ident *chip)
1646{
1647 struct cafe_camera *cam = priv;
1648
1649 chip->ident = V4L2_IDENT_NONE;
1650 chip->revision = 0;
1651 if (v4l2_chip_match_host(&chip->match)) {
1652 chip->ident = V4L2_IDENT_CAFE;
1653 return 0;
1654 }
1655 return sensor_call(cam, core, g_chip_ident, chip);
1656}
1657
1658#ifdef CONFIG_VIDEO_ADV_DEBUG
1659static int cafe_vidioc_g_register(struct file *file, void *priv,
1660 struct v4l2_dbg_register *reg)
1661{
1662 struct cafe_camera *cam = priv;
1663
1664 if (v4l2_chip_match_host(&reg->match)) {
1665 reg->val = cafe_reg_read(cam, reg->reg);
1666 reg->size = 4;
1667 return 0;
1668 }
1669 return sensor_call(cam, core, g_register, reg);
1670}
1671
1672static int cafe_vidioc_s_register(struct file *file, void *priv,
1673 struct v4l2_dbg_register *reg)
1674{
1675 struct cafe_camera *cam = priv;
1676
1677 if (v4l2_chip_match_host(&reg->match)) {
1678 cafe_reg_write(cam, reg->reg, reg->val);
1679 return 0;
1680 }
1681 return sensor_call(cam, core, s_register, reg);
1682}
1683#endif
1684
1649/* 1685/*
1650 * This template device holds all of those v4l2 methods; we 1686 * This template device holds all of those v4l2 methods; we
1651 * clone it for specific real devices. 1687 * clone it for specific real devices.
@@ -1682,6 +1718,11 @@ static const struct v4l2_ioctl_ops cafe_v4l_ioctl_ops = {
1682 .vidioc_s_ctrl = cafe_vidioc_s_ctrl, 1718 .vidioc_s_ctrl = cafe_vidioc_s_ctrl,
1683 .vidioc_g_parm = cafe_vidioc_g_parm, 1719 .vidioc_g_parm = cafe_vidioc_g_parm,
1684 .vidioc_s_parm = cafe_vidioc_s_parm, 1720 .vidioc_s_parm = cafe_vidioc_s_parm,
1721 .vidioc_g_chip_ident = cafe_vidioc_g_chip_ident,
1722#ifdef CONFIG_VIDEO_ADV_DEBUG
1723 .vidioc_g_register = cafe_vidioc_g_register,
1724 .vidioc_s_register = cafe_vidioc_s_register,
1725#endif
1685}; 1726};
1686 1727
1687static struct video_device cafe_v4l_template = { 1728static struct video_device cafe_v4l_template = {
@@ -1849,127 +1890,6 @@ static irqreturn_t cafe_irq(int irq, void *data)
1849 1890
1850 1891
1851/* -------------------------------------------------------------------------- */ 1892/* -------------------------------------------------------------------------- */
1852#ifdef CONFIG_VIDEO_ADV_DEBUG
1853/*
1854 * Debugfs stuff.
1855 */
1856
1857static char cafe_debug_buf[1024];
1858static struct dentry *cafe_dfs_root;
1859
1860static void cafe_dfs_setup(void)
1861{
1862 cafe_dfs_root = debugfs_create_dir("cafe_ccic", NULL);
1863 if (IS_ERR(cafe_dfs_root)) {
1864 cafe_dfs_root = NULL; /* Never mind */
1865 printk(KERN_NOTICE "cafe_ccic unable to set up debugfs\n");
1866 }
1867}
1868
1869static void cafe_dfs_shutdown(void)
1870{
1871 if (cafe_dfs_root)
1872 debugfs_remove(cafe_dfs_root);
1873}
1874
1875static int cafe_dfs_open(struct inode *inode, struct file *file)
1876{
1877 file->private_data = inode->i_private;
1878 return 0;
1879}
1880
1881static ssize_t cafe_dfs_read_regs(struct file *file,
1882 char __user *buf, size_t count, loff_t *ppos)
1883{
1884 struct cafe_camera *cam = file->private_data;
1885 char *s = cafe_debug_buf;
1886 int offset;
1887
1888 for (offset = 0; offset < 0x44; offset += 4)
1889 s += sprintf(s, "%02x: %08x\n", offset,
1890 cafe_reg_read(cam, offset));
1891 for (offset = 0x88; offset <= 0x90; offset += 4)
1892 s += sprintf(s, "%02x: %08x\n", offset,
1893 cafe_reg_read(cam, offset));
1894 for (offset = 0xb4; offset <= 0xbc; offset += 4)
1895 s += sprintf(s, "%02x: %08x\n", offset,
1896 cafe_reg_read(cam, offset));
1897 for (offset = 0x3000; offset <= 0x300c; offset += 4)
1898 s += sprintf(s, "%04x: %08x\n", offset,
1899 cafe_reg_read(cam, offset));
1900 return simple_read_from_buffer(buf, count, ppos, cafe_debug_buf,
1901 s - cafe_debug_buf);
1902}
1903
1904static const struct file_operations cafe_dfs_reg_ops = {
1905 .owner = THIS_MODULE,
1906 .read = cafe_dfs_read_regs,
1907 .open = cafe_dfs_open
1908};
1909
1910static ssize_t cafe_dfs_read_cam(struct file *file,
1911 char __user *buf, size_t count, loff_t *ppos)
1912{
1913 struct cafe_camera *cam = file->private_data;
1914 char *s = cafe_debug_buf;
1915 int offset;
1916
1917 if (! cam->sensor)
1918 return -EINVAL;
1919 for (offset = 0x0; offset < 0x8a; offset++)
1920 {
1921 u8 v;
1922
1923 cafe_smbus_read_data(cam, cam->sensor_addr, offset, &v);
1924 s += sprintf(s, "%02x: %02x\n", offset, v);
1925 }
1926 return simple_read_from_buffer(buf, count, ppos, cafe_debug_buf,
1927 s - cafe_debug_buf);
1928}
1929
1930static const struct file_operations cafe_dfs_cam_ops = {
1931 .owner = THIS_MODULE,
1932 .read = cafe_dfs_read_cam,
1933 .open = cafe_dfs_open
1934};
1935
1936
1937
1938static void cafe_dfs_cam_setup(struct cafe_camera *cam)
1939{
1940 char fname[40];
1941
1942 if (!cafe_dfs_root)
1943 return;
1944 sprintf(fname, "regs-%d", cam->vdev.num);
1945 cam->dfs_regs = debugfs_create_file(fname, 0444, cafe_dfs_root,
1946 cam, &cafe_dfs_reg_ops);
1947 sprintf(fname, "cam-%d", cam->vdev.num);
1948 cam->dfs_cam_regs = debugfs_create_file(fname, 0444, cafe_dfs_root,
1949 cam, &cafe_dfs_cam_ops);
1950}
1951
1952
1953static void cafe_dfs_cam_shutdown(struct cafe_camera *cam)
1954{
1955 if (! IS_ERR(cam->dfs_regs))
1956 debugfs_remove(cam->dfs_regs);
1957 if (! IS_ERR(cam->dfs_cam_regs))
1958 debugfs_remove(cam->dfs_cam_regs);
1959}
1960
1961#else
1962
1963#define cafe_dfs_setup()
1964#define cafe_dfs_shutdown()
1965#define cafe_dfs_cam_setup(cam)
1966#define cafe_dfs_cam_shutdown(cam)
1967#endif /* CONFIG_VIDEO_ADV_DEBUG */
1968
1969
1970
1971
1972/* ------------------------------------------------------------------------*/
1973/* 1893/*
1974 * PCI interface stuff. 1894 * PCI interface stuff.
1975 */ 1895 */
@@ -2070,7 +1990,6 @@ static int cafe_pci_probe(struct pci_dev *pdev,
2070 " will try again later."); 1990 " will try again later.");
2071 } 1991 }
2072 1992
2073 cafe_dfs_cam_setup(cam);
2074 mutex_unlock(&cam->s_mutex); 1993 mutex_unlock(&cam->s_mutex);
2075 return 0; 1994 return 0;
2076 1995
@@ -2096,7 +2015,6 @@ out:
2096static void cafe_shutdown(struct cafe_camera *cam) 2015static void cafe_shutdown(struct cafe_camera *cam)
2097{ 2016{
2098/* FIXME: Make sure we take care of everything here */ 2017/* FIXME: Make sure we take care of everything here */
2099 cafe_dfs_cam_shutdown(cam);
2100 if (cam->n_sbufs > 0) 2018 if (cam->n_sbufs > 0)
2101 /* What if they are still mapped? Shouldn't be, but... */ 2019 /* What if they are still mapped? Shouldn't be, but... */
2102 cafe_free_sio_buffers(cam); 2020 cafe_free_sio_buffers(cam);
@@ -2216,7 +2134,6 @@ static int __init cafe_init(void)
2216 2134
2217 printk(KERN_NOTICE "Marvell M88ALP01 'CAFE' Camera Controller version %d\n", 2135 printk(KERN_NOTICE "Marvell M88ALP01 'CAFE' Camera Controller version %d\n",
2218 CAFE_VERSION); 2136 CAFE_VERSION);
2219 cafe_dfs_setup();
2220 ret = pci_register_driver(&cafe_pci_driver); 2137 ret = pci_register_driver(&cafe_pci_driver);
2221 if (ret) { 2138 if (ret) {
2222 printk(KERN_ERR "Unable to register cafe_ccic driver\n"); 2139 printk(KERN_ERR "Unable to register cafe_ccic driver\n");
@@ -2232,7 +2149,6 @@ static int __init cafe_init(void)
2232static void __exit cafe_exit(void) 2149static void __exit cafe_exit(void)
2233{ 2150{
2234 pci_unregister_driver(&cafe_pci_driver); 2151 pci_unregister_driver(&cafe_pci_driver);
2235 cafe_dfs_shutdown();
2236} 2152}
2237 2153
2238module_init(cafe_init); 2154module_init(cafe_init);