diff options
author | Eric Nelson <eric.nelson@boundarydevices.com> | 2013-05-14 16:27:34 -0700 |
---|---|---|
committer | Eric Nelson <eric.nelson@boundarydevices.com> | 2013-09-03 14:08:23 -0700 |
commit | 952acded3ad8c2fd75d64d7665eaaafc4cdb7e76 (patch) | |
tree | be6678fb55d34940e4df01abbebe8c978895f499 /drivers | |
parent | dbe55669653c877f6651488209d0fbbd43d3d5d9 (diff) |
ov5642: add proc entry to read/write registers
Signed-off-by: Eric Nelson <eric.nelson@boundarydevices.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/video/mxc/capture/ov5642.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/drivers/media/video/mxc/capture/ov5642.c b/drivers/media/video/mxc/capture/ov5642.c index 29524c50ae05..4d6942925caf 100644 --- a/drivers/media/video/mxc/capture/ov5642.c +++ b/drivers/media/video/mxc/capture/ov5642.c @@ -31,6 +31,7 @@ #include <media/v4l2-chip-ident.h> #include <media/v4l2-int-device.h> #include "mxc_v4l2_capture.h" +#include <linux/proc_fs.h> #define OV5642_VOLTAGE_ANALOG 2800000 #define OV5642_VOLTAGE_DIGITAL_CORE 1500000 @@ -5987,6 +5988,49 @@ static struct v4l2_int_device ov5642_int_device = { }, }; +static int write_proc(struct file *file, const char __user *buffer, unsigned long count, void *data) +{ + char localbuf[256]; + if( count < sizeof(localbuf) ){ + if(copy_from_user(localbuf,buffer,count)){ + printk(KERN_ERR "Error reading user buf\n" ); + } else { + int addr0 ; + int addr1 ; + int value ; + int numScanned ; + if(2 == (numScanned = sscanf(localbuf,"%04x %02x", &addr0, &value)) ){ + if( (0xFFFF >= addr0) && (0xff >= value) ){ + s32 rval ; + + rval = ov5642_write_reg(addr0,value); + if (rval < 0) + pr_err("%s, write reg 0x%x failed: %d\n", __func__, addr0, rval); + else + pr_err("ov5642[%04x] = %02x\n", addr0,value); + } + else + printk(KERN_ERR "Invalid data: %s\n", localbuf); + } else if(1 == numScanned){ + if(0xFFFF > addr0){ + s32 rval; + u8 value; + rval = ov5642_read_reg(addr0,&value); + if (0 == rval) { + pr_err("ov5642[%04x] == 0x%02x\n", addr0,value); + } else { + pr_err("%s, read reg 0x%x failed: %d\n", __func__, addr0, rval); + } + } + } + else + printk(KERN_ERR "Invalid data: %s\n", localbuf); + } + } + + return count ; +} + /*! * ov5642 I2C probe function * @@ -5999,6 +6043,7 @@ static int ov5642_probe(struct i2c_client *client, int retval; struct fsl_mxc_camera_platform_data *plat_data = client->dev.platform_data; u8 chip_id_high, chip_id_low; + struct proc_dir_entry *pde ; struct reg_value *firmware_regs; int i; @@ -6104,6 +6149,14 @@ static int ov5642_probe(struct i2c_client *client, ov5642_int_device.priv = &ov5642_data; + pde = create_proc_entry("driver/ov5642", 0, 0); + if( pde ) { + pde->write_proc = write_proc ; + pde->data = &ov5642_int_device ; + } + else + printk( KERN_ERR "Error creating ov5642 proc entry\n" ); + pr_info("Upload Auto-focus firmware"); firmware_regs = ov5642_af_firmware; for (i = 0; i < ARRAY_SIZE(ov5642_af_firmware); ++i, ++firmware_regs) { @@ -6145,6 +6198,8 @@ err1: */ static int ov5642_remove(struct i2c_client *client) { + remove_proc_entry("driver/ov5642", NULL); + v4l2_int_device_unregister(&ov5642_int_device); if (gpo_regulator) { |