summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBhanu Murthy V <bmurthyv@nvidia.com>2018-09-12 14:10:54 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2019-02-01 02:27:50 -0500
commit8eb6de8344f843d545eff7e41d22cd002a827c68 (patch)
tree3d2c16f87f1e4cdb7ccf2c2d6c2cff5332cea1de
parentb4ca17dc535de02dbd31e1dee5b7d19fa2592a97 (diff)
include: media: Add camera device driver header
This header defines the I2C, SPI bus, multiplexer configurations and the overall sensor configuration for the camera device. This header exposes the structures which can be used in userspace for the interface communication with camera device driver. Bug 2433156 Change-Id: I05ae2ec4144c01bef664d329082d640b7d6ac1a1 Signed-off-by: Bhanu Murthy V <bmurthyv@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1822198 (cherry picked from commit 3f0c4dce47ede75c20f54a8fab4c0be4143a1786) Reviewed-on: https://git-master.nvidia.com/r/2006760 Tested-by: Ian Kaszubski <ikaszubski@nvidia.com> Reviewed-by: Vincent Chung <vincentc@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Frank Chen <frankc@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
-rw-r--r--include/media/camera_device.h132
-rw-r--r--include/media/sensor_common.h4
2 files changed, 135 insertions, 1 deletions
diff --git a/include/media/camera_device.h b/include/media/camera_device.h
new file mode 100644
index 000000000..575ae16ef
--- /dev/null
+++ b/include/media/camera_device.h
@@ -0,0 +1,132 @@
1/*
2 * include/linux/media/camera_device.h
3 *
4 * camera device driver header
5 *
6 * Copyright (c) 2019 NVIDIA Corporation. All rights reserved.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms and conditions of the GNU General Public License,
10 * version 2, as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20#ifndef __CAMERA_DEVICE_H_
21#define __CAMERA_DEVICE_H_
22
23#include <linux/compiler.h>
24#include <linux/types.h>
25#include <linux/ioctl.h>
26
27#define __CAMERA_DEVICE_ALIGN __aligned(8)
28
29/* Sensor, focuser, iris etc., */
30#define MAX_DEVICES_PER_CHANNEL 4
31
32/*
33 * Increasing below values must validate
34 * copy_from or copy_to works properly
35 */
36#define MAX_COMMANDS 256
37#define MAX_BLOB_SIZE 2048
38
39struct i2c_bus {
40 u32 reg_base;
41 u32 clk_rate;
42 u32 flags;
43 u8 reserved[4];
44};
45
46struct i2c_mux {
47 bool is_mux_valid;
48 u8 mux_channel;
49 u16 mux_addr;
50 u8 reserved[4];
51};
52
53struct i2c_dev {
54 u16 addr;
55 u8 pad[2];
56 u32 flags;
57};
58
59struct spi_bus {
60 u32 reg_base;
61 u32 clk_rate;
62 u32 flags;
63 u8 reserved[4];
64};
65
66struct spi_dev {
67 u8 port;
68 u16 addr;
69 u8 pad;
70 u32 flags;
71 u8 pad1[4];
72};
73
74struct i2c_sensor_cfg {
75 u32 num_devs;
76 struct i2c_bus bus;
77 struct i2c_mux mux;
78 struct i2c_dev sd[MAX_DEVICES_PER_CHANNEL];
79};
80
81struct spi_sensor_cfg {
82 u32 num_devs;
83 struct spi_bus bus;
84 struct spi_dev sd[MAX_DEVICES_PER_CHANNEL];
85};
86
87struct sensor_cfg {
88 u8 type; /* SPI or I2C */
89 u8 pad[3]; /* for alignment */
90 union {
91 struct i2c_sensor_cfg i2c_sensor;
92 struct spi_sensor_cfg spi_sensor;
93 } u;
94} __CAMERA_DEVICE_ALIGN;
95
96struct sensor_cmd {
97 u32 opcode;
98 u32 addr;
99};
100
101struct sensor_blob {
102 u32 num_cmds;
103 u32 buf_size;
104 struct sensor_cmd cmds[MAX_COMMANDS];
105 u8 buf[MAX_BLOB_SIZE];
106} __CAMERA_DEVICE_ALIGN;
107
108struct sensor_blob_cfg {
109 u32 nlines;
110 struct sensor_blob *blob;
111} __CAMERA_DEVICE_ALIGN;
112
113#define CAMERA_DEVICE_NONE 0
114#define CAMERA_DEVICE_I2C_SENSOR (0x1 << 1)
115#define CAMERA_DEVICE_SPI_SENSOR (0x1 << 2)
116/* Future extensions - if necessary */
117#define CAMERA_DEVICE_VI (0x1 << 8)
118#define CAMERA_DEVICE_CSI (0x1 << 9)
119#define CAMERA_DEVICE_ISP (0x1 << 16)
120
121struct camdev_chan_cfg {
122 u32 type;
123 struct sensor_cfg scfg;
124} __CAMERA_DEVICE_ALIGN;
125
126/* common functionality */
127#define CAMERA_DEVICE_REGISTER _IOW('C', 1, struct camdev_chan_cfg)
128#define CAMERA_DEVICE_UNREGISTER _IOW('C', 2, u32)
129/* sensor functionality */
130#define SENSOR_BLOB_EXECUTE _IOW('C', 10, struct sensor_blob_cfg)
131
132#endif
diff --git a/include/media/sensor_common.h b/include/media/sensor_common.h
index 736599f7c..67d1d9965 100644
--- a/include/media/sensor_common.h
+++ b/include/media/sensor_common.h
@@ -1,7 +1,7 @@
1/** 1/**
2 * sensor_common.h - utilities for tegra camera driver 2 * sensor_common.h - utilities for tegra camera driver
3 * 3 *
4 * Copyright (c) 2017-2018, NVIDIA Corporation. All rights reserved. 4 * Copyright (c) 2017-2019, NVIDIA Corporation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify it 6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License, 7 * under the terms and conditions of the GNU General Public License,
@@ -36,8 +36,10 @@
36#include <media/v4l2-ctrls.h> 36#include <media/v4l2-ctrls.h>
37#include <linux/v4l2-mediabus.h> 37#include <linux/v4l2-mediabus.h>
38#include <media/tegra-v4l2-camera.h> 38#include <media/tegra-v4l2-camera.h>
39#include <media/camera_device.h>
39 40
40struct sensor_properties { 41struct sensor_properties {
42 struct sensor_cfg cfg;
41 /* sensor_modes points to an array of mode properties */ 43 /* sensor_modes points to an array of mode properties */
42 struct sensor_mode_properties *sensor_modes; 44 struct sensor_mode_properties *sensor_modes;
43 u32 num_modes; 45 u32 num_modes;