1b562e72bSNiklas Söderlund /* SPDX-License-Identifier: GPL-2.0 */ 2b562e72bSNiklas Söderlund /* 3b562e72bSNiklas Söderlund * Copyright (C) 2026 Renesas Electronics Corp. 4b562e72bSNiklas Söderlund * Copyright (C) 2026 Ideas on Board Oy 5b562e72bSNiklas Söderlund * Copyright (C) 2026 Ragnatech AB 6b562e72bSNiklas Söderlund */ 7b562e72bSNiklas Söderlund 8b562e72bSNiklas Söderlund #ifndef __RPPX1_MODULE_H__ 9b562e72bSNiklas Söderlund #define __RPPX1_MODULE_H__ 10b562e72bSNiklas Söderlund 11b562e72bSNiklas Söderlund #include <linux/errno.h> 12b562e72bSNiklas Söderlund #include <linux/types.h> 13b562e72bSNiklas Söderlund #include <linux/v4l2-mediabus.h> 14b562e72bSNiklas Söderlund 15b562e72bSNiklas Söderlund #include <linux/media/dreamchip/rppx1-config.h> 16b562e72bSNiklas Söderlund 17b562e72bSNiklas Söderlund #include <media/rppx1.h> 18b562e72bSNiklas Söderlund 19b562e72bSNiklas Söderlund struct rpp_module_ops; 20b562e72bSNiklas Söderlund 21b562e72bSNiklas Söderlund enum rpp_raw_pattern { 22b562e72bSNiklas Söderlund RPP_RGGB = 0, 23b562e72bSNiklas Söderlund RPP_GRBG, 24b562e72bSNiklas Söderlund RPP_GBRG, 25b562e72bSNiklas Söderlund RPP_BGGR, 26b562e72bSNiklas Söderlund }; 27b562e72bSNiklas Söderlund 28b562e72bSNiklas Söderlund struct rpp_module { 29b562e72bSNiklas Söderlund struct rppx1 *rpp; 30b562e72bSNiklas Söderlund u32 base; 31b562e72bSNiklas Söderlund 32b562e72bSNiklas Söderlund const struct rpp_module_ops *ops; 33b562e72bSNiklas Söderlund 34b562e72bSNiklas Söderlund union { 35b562e72bSNiklas Söderlund struct { 36b562e72bSNiklas Söderlund enum rpp_raw_pattern raw_pattern; 37b562e72bSNiklas Söderlund } acq; 38b562e72bSNiklas Söderlund } info; 39b562e72bSNiklas Söderlund }; 40b562e72bSNiklas Söderlund 41b562e72bSNiklas Söderlund int rpp_module_probe(struct rpp_module *mod, struct rppx1 *rpp, 42b562e72bSNiklas Söderlund const struct rpp_module_ops *ops, u32 base); 43b562e72bSNiklas Söderlund 44b562e72bSNiklas Söderlund void rpp_module_write(struct rpp_module *mod, u32 offset, u32 value); 45b562e72bSNiklas Söderlund u32 rpp_module_read(struct rpp_module *mod, u32 offset); 46b562e72bSNiklas Söderlund void rpp_module_clrset(struct rpp_module *mod, u32 offset, u32 mask, u32 value); 47b562e72bSNiklas Söderlund 48b562e72bSNiklas Söderlund union rppx1_params_block { 49b562e72bSNiklas Söderlund struct v4l2_isp_block_header header; 503f8a2a88SNiklas Söderlund struct rppx1_bls_params bls; 51*46542592SJai Luthra struct rppx1_lin_params lin; 52b39656efSNiklas Söderlund struct rppx1_lsc_params lsc; 539ebf5001SNiklas Söderlund struct rppx1_awbg_params awbg; 54aaeee9b7SNiklas Söderlund struct rppx1_ccor_params ccor; 559a52f7deSNiklas Söderlund struct rppx1_hist_params hist; 56b020bec4SNiklas Söderlund struct rppx1_exm_params exm; 57884d6794SNiklas Söderlund struct rppx1_wbmeas_params wbmeas; 58d011daefSNiklas Söderlund struct rppx1_ga_params ga; 59b562e72bSNiklas Söderlund }; 60b562e72bSNiklas Söderlund 61b562e72bSNiklas Söderlund union rppx1_stats_block { 62b562e72bSNiklas Söderlund struct v4l2_isp_block_header header; 639a52f7deSNiklas Söderlund struct rppx1_hist_stats hist; 64b020bec4SNiklas Söderlund struct rppx1_exm_stats exm; 65884d6794SNiklas Söderlund struct rppx1_wbmeas_stats wbmeas; 66b562e72bSNiklas Söderlund }; 67b562e72bSNiklas Söderlund 68b562e72bSNiklas Söderlund struct rpp_module_ops { 69b562e72bSNiklas Söderlund int (*probe)(struct rpp_module *mod); 70b562e72bSNiklas Söderlund int (*start)(struct rpp_module *mod, const struct v4l2_mbus_framefmt *fmt); 71b562e72bSNiklas Söderlund 72b562e72bSNiklas Söderlund int (*fill_params)(struct rpp_module *mod, 73b562e72bSNiklas Söderlund const union rppx1_params_block *block, 74b562e72bSNiklas Söderlund rppx1_reg_write write, void *priv); 75b562e72bSNiklas Söderlund int (*fill_stats)(struct rpp_module *mod, 76b562e72bSNiklas Söderlund union rppx1_stats_block *block); 77b562e72bSNiklas Söderlund }; 78b562e72bSNiklas Söderlund 79b562e72bSNiklas Söderlund extern const struct rpp_module_ops rppx1_acq_ops; 80b562e72bSNiklas Söderlund extern const struct rpp_module_ops rppx1_awbg_ops; 81b562e72bSNiklas Söderlund extern const struct rpp_module_ops rppx1_bd_ops; 82b562e72bSNiklas Söderlund extern const struct rpp_module_ops rppx1_bdrgb_ops; 83b562e72bSNiklas Söderlund extern const struct rpp_module_ops rppx1_bls_ops; 84b562e72bSNiklas Söderlund extern const struct rpp_module_ops rppx1_cac_ops; 85b562e72bSNiklas Söderlund extern const struct rpp_module_ops rppx1_ccor_ops; 86b562e72bSNiklas Söderlund extern const struct rpp_module_ops rppx1_ccor_csm_ops; 87b562e72bSNiklas Söderlund extern const struct rpp_module_ops rppx1_db_ops; 88b562e72bSNiklas Söderlund extern const struct rpp_module_ops rppx1_dpcc_ops; 89b562e72bSNiklas Söderlund extern const struct rpp_module_ops rppx1_exm_ops; 90b562e72bSNiklas Söderlund extern const struct rpp_module_ops rppx1_ga_ops; 91b562e72bSNiklas Söderlund extern const struct rpp_module_ops rppx1_hist256_ops; 92b562e72bSNiklas Söderlund extern const struct rpp_module_ops rppx1_hist_ops; 93b562e72bSNiklas Söderlund extern const struct rpp_module_ops rppx1_is_ops; 94b562e72bSNiklas Söderlund extern const struct rpp_module_ops rppx1_lin_ops; 95b562e72bSNiklas Söderlund extern const struct rpp_module_ops rppx1_lsc_ops; 96b562e72bSNiklas Söderlund extern const struct rpp_module_ops rppx1_ltm_ops; 97b562e72bSNiklas Söderlund extern const struct rpp_module_ops rppx1_ltmmeas_ops; 98b562e72bSNiklas Söderlund extern const struct rpp_module_ops rppx1_outif_ops; 99b562e72bSNiklas Söderlund extern const struct rpp_module_ops rppx1_outregs_ops; 100b562e72bSNiklas Söderlund extern const struct rpp_module_ops rppx1_rmapmeas_ops; 101b562e72bSNiklas Söderlund extern const struct rpp_module_ops rppx1_rmap_ops; 102b562e72bSNiklas Söderlund extern const struct rpp_module_ops rppx1_shrp_ops; 103b562e72bSNiklas Söderlund extern const struct rpp_module_ops rppx1_wbmeas_ops; 104b562e72bSNiklas Söderlund extern const struct rpp_module_ops rppx1_xyz2luv_ops; 105b562e72bSNiklas Söderlund 106b562e72bSNiklas Söderlund #define rpp_module_call(mod, op, args...) \ 107b562e72bSNiklas Söderlund ({ \ 108b562e72bSNiklas Söderlund struct rpp_module *__mod = (mod); \ 109b562e72bSNiklas Söderlund int __result; \ 110b562e72bSNiklas Söderlund if (!__mod) \ 111b562e72bSNiklas Söderlund __result = -ENODEV; \ 112b562e72bSNiklas Söderlund else if (!__mod->ops->op) \ 113b562e72bSNiklas Söderlund __result = 0; \ 114b562e72bSNiklas Söderlund else \ 115b562e72bSNiklas Söderlund __result = __mod->ops->op(__mod, ##args); \ 116b562e72bSNiklas Söderlund __result; \ 117b562e72bSNiklas Söderlund }) 118b562e72bSNiklas Söderlund 119b562e72bSNiklas Söderlund #endif /* __RPPX1_MODULE_H__ */ 120