hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (c) 2023 Rockchip Electronics Co., Ltd.
 *
 */
 
#ifndef __MAXIM4C_DRV_H__
#define __MAXIM4C_DRV_H__
 
#include <linux/workqueue.h>
#include <linux/rk-camera-module.h>
#include <linux/mfd/core.h>
#include <media/media-entity.h>
#include <media/v4l2-async.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-subdev.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-fwnode.h>
#include <media/v4l2-subdev.h>
 
#include "maxim4c_i2c.h"
#include "maxim4c_link.h"
#include "maxim4c_mipi_txphy.h"
#include "maxim4c_remote.h"
#include "maxim4c_pattern.h"
 
#define MAXIM4C_REG_CHIP_ID        0x0D
#define MAX96712_CHIP_ID        0xA0
#define MAX96722_CHIP_ID        0xA1
 
enum {
   MAXIM4C_HOT_PLUG_OUT = 0,
   MAXIM4C_HOT_PLUG_IN,
};
 
struct maxim4c_hot_plug_work {
   struct workqueue_struct *state_check_wq;
   struct delayed_work state_d_work;
   u32 hot_plug_state;
};
 
struct maxim4c_mode {
   u32 width;
   u32 height;
   struct v4l2_fract max_fps;
   u32 hts_def;
   u32 vts_def;
   u32 exp_def;
   u32 link_freq_idx;
   u32 bus_fmt;
   u32 bpp;
   const struct regval *reg_list;
   u32 vc[PAD_MAX];
};
 
typedef struct maxim4c {
   struct i2c_client *client;
   struct clk *xvclk;
   struct gpio_desc *pwdn_gpio;
   struct gpio_desc *pocen_gpio;
   struct gpio_desc *lock_gpio;
 
   struct mutex mutex;
 
   struct v4l2_subdev subdev;
   struct media_pad pad;
   struct v4l2_ctrl_handler ctrl_handler;
   struct v4l2_ctrl *exposure;
   struct v4l2_ctrl *anal_gain;
   struct v4l2_ctrl *digi_gain;
   struct v4l2_ctrl *hblank;
   struct v4l2_ctrl *vblank;
   struct v4l2_ctrl *pixel_rate;
   struct v4l2_ctrl *link_freq;
   struct v4l2_fwnode_endpoint bus_cfg;
 
   u32 chipid;
 
   bool streaming;
   bool power_on;
   bool hot_plug;
   u8 is_reset;
   int hot_plug_irq;
   u32 hot_plug_state;
   u32 link_lock_state;
   struct maxim4c_hot_plug_work hot_plug_work;
 
   struct maxim4c_mode supported_mode;
   const struct maxim4c_mode *cur_mode;
   u32 cfg_modes_num;
 
   u32 module_index;
   const char *module_facing;
   const char *module_name;
   const char *len_name;
 
   maxim4c_gmsl_link_t gmsl_link;
   maxim4c_video_pipe_t video_pipe;
   maxim4c_mipi_txphy_t mipi_txphy;
 
   struct maxim4c_pattern pattern;
 
   struct maxim4c_i2c_init_seq extra_init_seq;
 
   struct mfd_cell remote_mfd_devs[MAXIM4C_LINK_ID_MAX];
   maxim4c_remote_t *remote_device[MAXIM4C_LINK_ID_MAX];
} maxim4c_t;
 
#endif /* __MAXIM4C_DRV_H__ */