How can I expose my read_reg and write_reg from camera driver to userspace?

Essentially as the title says. I have a camera driver and I want to be able to use the read_reg and write_reg functions in my user space application. I’m assuming it should be done through IOCTL and I have seen examples using file_operations but my driver doesn’t use that.

hello richardcusolito1,

may I know what’s the real use-case?
besides, there’s OEM firewall to block nvcsi register read/writes.

I want to be able to read and write to specific addresses using i2c to help with debugging my driver. There are also other ops I want to be able to call in userspace besides just the read/write so I figured if I could expose those I could expose any that I want.

hello richardcusolito1,

please refer to below function for reading the register values via kernel driver side.
you may implement a debugfs, or, customize IOCTL to access to sensor driver by yourself.

static inline int ov5693_read_reg(struct camera_common_data *s_data,
				u16 addr, u8 *val)
{
	int err = 0;
	u32 reg_val = 0;

	err = regmap_read(s_data->regmap, addr, &reg_val);
	*val = reg_val & 0xFF;

This is exactly the function I want to expose to userspace. This is where my original question comes in. I don’t know the steps I need to take (what files I need to edit) to allow this to happen. Could you provide some insight on this?

hello richardcusolito1,

you may see-also reference driver, nv_ov5693.c for the demonstration to create debugfs,
for instance, ov5693_debugfs_create()

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.