• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 *
3 * SPDX-License-Identifier: GPL-2.0
4 *
5 * Copyright (C) 2011-2018 ARM or its affiliates
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 *
18 */
19 
20 #ifndef _ISP_V4L2_COMMON_H_
21 #define _ISP_V4L2_COMMON_H_
22 
23 #include "acamera_firmware_config.h"
24 
25 /* Sensor data types */
26 #define MAX_SENSOR_PRESET_SIZE 10
27 #define MAX_SENSOR_FPS_SIZE 6
28 typedef struct _isp_v4l2_sensor_preset {
29     uint32_t width;
30     uint32_t height;
31     uint32_t fps[MAX_SENSOR_FPS_SIZE];
32     uint32_t idx[MAX_SENSOR_FPS_SIZE];
33     uint8_t fps_num;
34     uint8_t fps_cur;
35     uint8_t exposures[MAX_SENSOR_FPS_SIZE];
36     uint8_t wdr_mode[MAX_SENSOR_FPS_SIZE];
37 } isp_v4l2_sensor_preset;
38 
39 typedef struct _isp_v4l2_sensor_info {
40     /* resolution preset */
41     isp_v4l2_sensor_preset preset[MAX_SENSOR_PRESET_SIZE];
42     uint8_t preset_num;
43     uint8_t preset_cur;
44 } isp_v4l2_sensor_info;
45 
46 #define V4L2_CAN_UPDATE_SENSOR 0
47 #define V4L2_RESTORE_FR_BASE0 1
48 
49 /* Base address of DDR */
50 #if V4L2_RUNNING_ON_JUNO /* On Juno environment */
51 #define ISP_DDR_START 0x64400000
52 #define ISP_DDR_SIZE 0xB000000
53 #define FPGA_BASE_ADDR ISP_DDR_SIZE
54 #if JUNO_DIRECT_DDR_ACCESS
55 #define JUNO_DDR_START 0x9c1000000
56 #define JUNO_DDR_SIZE 0x10000000
57 #define JUNO_DDR_ADDR_BASE ( JUNO_DDR_START - 0x980000000 ) // (JUNO_DDR_START + 0xF80000000 - 0x1900000000) = (JUNO_DDR_START - 0x980000000) = 0x41000000
58 #endif
59 #else /* Probably on PCIE environment */
60 #define ISP_DDR_START 0x80000000
61 #define ISP_DDR_SIZE 0x10000000
62 #endif
63 
64 /* custom v4l2 formats */
65 #define ISP_V4L2_PIX_FMT_META v4l2_fourcc( 'M', 'E', 'T', 'A' )        /* META */
66 #define ISP_V4L2_PIX_FMT_ARGB2101010 v4l2_fourcc( 'B', 'A', '3', '0' ) /* ARGB2101010 */
67 #define ISP_V4L2_PIX_FMT_NULL v4l2_fourcc( 'N', 'U', 'L', 'L' )        /* format NULL to disable */
68 
69 /* custom v4l2 events */
70 #define V4L2_EVENT_ACAMERA_CLASS ( V4L2_EVENT_PRIVATE_START + 0xA * 1000 )
71 #define V4L2_EVENT_ACAMERA_FRAME_READY ( V4L2_EVENT_ACAMERA_CLASS + 0x1 )
72 #define V4L2_EVENT_ACAMERA_STREAM_OFF ( V4L2_EVENT_ACAMERA_CLASS + 0x2 )
73 
74 /* custom v4l2 controls */
75 #define ISP_V4L2_CID_ISP_V4L2_CLASS ( 0x00f00000 | 1 )
76 #define ISP_V4L2_CID_BASE ( 0x00f00000 | 0xf000 )
77 #define ISP_V4L2_CID_TEST_PATTERN ( ISP_V4L2_CID_BASE + 0 )
78 #define ISP_V4L2_CID_TEST_PATTERN_TYPE ( ISP_V4L2_CID_BASE + 1 )
79 #define ISP_V4L2_CID_AF_REFOCUS ( ISP_V4L2_CID_BASE + 2 )
80 #define ISP_V4L2_CID_SENSOR_PRESET ( ISP_V4L2_CID_BASE + 3 )
81 #define ISP_V4L2_CID_AF_ROI ( ISP_V4L2_CID_BASE + 4 )
82 #define ISP_V4L2_CID_OUTPUT_FR_ON_OFF ( ISP_V4L2_CID_BASE + 5 )
83 #define ISP_V4L2_CID_OUTPUT_DS1_ON_OFF ( ISP_V4L2_CID_BASE + 6 )
84 #define ISP_V4L2_CID_CUSTOM_SENSOR_WDR_MODE ( ISP_V4L2_CID_BASE + 7 )
85 #define ISP_V4L2_CID_CUSTOM_SENSOR_EXPOSURE ( ISP_V4L2_CID_BASE + 8 )
86 #define ISP_V4L2_CID_CUSTOM_SET_FR_FPS ( ISP_V4L2_CID_BASE + 9 )
87 #define ISP_V4L2_CID_CUSTOM_SET_SENSOR_TESTPATTERN (ISP_V4L2_CID_BASE + 10)
88 #define ISP_V4L2_CID_CUSTOM_SENSOR_IR_CUT ( ISP_V4L2_CID_BASE + 11 )
89 #define ISP_V4L2_CID_CUSTOM_SET_AE_ZONE_WEIGHT ( ISP_V4L2_CID_BASE + 12 )
90 #define ISP_V4L2_CID_CUSTOM_SET_AWB_ZONE_WEIGHT ( ISP_V4L2_CID_BASE + 13 )
91 #define ISP_V4L2_CID_CUSTOM_SET_MANUAL_EXPOSURE ( ISP_V4L2_CID_BASE + 14 )
92 #define ISP_V4L2_CID_CUSTOM_SET_SENSOR_INTEGRATION_TIME ( ISP_V4L2_CID_BASE + 15 )
93 #define ISP_V4L2_CID_CUSTOM_SET_SENSOR_ANALOG_GAIN ( ISP_V4L2_CID_BASE + 16 )
94 #define ISP_V4L2_CID_CUSTOM_SET_ISP_DIGITAL_GAIN ( ISP_V4L2_CID_BASE + 17 )
95 #define ISP_V4L2_CID_CUSTOM_SET_STOP_SENSOR_UPDATE ( ISP_V4L2_CID_BASE + 18 )
96 #define ISP_V4L2_CID_CUSTOM_SET_DS1_FPS ( ISP_V4L2_CID_BASE + 19 )
97 #define ISP_V4L2_CID_AE_COMPENSATION ( ISP_V4L2_CID_BASE + 20 )
98 #define ISP_V4L2_CID_CUSTOM_SET_SENSOR_DIGITAL_GAIN ( ISP_V4L2_CID_BASE + 21 )
99 #define ISP_V4L2_CID_CUSTOM_SET_AWB_RED_GAIN ( ISP_V4L2_CID_BASE + 22 )
100 #define ISP_V4L2_CID_CUSTOM_SET_AWB_BLUE_GAIN ( ISP_V4L2_CID_BASE + 23 )
101 #define ISP_V4L2_CID_CUSTOM_SET_MAX_INTEGRATION_TIME (ISP_V4L2_CID_BASE + 24)
102 #define ISP_V4L2_CID_CUSTOM_SENSOR_FPS (ISP_V4L2_CID_BASE + 26)
103 #define ISP_V4L2_CID_CUSTOM_SNR_MANUAL (ISP_V4L2_CID_BASE + 27)
104 #define ISP_V4L2_CID_CUSTOM_SNR_STRENGTH (ISP_V4L2_CID_BASE + 28)
105 #define ISP_V4L2_CID_CUSTOM_TNR_MANUAL (ISP_V4L2_CID_BASE + 29)
106 #define ISP_V4L2_CID_CUSTOM_TNR_OFFSET (ISP_V4L2_CID_BASE + 30)
107 #define ISP_V4L2_CID_CUSTOM_TEMPER_MODE (ISP_V4L2_CID_BASE + 31)
108 #define ISP_V4L2_CID_CUSTOM_WDR_SWITCH (ISP_V4L2_CID_BASE + 32)
109 #define ISP_V4L2_CID_CUSTOM_DEFOG_SWITCH (ISP_V4L2_CID_BASE + 33)
110 #define ISP_V4L2_CID_CUSTOM_DEFOG_STRENGTH (ISP_V4L2_CID_BASE + 34)
111 #define ISP_V4L2_CID_CUSTOM_ANTIFLICKER (ISP_V4L2_CID_BASE + 35)
112 
113 /* type of stream */
114 typedef enum {
115     V4L2_STREAM_TYPE_FR = 0,
116 #if ISP_HAS_META_CB
117     V4L2_STREAM_TYPE_META,
118 #endif
119 #if ISP_HAS_DS1
120     V4L2_STREAM_TYPE_DS1,
121 #endif
122 #if ISP_HAS_DS2
123     V4L2_STREAM_TYPE_DS2,
124 #endif
125 #if ISP_HAS_RAW_CB
126     V4L2_STREAM_TYPE_RAW,
127 #endif
128     V4L2_STREAM_TYPE_MAX
129 } isp_v4l2_stream_type_t;
130 
131 #endif
132