at master 7.0 kB view raw
1/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ 2/* 3 * RP1 PiSP Front End Driver Configuration structures 4 * 5 * Copyright (C) 2021 - Raspberry Pi Ltd. 6 * 7 */ 8#ifndef _UAPI_PISP_FE_CONFIG_ 9#define _UAPI_PISP_FE_CONFIG_ 10 11#include <linux/types.h> 12 13#include "pisp_common.h" 14#include "pisp_fe_statistics.h" 15 16#define PISP_FE_NUM_OUTPUTS 2 17 18enum pisp_fe_enable { 19 PISP_FE_ENABLE_INPUT = 0x000001, 20 PISP_FE_ENABLE_DECOMPRESS = 0x000002, 21 PISP_FE_ENABLE_DECOMPAND = 0x000004, 22 PISP_FE_ENABLE_BLA = 0x000008, 23 PISP_FE_ENABLE_DPC = 0x000010, 24 PISP_FE_ENABLE_STATS_CROP = 0x000020, 25 PISP_FE_ENABLE_DECIMATE = 0x000040, 26 PISP_FE_ENABLE_BLC = 0x000080, 27 PISP_FE_ENABLE_CDAF_STATS = 0x000100, 28 PISP_FE_ENABLE_AWB_STATS = 0x000200, 29 PISP_FE_ENABLE_RGBY = 0x000400, 30 PISP_FE_ENABLE_LSC = 0x000800, 31 PISP_FE_ENABLE_AGC_STATS = 0x001000, 32 PISP_FE_ENABLE_CROP0 = 0x010000, 33 PISP_FE_ENABLE_DOWNSCALE0 = 0x020000, 34 PISP_FE_ENABLE_COMPRESS0 = 0x040000, 35 PISP_FE_ENABLE_OUTPUT0 = 0x080000, 36 PISP_FE_ENABLE_CROP1 = 0x100000, 37 PISP_FE_ENABLE_DOWNSCALE1 = 0x200000, 38 PISP_FE_ENABLE_COMPRESS1 = 0x400000, 39 PISP_FE_ENABLE_OUTPUT1 = 0x800000 40}; 41 42#define PISP_FE_ENABLE_CROP(i) (PISP_FE_ENABLE_CROP0 << (4 * (i))) 43#define PISP_FE_ENABLE_DOWNSCALE(i) (PISP_FE_ENABLE_DOWNSCALE0 << (4 * (i))) 44#define PISP_FE_ENABLE_COMPRESS(i) (PISP_FE_ENABLE_COMPRESS0 << (4 * (i))) 45#define PISP_FE_ENABLE_OUTPUT(i) (PISP_FE_ENABLE_OUTPUT0 << (4 * (i))) 46 47/* 48 * We use the enable flags to show when blocks are "dirty", but we need some 49 * extra ones too. 50 */ 51enum pisp_fe_dirty { 52 PISP_FE_DIRTY_GLOBAL = 0x0001, 53 PISP_FE_DIRTY_FLOATING = 0x0002, 54 PISP_FE_DIRTY_OUTPUT_AXI = 0x0004 55}; 56 57struct pisp_fe_global_config { 58 __u32 enables; 59 __u8 bayer_order; 60 __u8 pad[3]; 61} __attribute__((packed)); 62 63struct pisp_fe_input_axi_config { 64 /* burst length minus one, in the range 0..15; OR'd with flags */ 65 __u8 maxlen_flags; 66 /* { prot[2:0], cache[3:0] } fields */ 67 __u8 cache_prot; 68 /* QoS (only 4 LS bits are used) */ 69 __u16 qos; 70} __attribute__((packed)); 71 72struct pisp_fe_output_axi_config { 73 /* burst length minus one, in the range 0..15; OR'd with flags */ 74 __u8 maxlen_flags; 75 /* { prot[2:0], cache[3:0] } fields */ 76 __u8 cache_prot; 77 /* QoS (4 bitfields of 4 bits each for different panic levels) */ 78 __u16 qos; 79 /* For Panic mode: Output FIFO panic threshold */ 80 __u16 thresh; 81 /* For Panic mode: Output FIFO statistics throttle threshold */ 82 __u16 throttle; 83} __attribute__((packed)); 84 85struct pisp_fe_input_config { 86 __u8 streaming; 87 __u8 pad[3]; 88 struct pisp_image_format_config format; 89 struct pisp_fe_input_axi_config axi; 90 /* Extra cycles delay before issuing each burst request */ 91 __u8 holdoff; 92 __u8 pad2[3]; 93} __attribute__((packed)); 94 95struct pisp_fe_output_config { 96 struct pisp_image_format_config format; 97 __u16 ilines; 98 __u8 pad[2]; 99} __attribute__((packed)); 100 101struct pisp_fe_input_buffer_config { 102 __u32 addr_lo; 103 __u32 addr_hi; 104 __u16 frame_id; 105 __u16 pad; 106} __attribute__((packed)); 107 108#define PISP_FE_DECOMPAND_LUT_SIZE 65 109 110struct pisp_fe_decompand_config { 111 __u16 lut[PISP_FE_DECOMPAND_LUT_SIZE]; 112 __u16 pad; 113} __attribute__((packed)); 114 115struct pisp_fe_dpc_config { 116 __u8 coeff_level; 117 __u8 coeff_range; 118 __u8 coeff_range2; 119#define PISP_FE_DPC_FLAG_FOLDBACK 1 120#define PISP_FE_DPC_FLAG_VFLAG 2 121 __u8 flags; 122} __attribute__((packed)); 123 124#define PISP_FE_LSC_LUT_SIZE 16 125 126struct pisp_fe_lsc_config { 127 __u8 shift; 128 __u8 pad0; 129 __u16 scale; 130 __u16 centre_x; 131 __u16 centre_y; 132 __u16 lut[PISP_FE_LSC_LUT_SIZE]; 133} __attribute__((packed)); 134 135struct pisp_fe_rgby_config { 136 __u16 gain_r; 137 __u16 gain_g; 138 __u16 gain_b; 139 __u8 maxflag; 140 __u8 pad; 141} __attribute__((packed)); 142 143struct pisp_fe_agc_stats_config { 144 __u16 offset_x; 145 __u16 offset_y; 146 __u16 size_x; 147 __u16 size_y; 148 /* each weight only 4 bits */ 149 __u8 weights[PISP_AGC_STATS_NUM_ZONES / 2]; 150 __u16 row_offset_x; 151 __u16 row_offset_y; 152 __u16 row_size_x; 153 __u16 row_size_y; 154 __u8 row_shift; 155 __u8 float_shift; 156 __u8 pad1[2]; 157} __attribute__((packed)); 158 159struct pisp_fe_awb_stats_config { 160 __u16 offset_x; 161 __u16 offset_y; 162 __u16 size_x; 163 __u16 size_y; 164 __u8 shift; 165 __u8 pad[3]; 166 __u16 r_lo; 167 __u16 r_hi; 168 __u16 g_lo; 169 __u16 g_hi; 170 __u16 b_lo; 171 __u16 b_hi; 172} __attribute__((packed)); 173 174struct pisp_fe_floating_stats_region { 175 __u16 offset_x; 176 __u16 offset_y; 177 __u16 size_x; 178 __u16 size_y; 179} __attribute__((packed)); 180 181struct pisp_fe_floating_stats_config { 182 struct pisp_fe_floating_stats_region 183 regions[PISP_FLOATING_STATS_NUM_ZONES]; 184} __attribute__((packed)); 185 186#define PISP_FE_CDAF_NUM_WEIGHTS 8 187 188struct pisp_fe_cdaf_stats_config { 189 __u16 noise_constant; 190 __u16 noise_slope; 191 __u16 offset_x; 192 __u16 offset_y; 193 __u16 size_x; 194 __u16 size_y; 195 __u16 skip_x; 196 __u16 skip_y; 197 __u32 mode; 198} __attribute__((packed)); 199 200struct pisp_fe_stats_buffer_config { 201 __u32 addr_lo; 202 __u32 addr_hi; 203} __attribute__((packed)); 204 205struct pisp_fe_crop_config { 206 __u16 offset_x; 207 __u16 offset_y; 208 __u16 width; 209 __u16 height; 210} __attribute__((packed)); 211 212enum pisp_fe_downscale_flags { 213 /* downscale the four Bayer components independently... */ 214 DOWNSCALE_BAYER = 1, 215 /* ...without trying to preserve their spatial relationship */ 216 DOWNSCALE_BIN = 2, 217}; 218 219struct pisp_fe_downscale_config { 220 __u8 xin; 221 __u8 xout; 222 __u8 yin; 223 __u8 yout; 224 __u8 flags; /* enum pisp_fe_downscale_flags */ 225 __u8 pad[3]; 226 __u16 output_width; 227 __u16 output_height; 228} __attribute__((packed)); 229 230struct pisp_fe_output_buffer_config { 231 __u32 addr_lo; 232 __u32 addr_hi; 233} __attribute__((packed)); 234 235/* Each of the two output channels/branches: */ 236struct pisp_fe_output_branch_config { 237 struct pisp_fe_crop_config crop; 238 struct pisp_fe_downscale_config downscale; 239 struct pisp_compress_config compress; 240 struct pisp_fe_output_config output; 241 __u32 pad; 242} __attribute__((packed)); 243 244/* And finally one to rule them all: */ 245struct pisp_fe_config { 246 /* I/O configuration: */ 247 struct pisp_fe_stats_buffer_config stats_buffer; 248 struct pisp_fe_output_buffer_config output_buffer[PISP_FE_NUM_OUTPUTS]; 249 struct pisp_fe_input_buffer_config input_buffer; 250 /* processing configuration: */ 251 struct pisp_fe_global_config global; 252 struct pisp_fe_input_config input; 253 struct pisp_decompress_config decompress; 254 struct pisp_fe_decompand_config decompand; 255 struct pisp_bla_config bla; 256 struct pisp_fe_dpc_config dpc; 257 struct pisp_fe_crop_config stats_crop; 258 __u32 spare1; /* placeholder for future decimate configuration */ 259 struct pisp_bla_config blc; 260 struct pisp_fe_rgby_config rgby; 261 struct pisp_fe_lsc_config lsc; 262 struct pisp_fe_agc_stats_config agc_stats; 263 struct pisp_fe_awb_stats_config awb_stats; 264 struct pisp_fe_cdaf_stats_config cdaf_stats; 265 struct pisp_fe_floating_stats_config floating_stats; 266 struct pisp_fe_output_axi_config output_axi; 267 struct pisp_fe_output_branch_config ch[PISP_FE_NUM_OUTPUTS]; 268 /* non-register fields: */ 269 __u32 dirty_flags; /* these use pisp_fe_enable */ 270 __u32 dirty_flags_extra; /* these use pisp_fe_dirty */ 271} __attribute__((packed)); 272 273#endif /* _UAPI_PISP_FE_CONFIG_ */