From b13656983a1ea8b938d789ea9d21d290dabd408d Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Wed, 8 Apr 2020 16:12:02 +0100 Subject: [PATCH 01/32] drm/vc4_hdmi: Add Broadcast RGB property to allow override of RGB range Copy Intel's "Broadcast RGB" property semantics to add manual override of the HDMI pixel range for monitors that don't abide by the content of the AVI Infoframe. Signed-off-by: Dave Stevenson --- drivers/gpu/drm/vc4/vc4_hdmi.c | 103 +++++++++++++++++++++++++++++++++ drivers/gpu/drm/vc4/vc4_hdmi.h | 15 +++++ 2 files changed, 118 insertions(+) diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index d71cd4378505..f1e0e0064b09 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -58,6 +58,14 @@ #include "vc4_hdmi_regs.h" #include "vc4_regs.h" +/* + * "Broadcast RGB" property. + * Allows overriding of HDMI full or limited range RGB + */ +#define VC4_BROADCAST_RGB_AUTO 0 +#define VC4_BROADCAST_RGB_FULL 1 +#define VC4_BROADCAST_RGB_LIMITED 2 + #define VC5_HDMI_HORZA_HFP_SHIFT 16 #define VC5_HDMI_HORZA_HFP_MASK VC4_MASK(28, 16) #define VC5_HDMI_HORZA_VPOS BIT(15) @@ -136,6 +144,10 @@ static bool vc4_hdmi_is_full_range_rgb(struct vc4_hdmi *vc4_hdmi, { struct vc4_hdmi_encoder *vc4_encoder = &vc4_hdmi->encoder; + if (vc4_hdmi->broadcast_rgb == VC4_BROADCAST_RGB_LIMITED) + return false; + else if (vc4_hdmi->broadcast_rgb == VC4_BROADCAST_RGB_FULL) + return true; return !vc4_encoder->hdmi_monitor || drm_default_rgb_quant_range(mode) == HDMI_QUANTIZATION_RANGE_FULL; } @@ -346,6 +358,65 @@ static int vc4_hdmi_connector_atomic_check(struct drm_connector *connector, return 0; } +/** + * vc4_hdmi_connector_atomic_get_property - hook for + * connector->atomic_get_property. + * @connector: Connector to get the property for. + * @state: Connector state to retrieve the property from. + * @property: Property to retrieve. + * @val: Return value for the property. + * + * Returns the atomic property value for a digital connector. + */ +int vc4_hdmi_connector_get_property(struct drm_connector *connector, + const struct drm_connector_state *state, + struct drm_property *property, + uint64_t *val) +{ + struct vc4_hdmi *vc4_hdmi = connector_to_vc4_hdmi(connector); + const struct vc4_hdmi_connector_state *vc4_conn_state = + const_conn_state_to_vc4_hdmi_conn_state(state); + + if (property == vc4_hdmi->broadcast_rgb_property) { + *val = vc4_conn_state->broadcast_rgb; + } else { + DRM_DEBUG_ATOMIC("Unknown property [PROP:%d:%s]\n", + property->base.id, property->name); + return -EINVAL; + } + + return 0; +} + +/** + * vc4_hdmi_connector_atomic_set_property - hook for + * connector->atomic_set_property. + * @connector: Connector to set the property for. + * @state: Connector state to set the property on. + * @property: Property to set. + * @val: New value for the property. + * + * Sets the atomic property value for a digital connector. + */ +int vc4_hdmi_connector_set_property(struct drm_connector *connector, + struct drm_connector_state *state, + struct drm_property *property, + uint64_t val) +{ + struct vc4_hdmi *vc4_hdmi = connector_to_vc4_hdmi(connector); + struct vc4_hdmi_connector_state *vc4_conn_state = + conn_state_to_vc4_hdmi_conn_state(state); + + if (property == vc4_hdmi->broadcast_rgb_property) { + vc4_conn_state->broadcast_rgb = val; + return 0; + } + + DRM_DEBUG_ATOMIC("Unknown property [PROP:%d:%s]\n", + property->base.id, property->name); + return -EINVAL; +} + static void vc4_hdmi_connector_reset(struct drm_connector *connector) { struct vc4_hdmi_connector_state *old_state = @@ -382,6 +453,7 @@ vc4_hdmi_connector_duplicate_state(struct drm_connector *connector) new_state->pixel_rate = vc4_state->pixel_rate; new_state->output_bpc = vc4_state->output_bpc; new_state->output_format = vc4_state->output_format; + new_state->broadcast_rgb = vc4_state->broadcast_rgb; __drm_atomic_helper_connector_duplicate_state(connector, &new_state->base); return &new_state->base; @@ -394,6 +466,8 @@ static const struct drm_connector_funcs vc4_hdmi_connector_funcs = { .reset = vc4_hdmi_connector_reset, .atomic_duplicate_state = vc4_hdmi_connector_duplicate_state, .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, + .atomic_get_property = vc4_hdmi_connector_get_property, + .atomic_set_property = vc4_hdmi_connector_set_property, }; static const struct drm_connector_helper_funcs vc4_hdmi_connector_helper_funcs = { @@ -401,6 +475,32 @@ static const struct drm_connector_helper_funcs vc4_hdmi_connector_helper_funcs = .atomic_check = vc4_hdmi_connector_atomic_check, }; +static const struct drm_prop_enum_list broadcast_rgb_names[] = { + { VC4_BROADCAST_RGB_AUTO, "Automatic" }, + { VC4_BROADCAST_RGB_FULL, "Full" }, + { VC4_BROADCAST_RGB_LIMITED, "Limited 16:235" }, +}; + +static void +vc4_hdmi_attach_broadcast_rgb_property(struct drm_device *dev, + struct vc4_hdmi *vc4_hdmi) +{ + struct drm_property *prop = vc4_hdmi->broadcast_rgb_property; + + if (!prop) { + prop = drm_property_create_enum(dev, DRM_MODE_PROP_ENUM, + "Broadcast RGB", + broadcast_rgb_names, + ARRAY_SIZE(broadcast_rgb_names)); + if (!prop) + return; + + vc4_hdmi->broadcast_rgb_property = prop; + } + + drm_object_attach_property(&vc4_hdmi->connector.base, prop, 0); +} + static int vc4_hdmi_connector_init(struct drm_device *dev, struct vc4_hdmi *vc4_hdmi) { @@ -444,6 +544,8 @@ static int vc4_hdmi_connector_init(struct drm_device *dev, if (vc4_hdmi->variant->supports_hdr) drm_connector_attach_hdr_output_metadata_property(connector); + vc4_hdmi_attach_broadcast_rgb_property(dev, vc4_hdmi); + drm_connector_attach_encoder(connector, encoder); return 0; @@ -1385,6 +1487,7 @@ static void vc4_hdmi_encoder_atomic_mode_set(struct drm_encoder *encoder, mutex_lock(&vc4_hdmi->mutex); vc4_hdmi->output_bpc = vc4_state->output_bpc; vc4_hdmi->output_format = vc4_state->output_format; + vc4_hdmi->broadcast_rgb = vc4_state->broadcast_rgb; memcpy(&vc4_hdmi->saved_adjusted_mode, &crtc_state->adjusted_mode, sizeof(vc4_hdmi->saved_adjusted_mode)); diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.h b/drivers/gpu/drm/vc4/vc4_hdmi.h index 3dd0d2a53a44..fa57d853b100 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.h +++ b/drivers/gpu/drm/vc4/vc4_hdmi.h @@ -142,6 +142,8 @@ struct vc4_hdmi { struct delayed_work scrambling_work; + struct drm_property *broadcast_rgb_property; + struct i2c_adapter *ddc; void __iomem *hdmicore_regs; void __iomem *hd_regs; @@ -254,6 +256,12 @@ struct vc4_hdmi { * for use outside of KMS hooks. Protected by @mutex. */ enum vc4_hdmi_output_format output_format; + + /** + * @broadcast_rgb: Copy of @vc4_connector_state.broadcast_rgb + * for use outside of KMS hooks. Protected by @mutex. + */ + int broadcast_rgb; }; static inline struct vc4_hdmi * @@ -275,6 +283,7 @@ struct vc4_hdmi_connector_state { unsigned long long pixel_rate; unsigned int output_bpc; enum vc4_hdmi_output_format output_format; + int broadcast_rgb; }; static inline struct vc4_hdmi_connector_state * @@ -283,6 +292,12 @@ conn_state_to_vc4_hdmi_conn_state(struct drm_connector_state *conn_state) return container_of(conn_state, struct vc4_hdmi_connector_state, base); } +static inline const struct vc4_hdmi_connector_state * +const_conn_state_to_vc4_hdmi_conn_state(const struct drm_connector_state *conn_state) +{ + return container_of(conn_state, struct vc4_hdmi_connector_state, base); +} + void vc4_hdmi_phy_init(struct vc4_hdmi *vc4_hdmi, struct vc4_hdmi_connector_state *vc4_conn_state); void vc4_hdmi_phy_disable(struct vc4_hdmi *vc4_hdmi); -- Gitee From c60057c13a738f50db1c19beb46ea8814bb3b730 Mon Sep 17 00:00:00 2001 From: Dom Cobley Date: Thu, 27 Jan 2022 14:31:21 +0000 Subject: [PATCH 02/32] Revert "vc4/drm: SQUASH: Fix source offsets with DRM_FORMAT_P030" This reverts commit d1fd8a5727908bb677c003d2ae977e9d935a6f94. --- drivers/gpu/drm/vc4/vc4_plane.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c index 074bdfdb184c..60a38bb13024 100644 --- a/drivers/gpu/drm/vc4/vc4_plane.c +++ b/drivers/gpu/drm/vc4/vc4_plane.c @@ -864,9 +864,8 @@ static int vc4_plane_mode_set(struct drm_plane *plane, * and bits[3:0] should be between 0 and 11, indicating which * of the 12-pixels in that 128-bit word is the first pixel to be used */ - u32 remaining_pixels = vc4_state->src_x % 96; - u32 aligned = remaining_pixels / 12; - u32 last_bits = remaining_pixels % 12; + u32 aligned = vc4_state->src_x / 12; + u32 last_bits = vc4_state->src_x % 12; x_off = aligned * 16 + last_bits; hvs_format = HVS_PIXEL_FORMAT_YCBCR_10BIT; -- Gitee From f678bf875ae609380811ff8a22ae27829617e141 Mon Sep 17 00:00:00 2001 From: Dom Cobley Date: Thu, 27 Jan 2022 14:31:28 +0000 Subject: [PATCH 03/32] Revert "vc4/drm: Fix source offsets with DRM_FORMAT_P030" This reverts commit 9b1b1beb1c7e58b3f967d21cd3dfd4837bdefb3f. --- drivers/gpu/drm/vc4/vc4_plane.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c index 60a38bb13024..046ac1fff467 100644 --- a/drivers/gpu/drm/vc4/vc4_plane.c +++ b/drivers/gpu/drm/vc4/vc4_plane.c @@ -858,20 +858,9 @@ static int vc4_plane_mode_set(struct drm_plane *plane, u32 tile_w, tile, x_off, pix_per_tile; if (fb->format->format == DRM_FORMAT_P030) { - /* - * Spec says: bits [31:4] of the given address should point to - * the 128-bit word containing the desired starting pixel, - * and bits[3:0] should be between 0 and 11, indicating which - * of the 12-pixels in that 128-bit word is the first pixel to be used - */ - u32 aligned = vc4_state->src_x / 12; - u32 last_bits = vc4_state->src_x % 12; - - x_off = aligned * 16 + last_bits; hvs_format = HVS_PIXEL_FORMAT_YCBCR_10BIT; tiling = SCALER_CTL0_TILING_128B; - tile_w = 128; - pix_per_tile = 96; + tile_w = 96; } else { hvs_format = HVS_PIXEL_FORMAT_H264; @@ -891,16 +880,17 @@ static int vc4_plane_mode_set(struct drm_plane *plane, default: break; } - pix_per_tile = tile_w / fb->format->cpp[0]; - x_off = (vc4_state->src_x % pix_per_tile) / - (i ? h_subsample : 1) * fb->format->cpp[i]; } if (param > SCALER_TILE_HEIGHT_MASK) { DRM_DEBUG_KMS("SAND height too large (%d)\n", param); return -EINVAL; } + + pix_per_tile = tile_w / fb->format->cpp[0]; tile = vc4_state->src_x / pix_per_tile; + x_off = vc4_state->src_x % pix_per_tile; + /* Adjust the base pointer to the first pixel to be scanned * out. * @@ -916,7 +906,9 @@ static int vc4_plane_mode_set(struct drm_plane *plane, vc4_state->offsets[i] += src_y / (i ? v_subsample : 1) * tile_w; - vc4_state->offsets[i] += x_off & ~(i ? 1 : 0); + vc4_state->offsets[i] += x_off / + (i ? h_subsample : 1) * + fb->format->cpp[i]; } pitch0 = VC4_SET_FIELD(param, SCALER_TILE_HEIGHT); -- Gitee From 21202b40b65114192efaf1a78d94bc25438f60d2 Mon Sep 17 00:00:00 2001 From: Dom Cobley Date: Thu, 27 Jan 2022 14:32:27 +0000 Subject: [PATCH 04/32] Revert "drm/vc4: Add support for DRM_FORMAT_P030 to vc4 planes" This reverts commit 63a31c81af9518d53b351dc8c2f24773cda77dfc. --- drivers/gpu/drm/vc4/vc4_plane.c | 79 +++++++++------------------------ 1 file changed, 22 insertions(+), 57 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c index 046ac1fff467..45cfcc725a91 100644 --- a/drivers/gpu/drm/vc4/vc4_plane.c +++ b/drivers/gpu/drm/vc4/vc4_plane.c @@ -33,7 +33,6 @@ static const struct hvs_format { u32 hvs; /* HVS_FORMAT_* */ u32 pixel_order; u32 pixel_order_hvs5; - bool hvs5_only; } hvs_formats[] = { { .drm = DRM_FORMAT_XRGB8888, @@ -129,12 +128,6 @@ static const struct hvs_format { .hvs = HVS_PIXEL_FORMAT_YCBCR_YUV422_2PLANE, .pixel_order = HVS_PIXEL_ORDER_XYCRCB, }, - { - .drm = DRM_FORMAT_P030, - .hvs = HVS_PIXEL_FORMAT_YCBCR_10BIT, - .pixel_order = HVS_PIXEL_ORDER_XYCBCR, - .hvs5_only = true, - }, }; static const struct hvs_format *vc4_get_hvs_format(u32 drm_format) @@ -857,33 +850,27 @@ static int vc4_plane_mode_set(struct drm_plane *plane, uint32_t param = fourcc_mod_broadcom_param(fb->modifier); u32 tile_w, tile, x_off, pix_per_tile; - if (fb->format->format == DRM_FORMAT_P030) { - hvs_format = HVS_PIXEL_FORMAT_YCBCR_10BIT; + hvs_format = HVS_PIXEL_FORMAT_H264; + + switch (base_format_mod) { + case DRM_FORMAT_MOD_BROADCOM_SAND64: + tiling = SCALER_CTL0_TILING_64B; + tile_w = 64; + break; + case DRM_FORMAT_MOD_BROADCOM_SAND128: tiling = SCALER_CTL0_TILING_128B; - tile_w = 96; - } else { - hvs_format = HVS_PIXEL_FORMAT_H264; - - switch (base_format_mod) { - case DRM_FORMAT_MOD_BROADCOM_SAND64: - tiling = SCALER_CTL0_TILING_64B; - tile_w = 64; - break; - case DRM_FORMAT_MOD_BROADCOM_SAND128: - tiling = SCALER_CTL0_TILING_128B; - tile_w = 128; - break; - case DRM_FORMAT_MOD_BROADCOM_SAND256: - tiling = SCALER_CTL0_TILING_256B_OR_T; - tile_w = 256; - break; - default: - break; - } + tile_w = 128; + break; + case DRM_FORMAT_MOD_BROADCOM_SAND256: + tiling = SCALER_CTL0_TILING_256B_OR_T; + tile_w = 256; + break; + default: + break; } + if (param > SCALER_TILE_HEIGHT_MASK) { - DRM_DEBUG_KMS("SAND height too large (%d)\n", - param); + DRM_DEBUG_KMS("SAND height too large (%d)\n", param); return -EINVAL; } @@ -893,13 +880,6 @@ static int vc4_plane_mode_set(struct drm_plane *plane, /* Adjust the base pointer to the first pixel to be scanned * out. - * - * For P030, y_ptr [31:4] is the 128bit word for the start pixel - * y_ptr [3:0] is the pixel (0-11) contained within that 128bit - * word that should be taken as the first pixel. - * Ditto uv_ptr [31:4] vs [3:0], however [3:0] contains the - * element within the 128bit word, eg for pixel 3 the value - * should be 6. */ for (i = 0; i < num_planes; i++) { vc4_state->offsets[i] += param * tile_w * tile; @@ -1051,8 +1031,7 @@ static int vc4_plane_mode_set(struct drm_plane *plane, /* Pitch word 1/2 */ for (i = 1; i < num_planes; i++) { - if (hvs_format != HVS_PIXEL_FORMAT_H264 && - hvs_format != HVS_PIXEL_FORMAT_YCBCR_10BIT) { + if (hvs_format != HVS_PIXEL_FORMAT_H264) { vc4_dlist_write(vc4_state, VC4_SET_FIELD(fb->pitches[i], SCALER_SRC_PITCH)); @@ -1417,13 +1396,6 @@ static bool vc4_format_mod_supported(struct drm_plane *plane, default: return false; } - case DRM_FORMAT_P030: - switch (fourcc_mod_broadcom_mod(modifier)) { - case DRM_FORMAT_MOD_BROADCOM_SAND128: - return true; - default: - return false; - } case DRM_FORMAT_RGBX1010102: case DRM_FORMAT_BGRX1010102: case DRM_FORMAT_RGBA1010102: @@ -1456,11 +1428,8 @@ struct drm_plane *vc4_plane_init(struct drm_device *dev, struct drm_plane *plane = NULL; struct vc4_plane *vc4_plane; u32 formats[ARRAY_SIZE(hvs_formats)]; - int num_formats = 0; int ret = 0; unsigned i; - bool hvs5 = of_device_is_compatible(dev->dev->of_node, - "brcm,bcm2711-vc5"); static const uint64_t modifiers[] = { DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED, DRM_FORMAT_MOD_BROADCOM_SAND128, @@ -1475,17 +1444,13 @@ struct drm_plane *vc4_plane_init(struct drm_device *dev, if (!vc4_plane) return ERR_PTR(-ENOMEM); - for (i = 0; i < ARRAY_SIZE(hvs_formats); i++) { - if (!hvs_formats[i].hvs5_only || hvs5) { - formats[num_formats] = hvs_formats[i].drm; - num_formats++; - } - } + for (i = 0; i < ARRAY_SIZE(hvs_formats); i++) + formats[i] = hvs_formats[i].drm; plane = &vc4_plane->base; ret = drm_universal_plane_init(dev, plane, 0, &vc4_plane_funcs, - formats, num_formats, + formats, ARRAY_SIZE(formats), modifiers, type, NULL); if (ret) return ERR_PTR(ret); -- Gitee From f4b5f12d9e59ee91455f3eb08166f2b443a26386 Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Wed, 15 Dec 2021 10:17:38 +0100 Subject: [PATCH 05/32] drm/vc4: plane: Add support for DRM_FORMAT_P030 The P030 format, used with the DRM_FORMAT_MOD_BROADCOM_SAND128 modifier, is a format output by the video decoder on the BCM2711. Add native support to the KMS planes for that format. Signed-off-by: Dave Stevenson Signed-off-by: Maxime Ripard Acked-by: Thomas Zimmermann Link: https://lore.kernel.org/r/20211215091739.135042-3-maxime@cerno.tech --- drivers/gpu/drm/vc4/vc4_plane.c | 127 ++++++++++++++++++++++++-------- 1 file changed, 96 insertions(+), 31 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c index 45cfcc725a91..70895a93b5ff 100644 --- a/drivers/gpu/drm/vc4/vc4_plane.c +++ b/drivers/gpu/drm/vc4/vc4_plane.c @@ -33,6 +33,7 @@ static const struct hvs_format { u32 hvs; /* HVS_FORMAT_* */ u32 pixel_order; u32 pixel_order_hvs5; + bool hvs5_only; } hvs_formats[] = { { .drm = DRM_FORMAT_XRGB8888, @@ -128,6 +129,12 @@ static const struct hvs_format { .hvs = HVS_PIXEL_FORMAT_YCBCR_YUV422_2PLANE, .pixel_order = HVS_PIXEL_ORDER_XYCRCB, }, + { + .drm = DRM_FORMAT_P030, + .hvs = HVS_PIXEL_FORMAT_YCBCR_10BIT, + .pixel_order = HVS_PIXEL_ORDER_XYCBCR, + .hvs5_only = true, + }, }; static const struct hvs_format *vc4_get_hvs_format(u32 drm_format) @@ -848,47 +855,90 @@ static int vc4_plane_mode_set(struct drm_plane *plane, case DRM_FORMAT_MOD_BROADCOM_SAND128: case DRM_FORMAT_MOD_BROADCOM_SAND256: { uint32_t param = fourcc_mod_broadcom_param(fb->modifier); - u32 tile_w, tile, x_off, pix_per_tile; - - hvs_format = HVS_PIXEL_FORMAT_H264; - - switch (base_format_mod) { - case DRM_FORMAT_MOD_BROADCOM_SAND64: - tiling = SCALER_CTL0_TILING_64B; - tile_w = 64; - break; - case DRM_FORMAT_MOD_BROADCOM_SAND128: - tiling = SCALER_CTL0_TILING_128B; - tile_w = 128; - break; - case DRM_FORMAT_MOD_BROADCOM_SAND256: - tiling = SCALER_CTL0_TILING_256B_OR_T; - tile_w = 256; - break; - default: - break; - } if (param > SCALER_TILE_HEIGHT_MASK) { - DRM_DEBUG_KMS("SAND height too large (%d)\n", param); + DRM_DEBUG_KMS("SAND height too large (%d)\n", + param); return -EINVAL; } - pix_per_tile = tile_w / fb->format->cpp[0]; - tile = vc4_state->src_x / pix_per_tile; - x_off = vc4_state->src_x % pix_per_tile; + if (fb->format->format == DRM_FORMAT_P030) { + hvs_format = HVS_PIXEL_FORMAT_YCBCR_10BIT; + tiling = SCALER_CTL0_TILING_128B; + } else { + hvs_format = HVS_PIXEL_FORMAT_H264; + + switch (base_format_mod) { + case DRM_FORMAT_MOD_BROADCOM_SAND64: + tiling = SCALER_CTL0_TILING_64B; + break; + case DRM_FORMAT_MOD_BROADCOM_SAND128: + tiling = SCALER_CTL0_TILING_128B; + break; + case DRM_FORMAT_MOD_BROADCOM_SAND256: + tiling = SCALER_CTL0_TILING_256B_OR_T; + break; + default: + return -EINVAL; + } + } /* Adjust the base pointer to the first pixel to be scanned * out. + * + * For P030, y_ptr [31:4] is the 128bit word for the start pixel + * y_ptr [3:0] is the pixel (0-11) contained within that 128bit + * word that should be taken as the first pixel. + * Ditto uv_ptr [31:4] vs [3:0], however [3:0] contains the + * element within the 128bit word, eg for pixel 3 the value + * should be 6. */ for (i = 0; i < num_planes; i++) { + u32 tile_w, tile, x_off, pix_per_tile; + + if (fb->format->format == DRM_FORMAT_P030) { + /* + * Spec says: bits [31:4] of the given address + * should point to the 128-bit word containing + * the desired starting pixel, and bits[3:0] + * should be between 0 and 11, indicating which + * of the 12-pixels in that 128-bit word is the + * first pixel to be used + */ + u32 remaining_pixels = vc4_state->src_x % 96; + u32 aligned = remaining_pixels / 12; + u32 last_bits = remaining_pixels % 12; + + x_off = aligned * 16 + last_bits; + tile_w = 128; + pix_per_tile = 96; + } else { + switch (base_format_mod) { + case DRM_FORMAT_MOD_BROADCOM_SAND64: + tile_w = 64; + break; + case DRM_FORMAT_MOD_BROADCOM_SAND128: + tile_w = 128; + break; + case DRM_FORMAT_MOD_BROADCOM_SAND256: + tile_w = 256; + break; + default: + return -EINVAL; + } + pix_per_tile = tile_w / fb->format->cpp[0]; + x_off = (vc4_state->src_x % pix_per_tile) / + (i ? h_subsample : 1) * + fb->format->cpp[i]; + } + + tile = vc4_state->src_x / pix_per_tile; + vc4_state->offsets[i] += param * tile_w * tile; vc4_state->offsets[i] += src_y / (i ? v_subsample : 1) * tile_w; - vc4_state->offsets[i] += x_off / - (i ? h_subsample : 1) * - fb->format->cpp[i]; + vc4_state->offsets[i] += x_off & ~(i ? 1 : 0); } pitch0 = VC4_SET_FIELD(param, SCALER_TILE_HEIGHT); @@ -1031,7 +1081,8 @@ static int vc4_plane_mode_set(struct drm_plane *plane, /* Pitch word 1/2 */ for (i = 1; i < num_planes; i++) { - if (hvs_format != HVS_PIXEL_FORMAT_H264) { + if (hvs_format != HVS_PIXEL_FORMAT_H264 && + hvs_format != HVS_PIXEL_FORMAT_YCBCR_10BIT) { vc4_dlist_write(vc4_state, VC4_SET_FIELD(fb->pitches[i], SCALER_SRC_PITCH)); @@ -1396,6 +1447,13 @@ static bool vc4_format_mod_supported(struct drm_plane *plane, default: return false; } + case DRM_FORMAT_P030: + switch (fourcc_mod_broadcom_mod(modifier)) { + case DRM_FORMAT_MOD_BROADCOM_SAND128: + return true; + default: + return false; + } case DRM_FORMAT_RGBX1010102: case DRM_FORMAT_BGRX1010102: case DRM_FORMAT_RGBA1010102: @@ -1428,8 +1486,11 @@ struct drm_plane *vc4_plane_init(struct drm_device *dev, struct drm_plane *plane = NULL; struct vc4_plane *vc4_plane; u32 formats[ARRAY_SIZE(hvs_formats)]; + int num_formats = 0; int ret = 0; unsigned i; + bool hvs5 = of_device_is_compatible(dev->dev->of_node, + "brcm,bcm2711-vc5"); static const uint64_t modifiers[] = { DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED, DRM_FORMAT_MOD_BROADCOM_SAND128, @@ -1444,13 +1505,17 @@ struct drm_plane *vc4_plane_init(struct drm_device *dev, if (!vc4_plane) return ERR_PTR(-ENOMEM); - for (i = 0; i < ARRAY_SIZE(hvs_formats); i++) - formats[i] = hvs_formats[i].drm; + for (i = 0; i < ARRAY_SIZE(hvs_formats); i++) { + if (!hvs_formats[i].hvs5_only || hvs5) { + formats[num_formats] = hvs_formats[i].drm; + num_formats++; + } + } plane = &vc4_plane->base; ret = drm_universal_plane_init(dev, plane, 0, &vc4_plane_funcs, - formats, ARRAY_SIZE(formats), + formats, num_formats, modifiers, type, NULL); if (ret) return ERR_PTR(ret); -- Gitee From de3814a98e47d2c895902924303c96a9892a4890 Mon Sep 17 00:00:00 2001 From: coldspark29 Date: Wed, 18 Aug 2021 14:42:22 +0200 Subject: [PATCH 06/32] configs: Add CONFIG_MAX30102=m See: https://github.com/raspberrypi/linux/pull/4535 Signed-off-by: Phil Elwell --- arch/arm/configs/bcm2709_defconfig | 1 + arch/arm/configs/bcm2711_defconfig | 1 + arch/arm/configs/bcmrpi_defconfig | 1 + arch/arm64/configs/bcm2711_defconfig | 1 + arch/arm64/configs/bcmrpi3_defconfig | 1 + 5 files changed, 5 insertions(+) diff --git a/arch/arm/configs/bcm2709_defconfig b/arch/arm/configs/bcm2709_defconfig index 04a38fe4c6d9..f2074da8a80d 100644 --- a/arch/arm/configs/bcm2709_defconfig +++ b/arch/arm/configs/bcm2709_defconfig @@ -1366,6 +1366,7 @@ CONFIG_BME680=m CONFIG_CCS811=m CONFIG_SENSIRION_SGP30=m CONFIG_SPS30=m +CONFIG_MAX30102=m CONFIG_DHT11=m CONFIG_HDC100X=m CONFIG_HTU21=m diff --git a/arch/arm/configs/bcm2711_defconfig b/arch/arm/configs/bcm2711_defconfig index 77cccb33de2a..8f4ae82cade4 100644 --- a/arch/arm/configs/bcm2711_defconfig +++ b/arch/arm/configs/bcm2711_defconfig @@ -1388,6 +1388,7 @@ CONFIG_BME680=m CONFIG_CCS811=m CONFIG_SENSIRION_SGP30=m CONFIG_SPS30=m +CONFIG_MAX30102=m CONFIG_DHT11=m CONFIG_HDC100X=m CONFIG_HTU21=m diff --git a/arch/arm/configs/bcmrpi_defconfig b/arch/arm/configs/bcmrpi_defconfig index f2a474cdad56..b3ea44509d98 100644 --- a/arch/arm/configs/bcmrpi_defconfig +++ b/arch/arm/configs/bcmrpi_defconfig @@ -1359,6 +1359,7 @@ CONFIG_BME680=m CONFIG_CCS811=m CONFIG_SENSIRION_SGP30=m CONFIG_SPS30=m +CONFIG_MAX30102=m CONFIG_DHT11=m CONFIG_HDC100X=m CONFIG_HTU21=m diff --git a/arch/arm64/configs/bcm2711_defconfig b/arch/arm64/configs/bcm2711_defconfig index b8e434797aa9..75333e69ef74 100644 --- a/arch/arm64/configs/bcm2711_defconfig +++ b/arch/arm64/configs/bcm2711_defconfig @@ -1395,6 +1395,7 @@ CONFIG_BME680=m CONFIG_CCS811=m CONFIG_SENSIRION_SGP30=m CONFIG_SPS30=m +CONFIG_MAX30102=m CONFIG_DHT11=m CONFIG_HDC100X=m CONFIG_HTU21=m diff --git a/arch/arm64/configs/bcmrpi3_defconfig b/arch/arm64/configs/bcmrpi3_defconfig index 57073001891c..419813140a52 100644 --- a/arch/arm64/configs/bcmrpi3_defconfig +++ b/arch/arm64/configs/bcmrpi3_defconfig @@ -1250,6 +1250,7 @@ CONFIG_BME680=m CONFIG_CCS811=m CONFIG_SENSIRION_SGP30=m CONFIG_SPS30=m +CONFIG_MAX30102=m CONFIG_DHT11=m CONFIG_HTU21=m CONFIG_APDS9960=m -- Gitee From 3e1d9405266765614ca56e439800aaea3e563522 Mon Sep 17 00:00:00 2001 From: coldspark29 Date: Wed, 18 Aug 2021 13:41:04 +0200 Subject: [PATCH 07/32] overlays: Add MAX30102 HR to i2c-sensor overlay Add support for the MAX30102 heart rate and blood oxygen sensor to the i2c-sensor overlay. See: https://github.com/raspberrypi/linux/pull/4535 Signed-off-by: Phil Elwell --- arch/arm/boot/dts/overlays/README | 6 ++++++ .../boot/dts/overlays/i2c-sensor-overlay.dts | 20 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/arch/arm/boot/dts/overlays/README b/arch/arm/boot/dts/overlays/README index f848a7fc87af..f124086d4702 100644 --- a/arch/arm/boot/dts/overlays/README +++ b/arch/arm/boot/dts/overlays/README @@ -1725,6 +1725,9 @@ Params: addr Set the address for the BH1750, BME280, BME680, htu21 Select the HTU21 temperature and humidity sensor + int_pin Set the GPIO to use for interrupts (max30102 + only) + lm75 Select the Maxim LM75 temperature sensor Valid addresses 0x48-0x4f, default 0x4f @@ -1733,6 +1736,9 @@ Params: addr Set the address for the BH1750, BME280, BME680, max17040 Select the Maxim Integrated MAX17040 battery monitor + max30102 Select the Maxim Integrated MAX30102 heart-rate + and blood-oxygen sensor + sht3x Select the Sensiron SHT3x temperature and humidity sensor. Valid addresses 0x44-0x45, default 0x44 diff --git a/arch/arm/boot/dts/overlays/i2c-sensor-overlay.dts b/arch/arm/boot/dts/overlays/i2c-sensor-overlay.dts index b05b0fa91942..33965be4b1e8 100755 --- a/arch/arm/boot/dts/overlays/i2c-sensor-overlay.dts +++ b/arch/arm/boot/dts/overlays/i2c-sensor-overlay.dts @@ -291,11 +291,30 @@ }; }; + fragment@19 { + target = <&i2c_arm>; + __dormant__ { + #address-cells = <1>; + #size-cells = <0>; + status = "okay"; + + max30102: max30102@57 { + compatible = "maxim,max30102"; + reg = <0x57>; + maxim,red-led-current-microamp = <7000>; + maxim,ir-led-current-microamp = <7000>; + interrupt-parent = <&gpio>; + interrupts = <4 2>; + }; + }; + }; + __overrides__ { addr = <&bme280>,"reg:0", <&bmp280>,"reg:0", <&tmp102>,"reg:0", <&lm75>,"reg:0", <&hdc100x>,"reg:0", <&sht3x>,"reg:0", <&ds1621>,"reg:0", <&bme680>,"reg:0", <&ccs811>,"reg:0", <&bh1750>,"reg:0"; + int_pin = <&max30102>, "interrupts:0"; bme280 = <0>,"+0"; bmp085 = <0>,"+1"; bmp180 = <0>,"+2"; @@ -316,5 +335,6 @@ sgp30 = <0>,"+16"; ccs811 = <0>, "+17"; bh1750 = <0>, "+18"; + max30102 = <0>,"+19"; }; }; -- Gitee From 64213d89a7289dad030ae1221148ad498c2ff5a6 Mon Sep 17 00:00:00 2001 From: Alex Crawford Date: Fri, 28 Jan 2022 13:36:51 -0800 Subject: [PATCH 08/32] i2c: bcm2835: Make clock-stretch timeout configurable The default clock-stretch timeout is 35 mS, which works well for SMBus, but there are some I2C devices which can stretch the clock even longer. Rather than trying to prescribe a safe default for everyone, allow the timeout to be configured. Signed-off-by: Alex Crawford --- drivers/i2c/busses/i2c-bcm2835.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/busses/i2c-bcm2835.c b/drivers/i2c/busses/i2c-bcm2835.c index 5b2589b6b9cc..7d8e183bb533 100644 --- a/drivers/i2c/busses/i2c-bcm2835.c +++ b/drivers/i2c/busses/i2c-bcm2835.c @@ -55,6 +55,10 @@ static unsigned int debug; module_param(debug, uint, 0644); MODULE_PARM_DESC(debug, "1=err, 2=isr, 3=xfer"); +static unsigned int clk_tout_ms = 35; /* SMBUs-recommended 35ms */ +module_param(clk_tout_ms, uint, 0644); +MODULE_PARM_DESC(clk_tout_ms, "clock-stretch timeout (mS)"); + #define BCM2835_DEBUG_MAX 512 struct bcm2835_debug { struct i2c_msg *msg; @@ -214,12 +218,12 @@ static int clk_bcm2835_i2c_set_rate(struct clk_hw *hw, unsigned long rate, (redl << BCM2835_I2C_REDL_SHIFT)); /* - * Set the clock stretch timeout to the SMBUs-recommended 35ms. + * Set the clock stretch timeout. */ - if (rate > 0xffff*1000/35) + if (rate > 0xffff*1000/clk_tout_ms) clk_tout = 0xffff; else - clk_tout = 35*rate/1000; + clk_tout = clk_tout_ms*rate/1000; bcm2835_i2c_writel(div->i2c_dev, BCM2835_I2C_CLKT, clk_tout); -- Gitee From d0c1c1bec642133977fd07cec511ebb1553c558e Mon Sep 17 00:00:00 2001 From: tiagofreire-pt <41837236+tiagofreire-pt@users.noreply.github.com> Date: Sat, 29 Jan 2022 10:01:36 +0000 Subject: [PATCH 09/32] Patching lan78xx for SOF_TIMESTAMPING_TX_SOFTWARE support --- drivers/net/usb/lan78xx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c index 2da884e795a9..54b3eb586b7e 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -1685,6 +1685,7 @@ static const struct ethtool_ops lan78xx_ethtool_ops = { .set_link_ksettings = lan78xx_set_link_ksettings, .get_regs_len = lan78xx_get_regs_len, .get_regs = lan78xx_get_regs, + .get_ts_info = ethtool_op_get_ts_info, }; static void lan78xx_init_mac_address(struct lan78xx_net *dev) -- Gitee From f2d989b5db0ef20b7456316042eb44936172d979 Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Mon, 31 Jan 2022 16:28:43 +0000 Subject: [PATCH 10/32] drm/vc4: Add DRM 210101010 RGB formats for hvs5. HVS5 supports the 210101010 RGB[A|X] formats, but they were missing from the DRM to HVS mapping list, so weren't available. Add them in. Signed-off-by: Dave Stevenson --- drivers/gpu/drm/vc4/vc4_plane.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c index 70895a93b5ff..766280a844f4 100644 --- a/drivers/gpu/drm/vc4/vc4_plane.c +++ b/drivers/gpu/drm/vc4/vc4_plane.c @@ -135,6 +135,34 @@ static const struct hvs_format { .pixel_order = HVS_PIXEL_ORDER_XYCBCR, .hvs5_only = true, }, + { + .drm = DRM_FORMAT_XRGB2101010, + .hvs = HVS_PIXEL_FORMAT_RGBA1010102, + .pixel_order = HVS_PIXEL_ORDER_ABGR, + .pixel_order_hvs5 = HVS_PIXEL_ORDER_ARGB, + .hvs5_only = true, + }, + { + .drm = DRM_FORMAT_ARGB2101010, + .hvs = HVS_PIXEL_FORMAT_RGBA1010102, + .pixel_order = HVS_PIXEL_ORDER_ABGR, + .pixel_order_hvs5 = HVS_PIXEL_ORDER_ARGB, + .hvs5_only = true, + }, + { + .drm = DRM_FORMAT_ABGR2101010, + .hvs = HVS_PIXEL_FORMAT_RGBA1010102, + .pixel_order = HVS_PIXEL_ORDER_ARGB, + .pixel_order_hvs5 = HVS_PIXEL_ORDER_ABGR, + .hvs5_only = true, + }, + { + .drm = DRM_FORMAT_XBGR2101010, + .hvs = HVS_PIXEL_FORMAT_RGBA1010102, + .pixel_order = HVS_PIXEL_ORDER_ARGB, + .pixel_order_hvs5 = HVS_PIXEL_ORDER_ABGR, + .hvs5_only = true, + }, }; static const struct hvs_format *vc4_get_hvs_format(u32 drm_format) -- Gitee From 032298b17a974b1cf39671e8e27718d420bf7cb1 Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Mon, 31 Jan 2022 21:01:25 +0000 Subject: [PATCH 11/32] overlays: Add spi0-0cs overlay An overlay to enable SPI0 without claiming any chip select GPIOs. Signed-off-by: Phil Elwell --- arch/arm/boot/dts/overlays/Makefile | 1 + arch/arm/boot/dts/overlays/README | 8 ++++ .../boot/dts/overlays/spi0-0cs-overlay.dts | 39 +++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 arch/arm/boot/dts/overlays/spi0-0cs-overlay.dts diff --git a/arch/arm/boot/dts/overlays/Makefile b/arch/arm/boot/dts/overlays/Makefile index bff07c1748b7..f51eca4887d5 100644 --- a/arch/arm/boot/dts/overlays/Makefile +++ b/arch/arm/boot/dts/overlays/Makefile @@ -194,6 +194,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \ spi-gpio35-39.dtbo \ spi-gpio40-45.dtbo \ spi-rtc.dtbo \ + spi0-0cs.dtbo \ spi0-1cs.dtbo \ spi0-2cs.dtbo \ spi1-1cs.dtbo \ diff --git a/arch/arm/boot/dts/overlays/README b/arch/arm/boot/dts/overlays/README index f124086d4702..0a2f62f2f28f 100644 --- a/arch/arm/boot/dts/overlays/README +++ b/arch/arm/boot/dts/overlays/README @@ -3098,6 +3098,14 @@ Params: ds3232 Select the DS3232 device cs_high This device requires an active-high CS +Name: spi0-0cs +Info: Don't claim any CS pins for SPI0. Requires a device with its chip + select permanently enabled, but frees a GPIO for e.g. a DPI display. +Load: dtoverlay=spi0-0cs,= +Params: no_miso Don't claim and use the MISO pin (9), freeing + it for other uses. + + Name: spi0-1cs Info: Only use one CS pin for SPI0 Load: dtoverlay=spi0-1cs,= diff --git a/arch/arm/boot/dts/overlays/spi0-0cs-overlay.dts b/arch/arm/boot/dts/overlays/spi0-0cs-overlay.dts new file mode 100644 index 000000000000..0d2acabf56a4 --- /dev/null +++ b/arch/arm/boot/dts/overlays/spi0-0cs-overlay.dts @@ -0,0 +1,39 @@ +/dts-v1/; +/plugin/; + +/ { + compatible = "brcm,bcm2835"; + + fragment@0 { + target = <&spi0_cs_pins>; + frag0: __overlay__ { + brcm,pins; + }; + }; + + fragment@1 { + target = <&spi0>; + __overlay__ { + cs-gpios; + status = "okay"; + }; + }; + + fragment@2 { + target = <&spidev1>; + __overlay__ { + status = "disabled"; + }; + }; + + fragment@3 { + target = <&spi0_pins>; + __dormant__ { + brcm,pins = <10 11>; + }; + }; + + __overrides__ { + no_miso = <0>,"=3"; + }; +}; -- Gitee From fd1a4755158a2b7f84c0f7bbe7211194c91de858 Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Fri, 21 Jan 2022 14:22:01 +0000 Subject: [PATCH 12/32] dtoverlays: Add pwm backlight option to vc4-kms-dpi-generic Adds the option of a PWM controlled backlight on a generic DPI display. Signed-off-by: Dave Stevenson --- arch/arm/boot/dts/overlays/README | 17 +++++++ .../overlays/vc4-kms-dpi-generic-overlay.dts | 51 +++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/arch/arm/boot/dts/overlays/README b/arch/arm/boot/dts/overlays/README index 0a2f62f2f28f..7b7714be39e4 100644 --- a/arch/arm/boot/dts/overlays/README +++ b/arch/arm/boot/dts/overlays/README @@ -3641,6 +3641,23 @@ Params: clock-frequency Display clock frequency (Hz) value. NB also overridden by rgbXXX overrides. backlight-gpio Defines a GPIO to be used for backlight control (default of none). + backlight-pwm Defines a PWM channel to be used for backlight + control (default of none). NB Disables audio + headphone output as that also uses PWM. + backlight-pwm-chan Choose channel on &pwm node for backlight + control. + (default 0). + backlight-pwm-gpio GPIO pin to be used for the PWM backlight. See + pwm-2chan for valid options. + (default 18 - note this can only work with + rgb666-padhi). + backlight-pwm-func Pin function of GPIO used for the PWM + backlight. + See pwm-2chan for valid options. + (default 2). + backlight-def-brightness + Set the default brightness. Normal range 1-16. + (default 16). Name: vc4-kms-dsi-7inch diff --git a/arch/arm/boot/dts/overlays/vc4-kms-dpi-generic-overlay.dts b/arch/arm/boot/dts/overlays/vc4-kms-dpi-generic-overlay.dts index 7846d56c1d1a..b62c0945582f 100644 --- a/arch/arm/boot/dts/overlays/vc4-kms-dpi-generic-overlay.dts +++ b/arch/arm/boot/dts/overlays/vc4-kms-dpi-generic-overlay.dts @@ -80,6 +80,52 @@ }; }; + fragment@4 { + target = <&panel>; + __dormant__ { + backlight = <&backlight_pwm>; + }; + }; + + fragment@5 { + target-path = "/"; + __dormant__ { + backlight_pwm: backlight_pwm { + compatible = "pwm-backlight"; + brightness-levels = <0 6 8 12 16 24 32 40 48 64 96 128 160 192 224 255>; + default-brightness-level = <16>; + pwms = <&pwm 0 200000>; + }; + }; + }; + + fragment@6 { + target = <&pwm>; + __dormant__ { + pinctrl-names = "default"; + pinctrl-0 = <&pwm_pins>; + assigned-clock-rates = <1000000>; + status = "okay"; + }; + }; + + fragment@7 { + target = <&gpio>; + __dormant__ { + pwm_pins: pwm_pins { + brcm,pins = <18>; + brcm,function = <2>; /* Alt5 */ + }; + }; + }; + + fragment@8 { + target = <&audio>; + __dormant__ { + brcm,disable-headphones; + }; + }; + __overrides__ { clock-frequency = <&timing>, "clock-frequency:0"; hactive = <&timing>, "hactive:0"; @@ -107,5 +153,10 @@ bus-format = <&panel>, "bus-format:0"; backlight-gpio = <0>, "+2+3", <&backlight>, "gpios:4"; + backlight-pwm = <0>, "+4+5+6+7+8"; + backlight-pwm-chan = <&backlight_pwm>, "pwms:4"; + backlight-pwm-gpio = <&pwm_pins>, "brcm,pins:0"; + backlight-pwm-func = <&pwm_pins>, "brcm,function:0"; + backlight-def-brightness = <&backlight_pwm>, "default-brightness-level:0"; }; }; -- Gitee From 488d0e33302adac0416d9d11a007810c3b12e06b Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Fri, 21 Jan 2022 15:12:25 +0000 Subject: [PATCH 13/32] dtoverlays: Correct [h|v]sync_invert config in vc4-kms-dpi-generic Both the base node and override set these parameters to 0, so it made no difference. The base node should have been 1. Signed-off-by: Dave Stevenson --- arch/arm/boot/dts/overlays/vc4-kms-dpi-generic-overlay.dts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm/boot/dts/overlays/vc4-kms-dpi-generic-overlay.dts b/arch/arm/boot/dts/overlays/vc4-kms-dpi-generic-overlay.dts index b62c0945582f..54bcd7d8505c 100644 --- a/arch/arm/boot/dts/overlays/vc4-kms-dpi-generic-overlay.dts +++ b/arch/arm/boot/dts/overlays/vc4-kms-dpi-generic-overlay.dts @@ -1,5 +1,5 @@ /* - * vc4-kms-dpi-at056tn53v1-overlay.dts + * vc4-kms-dpi-generic-overlay.dts */ /dts-v1/; @@ -27,12 +27,12 @@ hfront-porch = <24>; hsync-len = <72>; hback-porch = <96>; - hsync-active = <0>; + hsync-active = <1>; vactive = <480>; vfront-porch = <3>; vsync-len = <10>; vback-porch = <7>; - vsync-active = <0>; + vsync-active = <1>; de-active = <1>; pixelclk-active = <1>; -- Gitee From 9137c29929ab14d8ade490161aea55c6349f4c7c Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Mon, 31 Jan 2022 17:25:19 +0000 Subject: [PATCH 14/32] dtoverlays: Rework vc4-kms-dpi overlays to remove duplication Removes all the common panel, dpi, and backlight configuration from the individual vc4-kms-dpi-* files into vc4-kms-dpi.dtsi. Creates a new vc4-kms-dpi-panel-overlay.dts for preconfigured panels, with overrides to enable the different panel configurations. Deprecates vc4-kms-dpi-at056tn53v1 as superceded by vc4-kms-dpi-panel. vc4-kms-kippah-7inch not deprecated for now as it is likely to be in wider use than at056tn53v1. Signed-off-by: Dave Stevenson --- arch/arm/boot/dts/overlays/Makefile | 2 +- arch/arm/boot/dts/overlays/README | 33 ++++- arch/arm/boot/dts/overlays/overlay_map.dts | 4 + .../vc4-kms-dpi-at056tn53v1-overlay.dts | 44 ------ .../overlays/vc4-kms-dpi-generic-overlay.dts | 138 ++++-------------- .../overlays/vc4-kms-dpi-panel-overlay.dts | 62 ++++++++ arch/arm/boot/dts/overlays/vc4-kms-dpi.dtsi | 109 ++++++++++++++ .../overlays/vc4-kms-kippah-7inch-overlay.dts | 27 +--- 8 files changed, 235 insertions(+), 184 deletions(-) delete mode 100644 arch/arm/boot/dts/overlays/vc4-kms-dpi-at056tn53v1-overlay.dts create mode 100644 arch/arm/boot/dts/overlays/vc4-kms-dpi-panel-overlay.dts create mode 100644 arch/arm/boot/dts/overlays/vc4-kms-dpi.dtsi diff --git a/arch/arm/boot/dts/overlays/Makefile b/arch/arm/boot/dts/overlays/Makefile index f51eca4887d5..6fcacdccb608 100644 --- a/arch/arm/boot/dts/overlays/Makefile +++ b/arch/arm/boot/dts/overlays/Makefile @@ -233,8 +233,8 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \ upstream-pi4.dtbo \ vc4-fkms-v3d.dtbo \ vc4-fkms-v3d-pi4.dtbo \ - vc4-kms-dpi-at056tn53v1.dtbo \ vc4-kms-dpi-generic.dtbo \ + vc4-kms-dpi-panel.dtbo \ vc4-kms-dsi-7inch.dtbo \ vc4-kms-dsi-lt070me05000.dtbo \ vc4-kms-dsi-lt070me05000-v2.dtbo \ diff --git a/arch/arm/boot/dts/overlays/README b/arch/arm/boot/dts/overlays/README index 7b7714be39e4..193fff85edfe 100644 --- a/arch/arm/boot/dts/overlays/README +++ b/arch/arm/boot/dts/overlays/README @@ -3607,10 +3607,8 @@ Params: cma-512 CMA is 512MB (needs 1GB) Name: vc4-kms-dpi-at056tn53v1 -Info: Enable an Innolux 5.6in VGA TFT connected to DPI interface under KMS. - Requires vc4-kms-v3d to be loaded. -Load: dtoverlay=vc4-kms-dpi-at056tn53v1 -Params: +Info: This overlay is now deprecated - see vc4-kms-dpi-panel,at056tn53v1 +Load: Name: vc4-kms-dpi-generic @@ -3660,6 +3658,33 @@ Params: clock-frequency Display clock frequency (Hz) (default 16). +Name: vc4-kms-dpi-panel +Info: Enable a preconfigured KMS DPI panel. + Requires vc4-kms-v3d to be loaded. +Load: dtoverlay=vc4-kms-dpi-panel,= +Params: at056tn53v1 Enable an Innolux 5.6in VGA TFT + kippah-7inch Enable an Adafruit Kippah with 7inch panel. + backlight-gpio Defines a GPIO to be used for backlight control + (default of none). + backlight-pwm Defines a PWM channel to be used for backlight + control (default of none). NB Disables audio + headphone output as that also uses PWM. + backlight-pwm-chan Choose channel on &pwm node for backlight + control. + (default 0). + backlight-pwm-gpio GPIO pin to be used for the PWM backlight. See + pwm-2chan for valid options. + (default 18 - note this can only work with + rgb666-padhi). + backlight-pwm-func Pin function of GPIO used for the PWM + backlight. + See pwm-2chan for valid options. + (default 2). + backlight-def-brightness + Set the default brightness. Normal range 1-16. + (default 16). + + Name: vc4-kms-dsi-7inch Info: Enable the Raspberry Pi DSI 7" screen. Includes the edt-ft5406 for the touchscreen element. diff --git a/arch/arm/boot/dts/overlays/overlay_map.dts b/arch/arm/boot/dts/overlays/overlay_map.dts index 9fd31bcd5569..0e01f46d8db0 100644 --- a/arch/arm/boot/dts/overlays/overlay_map.dts +++ b/arch/arm/boot/dts/overlays/overlay_map.dts @@ -151,6 +151,10 @@ bcm2711; }; + vc4-kms-dpi-at056tn53v1 { + deprecated = "use vc4-kms-dpi-panel,at056tn53v1"; + }; + vc4-kms-v3d { bcm2835; bcm2711 = "vc4-kms-v3d-pi4"; diff --git a/arch/arm/boot/dts/overlays/vc4-kms-dpi-at056tn53v1-overlay.dts b/arch/arm/boot/dts/overlays/vc4-kms-dpi-at056tn53v1-overlay.dts deleted file mode 100644 index f7181c9828bf..000000000000 --- a/arch/arm/boot/dts/overlays/vc4-kms-dpi-at056tn53v1-overlay.dts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * vc4-kms-dpi-at056tn53v1-overlay.dts - */ - -/dts-v1/; -/plugin/; - -#include -#include - -/ { - compatible = "brcm,bcm2835"; - - fragment@0 { - target-path = "/"; - __overlay__ { - panel: panel { - compatible = "innolux,at056tn53v1", "simple-panel"; - - port { - panel_in: endpoint { - remote-endpoint = <&dpi_out>; - }; - }; - }; - }; - }; - - fragment@1 { - target = <&dpi>; - __overlay__ { - status = "okay"; - - pinctrl-names = "default"; - pinctrl-0 = <&dpi_18bit_cpadhi_gpio0>; - - port { - dpi_out: endpoint { - remote-endpoint = <&panel_in>; - }; - }; - }; - }; -}; diff --git a/arch/arm/boot/dts/overlays/vc4-kms-dpi-generic-overlay.dts b/arch/arm/boot/dts/overlays/vc4-kms-dpi-generic-overlay.dts index 54bcd7d8505c..1e5c5080592b 100644 --- a/arch/arm/boot/dts/overlays/vc4-kms-dpi-generic-overlay.dts +++ b/arch/arm/boot/dts/overlays/vc4-kms-dpi-generic-overlay.dts @@ -5,124 +5,43 @@ /dts-v1/; /plugin/; -#include -#include +#include "vc4-kms-dpi.dtsi" / { compatible = "brcm,bcm2835"; fragment@0 { - target-path = "/"; - __overlay__ { - panel: panel { - compatible = "panel-dpi"; - - width-mm = <154>; - height-mm = <83>; - bus-format = <0x1009>; - - timing: panel-timing { - clock-frequency = <29500000>; - hactive = <800>; - hfront-porch = <24>; - hsync-len = <72>; - hback-porch = <96>; - hsync-active = <1>; - vactive = <480>; - vfront-porch = <3>; - vsync-len = <10>; - vback-porch = <7>; - vsync-active = <1>; - - de-active = <1>; - pixelclk-active = <1>; - }; - - port { - panel_in: endpoint { - remote-endpoint = <&dpi_out>; - }; - }; + target = <&panel>; + __overlay__ { + compatible = "panel-dpi"; + + width-mm = <154>; + height-mm = <83>; + bus-format = <0x1009>; + + timing: panel-timing { + clock-frequency = <29500000>; + hactive = <800>; + hfront-porch = <24>; + hsync-len = <72>; + hback-porch = <96>; + hsync-active = <1>; + vactive = <480>; + vfront-porch = <3>; + vsync-len = <10>; + vback-porch = <7>; + vsync-active = <1>; + + de-active = <1>; + pixelclk-active = <1>; }; }; }; fragment@1 { target = <&dpi>; - dpi_node: __overlay__ { - status = "okay"; - - pinctrl-names = "default"; + __overlay__ { pinctrl-0 = <&dpi_18bit_gpio0>; - - port { - dpi_out: endpoint { - remote-endpoint = <&panel_in>; - }; - }; - }; - }; - - fragment@2 { - target = <&panel>; - __dormant__ { - backlight = <&backlight>; - }; - }; - - fragment@3 { - target-path = "/"; - __dormant__ { - backlight: backlight { - compatible = "gpio-backlight"; - gpios = <&gpio 255 GPIO_ACTIVE_HIGH>; - }; - }; - }; - - fragment@4 { - target = <&panel>; - __dormant__ { - backlight = <&backlight_pwm>; - }; - }; - - fragment@5 { - target-path = "/"; - __dormant__ { - backlight_pwm: backlight_pwm { - compatible = "pwm-backlight"; - brightness-levels = <0 6 8 12 16 24 32 40 48 64 96 128 160 192 224 255>; - default-brightness-level = <16>; - pwms = <&pwm 0 200000>; - }; - }; - }; - - fragment@6 { - target = <&pwm>; - __dormant__ { - pinctrl-names = "default"; - pinctrl-0 = <&pwm_pins>; - assigned-clock-rates = <1000000>; - status = "okay"; - }; - }; - - fragment@7 { - target = <&gpio>; - __dormant__ { - pwm_pins: pwm_pins { - brcm,pins = <18>; - brcm,function = <2>; /* Alt5 */ - }; - }; - }; - - fragment@8 { - target = <&audio>; - __dormant__ { - brcm,disable-headphones; }; }; @@ -151,12 +70,5 @@ rgb888 = <&panel>, "bus-format:0=0x100a", <&dpi_node>, "pinctrl-0:0=",<&dpi_gpio0>; bus-format = <&panel>, "bus-format:0"; - backlight-gpio = <0>, "+2+3", - <&backlight>, "gpios:4"; - backlight-pwm = <0>, "+4+5+6+7+8"; - backlight-pwm-chan = <&backlight_pwm>, "pwms:4"; - backlight-pwm-gpio = <&pwm_pins>, "brcm,pins:0"; - backlight-pwm-func = <&pwm_pins>, "brcm,function:0"; - backlight-def-brightness = <&backlight_pwm>, "default-brightness-level:0"; }; }; diff --git a/arch/arm/boot/dts/overlays/vc4-kms-dpi-panel-overlay.dts b/arch/arm/boot/dts/overlays/vc4-kms-dpi-panel-overlay.dts new file mode 100644 index 000000000000..63b616f0345c --- /dev/null +++ b/arch/arm/boot/dts/overlays/vc4-kms-dpi-panel-overlay.dts @@ -0,0 +1,62 @@ +/* + * vc4-kms-dpi-panel-overlay.dts + * Support for any predefined DPI panel. + */ + +/dts-v1/; +/plugin/; + +#include "vc4-kms-dpi.dtsi" + +/ { + compatible = "brcm,bcm2835"; + + fragment@0 { + target = <&panel>; + __dormant__ { + compatible = "innolux,at056tn53v1", "simple-panel"; + }; + }; + fragment@1 { + target = <&panel>; + __dormant__ { + compatible = "ontat,yx700wv03", "simple-panel"; + }; + }; + + fragment@90 { + target = <&dpi>; + __dormant__ { + pinctrl-0 = <&dpi_18bit_cpadhi_gpio0>; + }; + }; + fragment@91 { + target = <&dpi>; + __dormant__ { + pinctrl-0 = <&dpi_18bit_gpio0>; + }; + }; + fragment@92 { + target = <&dpi>; + __dormant__ { + pinctrl-0 = <&dpi_gpio0>; + }; + }; + fragment@93 { + target = <&dpi>; + __dormant__ { + pinctrl-0 = <&dpi_16bit_cpadhi_gpio0>; + }; + }; + fragment@94 { + target = <&dpi>; + __dormant__ { + pinctrl-0 = <&dpi_16bit_gpio0>; + }; + }; + + __overrides__ { + at056tn53v1 = <0>, "+0+90"; + kippah-7inch = <0>, "+1+91"; + }; +}; diff --git a/arch/arm/boot/dts/overlays/vc4-kms-dpi.dtsi b/arch/arm/boot/dts/overlays/vc4-kms-dpi.dtsi new file mode 100644 index 000000000000..02d7f7fb109c --- /dev/null +++ b/arch/arm/boot/dts/overlays/vc4-kms-dpi.dtsi @@ -0,0 +1,109 @@ +/* + * vc4-kms-dpi.dtsi + */ + +#include +#include + +/ { + fragment@100 { + target-path = "/"; + __overlay__ { + panel: panel { + port { + panel_in: endpoint { + remote-endpoint = <&dpi_out>; + }; + }; + }; + }; + }; + + fragment@101 { + target = <&dpi>; + dpi_node: __overlay__ { + status = "okay"; + + pinctrl-names = "default"; + + port { + dpi_out: endpoint { + remote-endpoint = <&panel_in>; + }; + }; + }; + }; + + fragment@102 { + target = <&panel>; + __dormant__ { + backlight = <&backlight>; + }; + }; + + fragment@103 { + target-path = "/"; + __dormant__ { + backlight: backlight { + compatible = "gpio-backlight"; + gpios = <&gpio 255 GPIO_ACTIVE_HIGH>; + }; + }; + }; + + fragment@104 { + target = <&panel>; + __dormant__ { + backlight = <&backlight_pwm>; + }; + }; + + fragment@105 { + target-path = "/"; + __dormant__ { + backlight_pwm: backlight_pwm { + compatible = "pwm-backlight"; + brightness-levels = <0 6 8 12 16 24 32 40 48 64 96 128 160 192 224 255>; + default-brightness-level = <16>; + pwms = <&pwm 0 200000>; + }; + }; + }; + + fragment@106 { + target = <&pwm>; + __dormant__ { + pinctrl-names = "default"; + pinctrl-0 = <&pwm_pins>; + assigned-clock-rates = <1000000>; + status = "okay"; + }; + }; + + fragment@107 { + target = <&gpio>; + __dormant__ { + pwm_pins: pwm_pins { + brcm,pins = <18>; + brcm,function = <2>; /* Alt5 */ + }; + }; + }; + + fragment@108 { + target = <&audio>; + __dormant__ { + brcm,disable-headphones; + }; + }; + + __overrides__ { + backlight-gpio = <0>, "+102+103", + <&backlight>, "gpios:4"; + backlight-pwm = <0>, "+104+105+106+107+108"; + backlight-pwm-chan = <&backlight_pwm>, "pwms:4"; + backlight-pwm-gpio = <&pwm_pins>, "brcm,pins:0"; + backlight-pwm-func = <&pwm_pins>, "brcm,function:0"; + backlight-def-brightness = <&backlight_pwm>, "default-brightness-level:0"; + }; +}; diff --git a/arch/arm/boot/dts/overlays/vc4-kms-kippah-7inch-overlay.dts b/arch/arm/boot/dts/overlays/vc4-kms-kippah-7inch-overlay.dts index b03394844abd..4c1aa1c70158 100644 --- a/arch/arm/boot/dts/overlays/vc4-kms-kippah-7inch-overlay.dts +++ b/arch/arm/boot/dts/overlays/vc4-kms-kippah-7inch-overlay.dts @@ -1,43 +1,26 @@ /* - * vc4-kms-v3d-overlay.dts + * vc4-kms-kippah-7inch-overlay.dts */ /dts-v1/; /plugin/; -#include +#include "vc4-kms-dpi.dtsi" / { compatible = "brcm,bcm2835"; fragment@0 { - target-path = "/"; - __overlay__ { - panel: panel { - compatible = "ontat,yx700wv03", "simple-panel"; - - port { - panel_in: endpoint { - remote-endpoint = <&dpi_out>; - }; - }; - }; + target = <&panel>; + __overlay__ { + compatible = "ontat,yx700wv03", "simple-panel"; }; }; fragment@1 { target = <&dpi>; __overlay__ { - status = "okay"; - - pinctrl-names = "default"; pinctrl-0 = <&dpi_18bit_gpio0>; - - port { - dpi_out: endpoint@0 { - remote-endpoint = <&panel_in>; - }; - }; }; }; }; -- Gitee From 6420b47d0502fc7e8f66ffe2fcd07f70d7df2a5b Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Fri, 28 Jan 2022 17:37:43 -0600 Subject: [PATCH 15/32] media: uapi: Document format MEDIA_BUS_FMT_RGB565_1X24_CPADHI Add support for MEDIA_BUS_FMT_RGB565_1X24_CPADHI. This format is used by the Geekworm MZP280 panel which interfaces with the Raspberry Pi. Signed-off-by: Chris Morgan --- .../media/v4l/subdev-formats.rst | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/Documentation/userspace-api/media/v4l/subdev-formats.rst b/Documentation/userspace-api/media/v4l/subdev-formats.rst index 8e0ae032411a..a62c416f1408 100644 --- a/Documentation/userspace-api/media/v4l/subdev-formats.rst +++ b/Documentation/userspace-api/media/v4l/subdev-formats.rst @@ -620,6 +620,43 @@ The following tables list existing packed RGB formats. - b\ :sub:`2` - b\ :sub:`1` - b\ :sub:`0` + * .. _MEDIA_BUS_FMT_RGB565_1X24_CPADHI: + + - MEDIA_BUS_FMT_RGB565_1X24_CPADHI + - 0x1020 + - + - + - + - + - + - + - + - + - + - 0 + - 0 + - 0 + - r\ :sub:`4` + - r\ :sub:`3` + - r\ :sub:`2` + - r\ :sub:`1` + - r\ :sub:`0` + - 0 + - 0 + - g\ :sub:`5` + - g\ :sub:`4` + - g\ :sub:`3` + - g\ :sub:`2` + - g\ :sub:`1` + - g\ :sub:`0` + - 0 + - 0 + - 0 + - b\ :sub:`4` + - b\ :sub:`3` + - b\ :sub:`2` + - b\ :sub:`1` + - b\ :sub:`0` * .. _MEDIA-BUS-FMT-BGR565-2X8-BE: - MEDIA_BUS_FMT_BGR565_2X8_BE -- Gitee From 96518e34f92cea267f91108f4105f593120e8a5f Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Fri, 28 Jan 2022 17:38:40 -0600 Subject: [PATCH 16/32] media: uapi: add MEDIA_BUS_FMT_RGB565_1X24_CPADHI Add the MEDIA_BUS_FMT_RGB565_1X24_CPADHI format used by the Geekworm MZP280 panel for the Raspberry Pi. Signed-off-by: Chris Morgan --- include/uapi/linux/media-bus-format.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/media-bus-format.h b/include/uapi/linux/media-bus-format.h index c4abd49af073..33574f0fb793 100644 --- a/include/uapi/linux/media-bus-format.h +++ b/include/uapi/linux/media-bus-format.h @@ -34,13 +34,14 @@ #define MEDIA_BUS_FMT_FIXED 0x0001 -/* RGB - next is 0x1020 */ +/* RGB - next is 0x1021 */ #define MEDIA_BUS_FMT_RGB444_1X12 0x1016 #define MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE 0x1001 #define MEDIA_BUS_FMT_RGB444_2X8_PADHI_LE 0x1002 #define MEDIA_BUS_FMT_RGB555_2X8_PADHI_BE 0x1003 #define MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE 0x1004 #define MEDIA_BUS_FMT_RGB565_1X16 0x1017 +#define MEDIA_BUS_FMT_RGB565_1X24_CPADHI 0x1020 #define MEDIA_BUS_FMT_BGR565_2X8_BE 0x1005 #define MEDIA_BUS_FMT_BGR565_2X8_LE 0x1006 #define MEDIA_BUS_FMT_RGB565_2X8_BE 0x1007 -- Gitee From 0259d214daae2933d41425a5d2b70124f2dd712f Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Fri, 28 Jan 2022 17:39:54 -0600 Subject: [PATCH 17/32] drm/vc4: dpi: Support DPI interface in mode3 for RGB565 Add support for the VC4 DPI driver to utilize DPI mode 3. This is defined here as xxxRRRRRxxGGGGGGxxxBBBBB: https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#parallel-display-interface-dpi This mode is required to use the Geekworm MZP280 DPI display. Signed-off-by: Chris Morgan Reviewed-by: Dave Stevenson --- drivers/gpu/drm/vc4/vc4_dpi.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/vc4/vc4_dpi.c b/drivers/gpu/drm/vc4/vc4_dpi.c index 08147d0eab83..0d4fb6818d51 100644 --- a/drivers/gpu/drm/vc4/vc4_dpi.c +++ b/drivers/gpu/drm/vc4/vc4_dpi.c @@ -191,6 +191,10 @@ static void vc4_dpi_encoder_enable(struct drm_encoder *encoder) dpi_c |= VC4_SET_FIELD(DPI_FORMAT_16BIT_565_RGB_3, DPI_FORMAT); break; + case MEDIA_BUS_FMT_RGB565_1X24_CPADHI: + dpi_c |= VC4_SET_FIELD(DPI_FORMAT_16BIT_565_RGB_2, + DPI_FORMAT); + break; } } else { /* Default to 18bit if no connector found. */ -- Gitee From b8f54812c7c28bcbf5c5461c28f48778a5f936ce Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Fri, 28 Jan 2022 17:40:50 -0600 Subject: [PATCH 18/32] dt-bindings: vendor-prefixes: Add Geekworm Add vendor prefix for Geekworm (https://geekworm.com). Signed-off-by: Chris Morgan --- Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Documentation/devicetree/bindings/vendor-prefixes.yaml index 0d306469abd0..e8a98ec7632d 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.yaml +++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml @@ -401,6 +401,8 @@ patternProperties: description: General Electric Company "^geekbuying,.*": description: GeekBuying + "^geekworm,.*": + description: Geekworm "^gef,.*": description: GE Fanuc Intelligent Platforms Embedded Systems, Inc. "^GEFanuc,.*": -- Gitee From 832b4c6f97a82a55cea556ced556b5f26aa3656d Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Fri, 28 Jan 2022 17:41:18 -0600 Subject: [PATCH 19/32] dt-bindings: display: simple: add Geekworm MZP280 Panel The Geekworm MZP280 panel is a 480x640 (portrait) panel with a capacitive touch interface and a 40 pin header meant to interface directly with the Raspberry Pi. The screen is 2.8 inches diagonally, and there appear to be at least 4 distinct versions all with the same panel timings. Timings were derived from drivers posted on the github located here: https://github.com/tianyoujian/MZDPI/tree/master/vga Additional details about this panel family can be found here: https://wiki.geekworm.com/2.8_inch_Touch_Screen_for_Pi_zero Signed-off-by: Chris Morgan --- .../devicetree/bindings/display/panel/panel-simple.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/display/panel/panel-simple.yaml b/Documentation/devicetree/bindings/display/panel/panel-simple.yaml index 4d50b22554a4..f474cc0feed6 100644 --- a/Documentation/devicetree/bindings/display/panel/panel-simple.yaml +++ b/Documentation/devicetree/bindings/display/panel/panel-simple.yaml @@ -133,6 +133,8 @@ properties: - frida,frd350h54004 # FriendlyELEC HD702E 800x1280 LCD panel - friendlyarm,hd702e + # Geekworm MZP280 2.8" 480x640 LCD panel with capacitive touch + - geekworm,mzp280 # GiantPlus GPG48273QS5 4.3" (480x272) WQVGA TFT LCD panel - giantplus,gpg48273qs5 # GiantPlus GPM940B0 3.0" QVGA TFT LCD panel -- Gitee From a7895e54cfe2fbf10c2efa50aeea0275b452071c Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Fri, 28 Jan 2022 17:42:12 -0600 Subject: [PATCH 20/32] drm/panel: simple: add Geekworm MZP280 Panel Add support for the Geekworm MZP280 Panel Signed-off-by: Chris Morgan Acked-by: Maxime Ripard --- drivers/gpu/drm/panel/panel-simple.c | 29 ++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c index e99168cc2ae4..c1d6052f2ace 100644 --- a/drivers/gpu/drm/panel/panel-simple.c +++ b/drivers/gpu/drm/panel/panel-simple.c @@ -1943,6 +1943,32 @@ static const struct panel_desc friendlyarm_hd702e = { }, }; +static const struct drm_display_mode geekworm_mzp280_mode = { + .clock = 32000, + .hdisplay = 480, + .hsync_start = 480 + 41, + .hsync_end = 480 + 41 + 20, + .htotal = 480 + 41 + 20 + 60, + .vdisplay = 640, + .vsync_start = 640 + 5, + .vsync_end = 640 + 5 + 10, + .vtotal = 640 + 5 + 10 + 10, + .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC, +}; + +static const struct panel_desc geekworm_mzp280 = { + .modes = &geekworm_mzp280_mode, + .num_modes = 1, + .bpc = 6, + .size = { + .width = 47, + .height = 61, + }, + .bus_format = MEDIA_BUS_FMT_RGB565_1X24_CPADHI, + .bus_flags = DRM_BUS_FLAG_DE_HIGH | DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE, + .connector_type = DRM_MODE_CONNECTOR_DPI, +}; + static const struct drm_display_mode giantplus_gpg482739qs5_mode = { .clock = 9000, .hdisplay = 480, @@ -4118,6 +4144,9 @@ static const struct of_device_id platform_of_match[] = { }, { .compatible = "friendlyarm,hd702e", .data = &friendlyarm_hd702e, + }, { + .compatible = "geekworm,mzp280", + .data = &geekworm_mzp280, }, { .compatible = "giantplus,gpg482739qs5", .data = &giantplus_gpg482739qs5 -- Gitee From 481580ca340028f502f1ebe7abb8f6f8439b966b Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Wed, 2 Feb 2022 09:11:20 +0000 Subject: [PATCH 21/32] overlays: README: Deprecate vc4-kms-kippah-7inch The vc4-kms-kippah-7inch overlay has been replaced by the container overlay vc4-kms-dpi-panel, using the "kippah-7inch" parameter. The original overlay has been retained for now to avoid breaking existing installations, but that doesn't make it any less deprecated, so update the README accordingly. Signed-off-by: Phil Elwell --- arch/arm/boot/dts/overlays/README | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/arch/arm/boot/dts/overlays/README b/arch/arm/boot/dts/overlays/README index 193fff85edfe..6a8d5c5f82c9 100644 --- a/arch/arm/boot/dts/overlays/README +++ b/arch/arm/boot/dts/overlays/README @@ -3720,10 +3720,8 @@ Params: Name: vc4-kms-kippah-7inch -Info: Enable the Adafruit DPI Kippah with the 7" Ontat panel attached. - Requires vc4-kms-v3d to be loaded. -Load: dtoverlay=vc4-kms-kippah-7inch -Params: +Info: This overlay is now deprecated - see vc4-kms-dpi-panel,kippah-7inch +Load: Name: vc4-kms-v3d -- Gitee From 730f9bfee81a81cc850ff13b5e543405bc9a669a Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Tue, 1 Feb 2022 12:20:20 +0000 Subject: [PATCH 22/32] drm/panel: Add and initialise an orientation field to drm_panel Current usage of drm_connector_set_panel_orientation is from a panel's get_modes call. However if the panel orientation property doesn't exist on the connector at this point, then drm_mode_object triggers WARNs as the connector is already registered. Add an orientation variable to struct drm_panel and initialise it from drm_panel_init. panel_bridge_attach can then create the property before the connector is registered. Signed-off-by: Dave Stevenson --- drivers/gpu/drm/bridge/panel.c | 4 ++++ drivers/gpu/drm/drm_panel.c | 15 ++++++++++----- include/drm/drm_panel.h | 8 ++++++++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/bridge/panel.c b/drivers/gpu/drm/bridge/panel.c index c916f4b8907e..a63d6d238e3c 100644 --- a/drivers/gpu/drm/bridge/panel.c +++ b/drivers/gpu/drm/bridge/panel.c @@ -79,6 +79,10 @@ static int panel_bridge_attach(struct drm_bridge *bridge, return ret; } + /* set up connector's "panel orientation" property */ + drm_connector_set_panel_orientation(&panel_bridge->connector, + panel_bridge->panel->orientation); + drm_connector_attach_encoder(&panel_bridge->connector, bridge->encoder); diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c index f634371c717a..bee5066e9227 100644 --- a/drivers/gpu/drm/drm_panel.c +++ b/drivers/gpu/drm/drm_panel.c @@ -61,6 +61,9 @@ void drm_panel_init(struct drm_panel *panel, struct device *dev, panel->dev = dev; panel->funcs = funcs; panel->connector_type = connector_type; + + panel->orientation = DRM_MODE_PANEL_ORIENTATION_UNKNOWN; + of_drm_get_panel_orientation(dev->of_node, &panel->orientation); } EXPORT_SYMBOL(drm_panel_init); @@ -289,16 +292,18 @@ int of_drm_get_panel_orientation(const struct device_node *np, if (ret < 0) return ret; - if (rotation == 0) + if (rotation == 0) { *orientation = DRM_MODE_PANEL_ORIENTATION_NORMAL; - else if (rotation == 90) + } else if (rotation == 90) { *orientation = DRM_MODE_PANEL_ORIENTATION_RIGHT_UP; - else if (rotation == 180) + } else if (rotation == 180) { *orientation = DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP; - else if (rotation == 270) + } else if (rotation == 270) { *orientation = DRM_MODE_PANEL_ORIENTATION_LEFT_UP; - else + } else { + DRM_ERROR("%pOF: invalid orientation %d\n", np, ret); return -EINVAL; + } return 0; } diff --git a/include/drm/drm_panel.h b/include/drm/drm_panel.h index 33605c3f0eba..878256905791 100644 --- a/include/drm/drm_panel.h +++ b/include/drm/drm_panel.h @@ -165,6 +165,14 @@ struct drm_panel { */ int connector_type; + /** + * @orientation: + * + * Panel orientation at initialisation. This is used to initialise the + * drm_connector property for panel orientation. + */ + enum drm_panel_orientation orientation; + /** * @list: * -- Gitee From 8f60225c76b308064f480888cfea7d2af6b007f9 Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Tue, 1 Feb 2022 12:24:51 +0000 Subject: [PATCH 23/32] drm/panel: simple: Remove custom handling of orientation Panel orientation is now handled by the drm_panel and panel_bridge frameworks, so remove the custom handling. Signed-off-by: Dave Stevenson --- drivers/gpu/drm/panel/panel-simple.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c index c1d6052f2ace..08d26e81cbfb 100644 --- a/drivers/gpu/drm/panel/panel-simple.c +++ b/drivers/gpu/drm/panel/panel-simple.c @@ -112,8 +112,6 @@ struct panel_simple { struct gpio_desc *hpd_gpio; struct drm_display_mode override_mode; - - enum drm_panel_orientation orientation; }; static inline struct panel_simple *to_panel_simple(struct drm_panel *panel) @@ -373,9 +371,6 @@ static int panel_simple_get_modes(struct drm_panel *panel, /* add hard-coded panel modes */ num += panel_simple_get_non_edid_modes(p, connector); - /* set up connector's "panel orientation" property */ - drm_connector_set_panel_orientation(connector, p->orientation); - return num; } @@ -540,12 +535,6 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc) return err; } - err = of_drm_get_panel_orientation(dev->of_node, &panel->orientation); - if (err) { - dev_err(dev, "%pOF: failed to get orientation %d\n", dev->of_node, err); - return err; - } - ddc = of_parse_phandle(dev->of_node, "ddc-i2c-bus", 0); if (ddc) { panel->ddc = of_find_i2c_adapter_by_node(ddc); -- Gitee From b382be4408e2dc53686e282ec29c20d8e07b6156 Mon Sep 17 00:00:00 2001 From: Joakim Tjernlund Date: Fri, 28 May 2021 17:26:45 +0200 Subject: [PATCH 24/32] Bluetooth: btusb: Add 0x0b05:0x190e Realtek 8761BU (ASUS BT500) device. commit 33404381c5e875cbd57eec6d9bbacd3b13b404c9 upstream. T: Bus=01 Lev=01 Prnt=01 Port=08 Cnt=04 Dev#= 18 Spd=12 MxCh= 0 D: Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=0b05 ProdID=190e Rev= 2.00 S: Manufacturer=Realtek S: Product=ASUS USB-BT500 S: SerialNumber=xxxxxxxx C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=500mA I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=81(I) Atr=03(Int.) MxPS= 16 Ivl=1ms E: Ad=02(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 0 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 0 Ivl=1ms I: If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 9 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 9 Ivl=1ms I: If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 17 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 17 Ivl=1ms I: If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 25 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 25 Ivl=1ms I: If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 33 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 33 Ivl=1ms I: If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 49 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 49 Ivl=1ms Signed-off-by: Joakim Tjernlund Signed-off-by: Marcel Holtmann --- drivers/bluetooth/btusb.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index e0859f4e2807..ab9aed928507 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -419,6 +419,10 @@ static const struct usb_device_id blacklist_table[] = { { USB_DEVICE(0x0bda, 0xb009), .driver_info = BTUSB_REALTEK }, { USB_DEVICE(0x2ff8, 0xb011), .driver_info = BTUSB_REALTEK }, + /* Additional Realtek 8761BU Bluetooth devices */ + { USB_DEVICE(0x0b05, 0x190e), .driver_info = BTUSB_REALTEK | + BTUSB_WIDEBAND_SPEECH }, + /* Additional Realtek 8821AE Bluetooth devices */ { USB_DEVICE(0x0b05, 0x17dc), .driver_info = BTUSB_REALTEK }, { USB_DEVICE(0x13d3, 0x3414), .driver_info = BTUSB_REALTEK }, -- Gitee From a94a9a6ae88694b3e26072841eb11e9c229c920d Mon Sep 17 00:00:00 2001 From: Nicholas Flintham Date: Thu, 30 Sep 2021 09:22:39 +0100 Subject: [PATCH 25/32] Bluetooth: btusb: Add support for TP-Link UB500 Adapter commit 4fd6d490796171bf786090fee782e252186632e4 upstream. Add support for TP-Link UB500 Adapter (RTL8761B) * /sys/kernel/debug/usb/devices T: Bus=01 Lev=02 Prnt=05 Port=01 Cnt=01 Dev#= 78 Spd=12 MxCh= 0 D: Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=2357 ProdID=0604 Rev= 2.00 S: Manufacturer= S: Product=TP-Link UB500 Adapter S: SerialNumber=E848B8C82000 C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=500mA I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=81(I) Atr=03(Int.) MxPS= 16 Ivl=1ms E: Ad=02(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 0 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 0 Ivl=1ms I: If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 9 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 9 Ivl=1ms I: If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 17 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 17 Ivl=1ms I: If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 25 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 25 Ivl=1ms I: If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 33 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 33 Ivl=1ms I: If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 49 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 49 Ivl=1ms Signed-off-by: Nicholas Flintham Signed-off-by: Marcel Holtmann --- drivers/bluetooth/btusb.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index ab9aed928507..7fda81dac4f9 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -419,6 +419,10 @@ static const struct usb_device_id blacklist_table[] = { { USB_DEVICE(0x0bda, 0xb009), .driver_info = BTUSB_REALTEK }, { USB_DEVICE(0x2ff8, 0xb011), .driver_info = BTUSB_REALTEK }, + /* Additional Realtek 8761B Bluetooth devices */ + { USB_DEVICE(0x2357, 0x0604), .driver_info = BTUSB_REALTEK | + BTUSB_WIDEBAND_SPEECH }, + /* Additional Realtek 8761BU Bluetooth devices */ { USB_DEVICE(0x0b05, 0x190e), .driver_info = BTUSB_REALTEK | BTUSB_WIDEBAND_SPEECH }, -- Gitee From 726b62a786bc66fdba3aa86e4551a94f3e3c87f6 Mon Sep 17 00:00:00 2001 From: Nicolai Buchwitz Date: Wed, 2 Feb 2022 16:18:52 +0100 Subject: [PATCH 26/32] keep disabled node hdmi1 in devicetree The second hdmi port on cm4s is disabled by default (default from bcm2711-rpi.dtsi) and therefore it is not necessary to remove it in the specific cm4s overlay (as done in 64328ab674dc3e3f0356d066916546f6b2876257) --- arch/arm/boot/dts/bcm2711-rpi-cm4s.dts | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/arm/boot/dts/bcm2711-rpi-cm4s.dts b/arch/arm/boot/dts/bcm2711-rpi-cm4s.dts index c0808eca28b3..cefef46bd866 100644 --- a/arch/arm/boot/dts/bcm2711-rpi-cm4s.dts +++ b/arch/arm/boot/dts/bcm2711-rpi-cm4s.dts @@ -206,8 +206,6 @@ #include "bcm283x-rpi-csi1-4lane.dtsi" #include "bcm283x-rpi-i2c0mux_0_28.dtsi" -/delete-node/ &hdmi1; - / { chosen { bootargs = "coherent_pool=1M 8250.nr_uarts=1 snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1"; -- Gitee From 5040352326250133496b533a17832485298fe28f Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Wed, 2 Feb 2022 10:42:00 -0600 Subject: [PATCH 27/32] overlays: Add rotate property to vc4-kms-dpi-panel Allow a user to specify the panel rotation in devicetree as 0, 90, 180, or 270 by setting a parameter. Signed-off-by: Chris Morgan --- arch/arm/boot/dts/overlays/README | 2 ++ arch/arm/boot/dts/overlays/vc4-kms-dpi.dtsi | 2 ++ 2 files changed, 4 insertions(+) diff --git a/arch/arm/boot/dts/overlays/README b/arch/arm/boot/dts/overlays/README index 6a8d5c5f82c9..69cb31788b1a 100644 --- a/arch/arm/boot/dts/overlays/README +++ b/arch/arm/boot/dts/overlays/README @@ -3656,6 +3656,7 @@ Params: clock-frequency Display clock frequency (Hz) backlight-def-brightness Set the default brightness. Normal range 1-16. (default 16). + rotate Display rotation {0,90,180,270} (default 0) Name: vc4-kms-dpi-panel @@ -3683,6 +3684,7 @@ Params: at056tn53v1 Enable an Innolux 5.6in VGA TFT backlight-def-brightness Set the default brightness. Normal range 1-16. (default 16). + rotate Display rotation {0,90,180,270} (default 0) Name: vc4-kms-dsi-7inch diff --git a/arch/arm/boot/dts/overlays/vc4-kms-dpi.dtsi b/arch/arm/boot/dts/overlays/vc4-kms-dpi.dtsi index 02d7f7fb109c..f78fa48b19f9 100644 --- a/arch/arm/boot/dts/overlays/vc4-kms-dpi.dtsi +++ b/arch/arm/boot/dts/overlays/vc4-kms-dpi.dtsi @@ -10,6 +10,7 @@ target-path = "/"; __overlay__ { panel: panel { + rotation = <0>; port { panel_in: endpoint { remote-endpoint = <&dpi_out>; @@ -105,5 +106,6 @@ backlight-pwm-gpio = <&pwm_pins>, "brcm,pins:0"; backlight-pwm-func = <&pwm_pins>, "brcm,function:0"; backlight-def-brightness = <&backlight_pwm>, "default-brightness-level:0"; + rotate = <&panel>, "rotation:0"; }; }; -- Gitee From f8037e205537bf509dd07d928e6dfbeac99bcb84 Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Wed, 2 Feb 2022 10:43:32 -0600 Subject: [PATCH 28/32] overlays: Add Geekworm mzp280 to vc4-kms-dpi-panel Add support for the Geekworm mzp280 DPI panel to the generic vc4-kms-dpi-panel overlay. Signed-off-by: Chris Morgan --- arch/arm/boot/dts/overlays/README | 1 + arch/arm/boot/dts/overlays/vc4-kms-dpi-panel-overlay.dts | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/arch/arm/boot/dts/overlays/README b/arch/arm/boot/dts/overlays/README index 69cb31788b1a..3a0961540427 100644 --- a/arch/arm/boot/dts/overlays/README +++ b/arch/arm/boot/dts/overlays/README @@ -3665,6 +3665,7 @@ Info: Enable a preconfigured KMS DPI panel. Load: dtoverlay=vc4-kms-dpi-panel,= Params: at056tn53v1 Enable an Innolux 5.6in VGA TFT kippah-7inch Enable an Adafruit Kippah with 7inch panel. + mzp280 Enable a Geekworm MZP280 panel. backlight-gpio Defines a GPIO to be used for backlight control (default of none). backlight-pwm Defines a PWM channel to be used for backlight diff --git a/arch/arm/boot/dts/overlays/vc4-kms-dpi-panel-overlay.dts b/arch/arm/boot/dts/overlays/vc4-kms-dpi-panel-overlay.dts index 63b616f0345c..ee9e2e8fd246 100644 --- a/arch/arm/boot/dts/overlays/vc4-kms-dpi-panel-overlay.dts +++ b/arch/arm/boot/dts/overlays/vc4-kms-dpi-panel-overlay.dts @@ -23,6 +23,12 @@ compatible = "ontat,yx700wv03", "simple-panel"; }; }; + fragment@2 { + target = <&panel>; + __dormant__ { + compatible = "geekworm,mzp280", "simple-panel"; + }; + }; fragment@90 { target = <&dpi>; @@ -58,5 +64,6 @@ __overrides__ { at056tn53v1 = <0>, "+0+90"; kippah-7inch = <0>, "+1+91"; + mzp280 = <0>, "+2+93"; }; }; -- Gitee From 532ea035e7bd40a4b8c6ff87469944c737f6496e Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Thu, 3 Feb 2022 11:17:16 +0000 Subject: [PATCH 29/32] dtoverlay: Reduce size of PCIE IB window in pcie-32-dma overlay The PCIE inbound window is rounded up to a power of 2, so the default of 3GB rounds up to 4GB starting at 0. This prohibits the MSI vector sitting at 0x0_fffffffc, and causes warnings from some subsystems (eg ahci) of a 64bit address on a 32bit configuration. Reduce the window down to 2GB to avoid this issue. https://github.com/raspberrypi/linux/issues/4848 Signed-off-by: Dave Stevenson --- .../dts/overlays/pcie-32bit-dma-overlay.dts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/arch/arm/boot/dts/overlays/pcie-32bit-dma-overlay.dts b/arch/arm/boot/dts/overlays/pcie-32bit-dma-overlay.dts index cca3e83721b7..e01c9ceeab08 100644 --- a/arch/arm/boot/dts/overlays/pcie-32bit-dma-overlay.dts +++ b/arch/arm/boot/dts/overlays/pcie-32bit-dma-overlay.dts @@ -11,8 +11,26 @@ fragment@0 { target-path = "/aliases"; __overlay__ { + /* + * Removing this alias stops the firmware patching the + * PCIE DT dma-ranges based on the detected chip + * revision. + */ pcie0 = ""; }; }; + fragment@1 { + target = <&pcie0>; + __overlay__ { + /* + * The size of the range is rounded up to a power of 2, + * so the range ends up being 0-4GB, and the MSI vector + * gets pushed beyond 4GB. + */ + dma-ranges = <0x02000000 0x0 0x00000000 0x0 0x00000000 + 0x0 0x80000000>; + }; + }; + }; -- Gitee From 1c51ef9acdef97b6d917a5664bb6611797d44d2b Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Wed, 2 Feb 2022 17:47:54 +0000 Subject: [PATCH 30/32] ARM: dts: Permanently disable hdmi1 and ddc1 on CM4S CM4S has no HDMI1 output, so it is advisable to disable the controller and its I2C interface in software. This is ordinarily done by setting their status properties to "disabled", but the vc4-kms-v3d(-pi4) overlay enables both HDMIs and DDCs as part of the transfer of control from the VPU. Knobble the CM4S dts in such a way that the overlay applies successfully but the hdmi1 and ddc1 nodes remain disabled by changing the compatible string to something unrecognised. See: https://github.com/raspberrypi/linux/issues/4857 Signed-off-by: Phil Elwell --- arch/arm/boot/dts/bcm2711-rpi-cm4s.dts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/arm/boot/dts/bcm2711-rpi-cm4s.dts b/arch/arm/boot/dts/bcm2711-rpi-cm4s.dts index cefef46bd866..f90785abc92f 100644 --- a/arch/arm/boot/dts/bcm2711-rpi-cm4s.dts +++ b/arch/arm/boot/dts/bcm2711-rpi-cm4s.dts @@ -416,6 +416,16 @@ }; }; +/* Permanently disable HDMI1 */ +&hdmi1 { + compatible = "disabled"; +}; + +/* Permanently disable DDC1 */ +&ddc1 { + compatible = "disabled"; +}; + &leds { act_led: led-act { label = "led0"; -- Gitee From 75ab180d3045729adb40a079cc5841d13d5cf21a Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Thu, 3 Feb 2022 12:16:45 +0000 Subject: [PATCH 31/32] dtoverlays: Correct field sizes in pcie-32bit-dma Adding the dma-ranges to the overlay missed setting the field sizes, so the compiler rightly flagged a warning. https://github.com/raspberrypi/linux/issues/4848 Fixes: ee6a81c85402 "dtoverlay: Reduce size of PCIE IB window in pcie-32-dma overlay" Signed-off-by: Dave Stevenson --- arch/arm/boot/dts/overlays/pcie-32bit-dma-overlay.dts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/boot/dts/overlays/pcie-32bit-dma-overlay.dts b/arch/arm/boot/dts/overlays/pcie-32bit-dma-overlay.dts index e01c9ceeab08..955703563df7 100644 --- a/arch/arm/boot/dts/overlays/pcie-32bit-dma-overlay.dts +++ b/arch/arm/boot/dts/overlays/pcie-32bit-dma-overlay.dts @@ -28,6 +28,8 @@ * so the range ends up being 0-4GB, and the MSI vector * gets pushed beyond 4GB. */ + #address-cells = <3>; + #size-cells = <2>; dma-ranges = <0x02000000 0x0 0x00000000 0x0 0x00000000 0x0 0x80000000>; }; -- Gitee From e3d8fe5723b7e0a8c59d2710c0524bcde63f9fd0 Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Thu, 3 Feb 2022 15:51:41 +0000 Subject: [PATCH 32/32] net: phy: lan87xx: Decrease phy polling rate Polling at 100Hz for 1.5s consumes quite a bit of kworker time with no obvious benefit. Reduce that polling rate to ~6Hz. To further save CPU and power, defer the next poll if no energy is detected. See: https://github.com/raspberrypi/linux/issues/4780 Signed-off-by: Phil Elwell --- drivers/net/phy/smsc.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c index 9983eeded624..65ccc94a9282 100644 --- a/drivers/net/phy/smsc.c +++ b/drivers/net/phy/smsc.c @@ -185,6 +185,8 @@ static int lan87xx_read_status(struct phy_device *phydev) int err = genphy_read_status(phydev); if (!phydev->link && priv->energy_enable) { + int energy_detected; + /* Disable EDPD to wake up PHY */ int rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS); if (rc < 0) @@ -200,7 +202,7 @@ static int lan87xx_read_status(struct phy_device *phydev) */ read_poll_timeout(phy_read, rc, rc & MII_LAN83C185_ENERGYON || rc < 0, - 10000, 1500000, true, phydev, + 150000, 1500000, true, phydev, MII_LAN83C185_CTRL_STATUS); if (rc < 0) return rc; @@ -210,10 +212,16 @@ static int lan87xx_read_status(struct phy_device *phydev) if (rc < 0) return rc; + energy_detected = !!(rc & MII_LAN83C185_ENERGYON); + rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS, rc | MII_LAN83C185_EDPWRDOWN); if (rc < 0) return rc; + + /* Save CPU and power by deferring the next poll */ + if (!energy_detected) + msleep(2000); } return err; -- Gitee