0001
0002
0003
0004
0005
0006
0007 #ifndef __IMX_LDB_HELPER__
0008 #define __IMX_LDB_HELPER__
0009
0010 #include <linux/device.h>
0011 #include <linux/kernel.h>
0012 #include <linux/of.h>
0013 #include <linux/regmap.h>
0014
0015 #include <drm/drm_atomic.h>
0016 #include <drm/drm_bridge.h>
0017 #include <drm/drm_device.h>
0018 #include <drm/drm_encoder.h>
0019 #include <drm/drm_modeset_helper_vtables.h>
0020
0021 #define LDB_CH0_MODE_EN_TO_DI0 BIT(0)
0022 #define LDB_CH0_MODE_EN_TO_DI1 (3 << 0)
0023 #define LDB_CH0_MODE_EN_MASK (3 << 0)
0024 #define LDB_CH1_MODE_EN_TO_DI0 BIT(2)
0025 #define LDB_CH1_MODE_EN_TO_DI1 (3 << 2)
0026 #define LDB_CH1_MODE_EN_MASK (3 << 2)
0027 #define LDB_SPLIT_MODE_EN BIT(4)
0028 #define LDB_DATA_WIDTH_CH0_24 BIT(5)
0029 #define LDB_BIT_MAP_CH0_JEIDA BIT(6)
0030 #define LDB_DATA_WIDTH_CH1_24 BIT(7)
0031 #define LDB_BIT_MAP_CH1_JEIDA BIT(8)
0032 #define LDB_DI0_VS_POL_ACT_LOW BIT(9)
0033 #define LDB_DI1_VS_POL_ACT_LOW BIT(10)
0034
0035 #define MAX_LDB_CHAN_NUM 2
0036
0037 enum ldb_channel_link_type {
0038 LDB_CH_SINGLE_LINK,
0039 LDB_CH_DUAL_LINK_EVEN_ODD_PIXELS,
0040 LDB_CH_DUAL_LINK_ODD_EVEN_PIXELS,
0041 };
0042
0043 struct ldb;
0044
0045 struct ldb_channel {
0046 struct ldb *ldb;
0047 struct drm_bridge bridge;
0048 struct drm_bridge *next_bridge;
0049 struct device_node *np;
0050 u32 chno;
0051 bool is_available;
0052 u32 in_bus_format;
0053 u32 out_bus_format;
0054 enum ldb_channel_link_type link_type;
0055 };
0056
0057 struct ldb {
0058 struct regmap *regmap;
0059 struct device *dev;
0060 struct ldb_channel *channel[MAX_LDB_CHAN_NUM];
0061 unsigned int ctrl_reg;
0062 u32 ldb_ctrl;
0063 unsigned int available_ch_cnt;
0064 };
0065
0066 #define bridge_to_ldb_ch(b) container_of(b, struct ldb_channel, bridge)
0067
0068 bool ldb_channel_is_single_link(struct ldb_channel *ldb_ch);
0069 bool ldb_channel_is_split_link(struct ldb_channel *ldb_ch);
0070
0071 int ldb_bridge_atomic_check_helper(struct drm_bridge *bridge,
0072 struct drm_bridge_state *bridge_state,
0073 struct drm_crtc_state *crtc_state,
0074 struct drm_connector_state *conn_state);
0075
0076 void ldb_bridge_mode_set_helper(struct drm_bridge *bridge,
0077 const struct drm_display_mode *mode,
0078 const struct drm_display_mode *adjusted_mode);
0079
0080 void ldb_bridge_enable_helper(struct drm_bridge *bridge);
0081
0082 void ldb_bridge_disable_helper(struct drm_bridge *bridge);
0083
0084 int ldb_bridge_attach_helper(struct drm_bridge *bridge,
0085 enum drm_bridge_attach_flags flags);
0086
0087 int ldb_init_helper(struct ldb *ldb);
0088
0089 int ldb_find_next_bridge_helper(struct ldb *ldb);
0090
0091 void ldb_add_bridge_helper(struct ldb *ldb,
0092 const struct drm_bridge_funcs *bridge_funcs);
0093
0094 void ldb_remove_bridge_helper(struct ldb *ldb);
0095
0096 #endif