hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/media/i2c/adv748x/adv748x.h
....@@ -1,12 +1,8 @@
1
+/* SPDX-License-Identifier: GPL-2.0+ */
12 /*
23 * Driver for Analog Devices ADV748X video decoder and HDMI receiver
34 *
45 * Copyright (C) 2017 Renesas Electronics Corp.
5
- *
6
- * This program is free software; you can redistribute it and/or modify it
7
- * under the terms of the GNU General Public License as published by the
8
- * Free Software Foundation; either version 2 of the License, or (at your
9
- * option) any later version.
106 *
117 * Authors:
128 * Koji Matsuoka <koji.matsuoka.xm@renesas.com>
....@@ -43,7 +39,6 @@
4339 ADV748X_PAGE_MAX,
4440
4541 /* Fake pages for register sequences */
46
- ADV748X_PAGE_WAIT, /* Wait x msec */
4742 ADV748X_PAGE_EOR, /* End Mark */
4843 };
4944
....@@ -83,16 +78,34 @@
8378 struct v4l2_mbus_framefmt format;
8479 unsigned int page;
8580 unsigned int port;
81
+ unsigned int num_lanes;
82
+ unsigned int active_lanes;
8683
8784 struct media_pad pads[ADV748X_CSI2_NR_PADS];
8885 struct v4l2_ctrl_handler ctrl_hdl;
8986 struct v4l2_ctrl *pixel_rate;
87
+ struct v4l2_subdev *src;
9088 struct v4l2_subdev sd;
9189 };
9290
9391 #define notifier_to_csi2(n) container_of(n, struct adv748x_csi2, notifier)
9492 #define adv748x_sd_to_csi2(sd) container_of(sd, struct adv748x_csi2, sd)
93
+
9594 #define is_tx_enabled(_tx) ((_tx)->state->endpoints[(_tx)->port] != NULL)
95
+#define is_txa(_tx) ((_tx) == &(_tx)->state->txa)
96
+#define is_txb(_tx) ((_tx) == &(_tx)->state->txb)
97
+#define is_tx(_tx) (is_txa(_tx) || is_txb(_tx))
98
+
99
+#define is_afe_enabled(_state) \
100
+ ((_state)->endpoints[ADV748X_PORT_AIN0] != NULL || \
101
+ (_state)->endpoints[ADV748X_PORT_AIN1] != NULL || \
102
+ (_state)->endpoints[ADV748X_PORT_AIN2] != NULL || \
103
+ (_state)->endpoints[ADV748X_PORT_AIN3] != NULL || \
104
+ (_state)->endpoints[ADV748X_PORT_AIN4] != NULL || \
105
+ (_state)->endpoints[ADV748X_PORT_AIN5] != NULL || \
106
+ (_state)->endpoints[ADV748X_PORT_AIN6] != NULL || \
107
+ (_state)->endpoints[ADV748X_PORT_AIN7] != NULL)
108
+#define is_hdmi_enabled(_state) ((_state)->endpoints[ADV748X_PORT_HDMI] != NULL)
96109
97110 enum adv748x_hdmi_pads {
98111 ADV748X_HDMI_SINK,
....@@ -108,6 +121,8 @@
108121
109122 struct v4l2_dv_timings timings;
110123 struct v4l2_fract aspect_ratio;
124
+
125
+ struct adv748x_csi2 *tx;
111126
112127 struct {
113128 u8 edid[512];
....@@ -138,6 +153,8 @@
138153 struct v4l2_ctrl_handler ctrl_hdl;
139154 struct v4l2_subdev sd;
140155 struct v4l2_mbus_framefmt format;
156
+
157
+ struct adv748x_csi2 *tx;
141158
142159 bool streaming;
143160 v4l2_std_id curr_norm;
....@@ -194,6 +211,11 @@
194211 #define ADV748X_IO_PD 0x00 /* power down controls */
195212 #define ADV748X_IO_PD_RX_EN BIT(6)
196213
214
+#define ADV748X_IO_REG_01 0x01 /* pwrdn{2}b, prog_xtal_freq */
215
+#define ADV748X_IO_REG_01_PWRDN_MASK (BIT(7) | BIT(6))
216
+#define ADV748X_IO_REG_01_PWRDN2B BIT(7) /* CEC Wakeup Support */
217
+#define ADV748X_IO_REG_01_PWRDNB BIT(6) /* CEC Wakeup Support */
218
+
197219 #define ADV748X_IO_REG_04 0x04
198220 #define ADV748X_IO_REG_04_FORCE_FR BIT(0) /* Force CP free-run */
199221
....@@ -207,11 +229,23 @@
207229 #define ADV748X_IO_10_CSI4_EN BIT(7)
208230 #define ADV748X_IO_10_CSI1_EN BIT(6)
209231 #define ADV748X_IO_10_PIX_OUT_EN BIT(5)
232
+#define ADV748X_IO_10_CSI4_IN_SEL_AFE BIT(3)
210233
211234 #define ADV748X_IO_CHIP_REV_ID_1 0xdf
212235 #define ADV748X_IO_CHIP_REV_ID_2 0xe0
213236
237
+#define ADV748X_IO_REG_F2 0xf2
238
+#define ADV748X_IO_REG_F2_READ_AUTO_INC BIT(0)
239
+
240
+/* For PAGE slave address offsets */
214241 #define ADV748X_IO_SLAVE_ADDR_BASE 0xf2
242
+
243
+/*
244
+ * The ADV748x_Recommended_Settings_PrA_2014-08-20.pdf details both 0x80 and
245
+ * 0xff as examples for performing a software reset.
246
+ */
247
+#define ADV748X_IO_REG_FF 0xff
248
+#define ADV748X_IO_REG_FF_MAIN_RESET 0xff
215249
216250 /* HDMI RX Map */
217251 #define ADV748X_HDMI_LW1 0x07 /* line width_1 */
....@@ -378,9 +412,6 @@
378412 #define cp_write(s, r, v) adv748x_write(s, ADV748X_PAGE_CP, r, v)
379413 #define cp_clrset(s, r, m, v) cp_write(s, r, (cp_read(s, r) & ~(m)) | (v))
380414
381
-#define txa_read(s, r) adv748x_read(s, ADV748X_PAGE_TXA, r)
382
-#define txb_read(s, r) adv748x_read(s, ADV748X_PAGE_TXB, r)
383
-
384415 #define tx_read(t, r) adv748x_read(t->state, t->page, r)
385416 #define tx_write(t, r, v) adv748x_write(t->state, t->page, r, v)
386417
....@@ -400,8 +431,7 @@
400431 int adv748x_register_subdevs(struct adv748x_state *state,
401432 struct v4l2_device *v4l2_dev);
402433
403
-int adv748x_txa_power(struct adv748x_state *state, bool on);
404
-int adv748x_txb_power(struct adv748x_state *state, bool on);
434
+int adv748x_tx_power(struct adv748x_csi2 *tx, bool on);
405435
406436 int adv748x_afe_init(struct adv748x_afe *afe);
407437 void adv748x_afe_cleanup(struct adv748x_afe *afe);