eDP: Support probing eDP panels dynamically instead of hardcoding
Subsystems (17)
Douglas Anderson
reviewerv4 cover eDP: Support probing eDP panels dynamically instead of hardcoding
The goal of this patch series is to move away from hardcoding exact eDP panels in device tree files. As discussed in the various patches in this series (I'm not repeating everything here), most eDP panels are 99% probable and we can get that last 1% by allowing two "power up" delays to be specified in the device tree file and then using the panel ID (found in the EDID) to look up additional power sequencing delays for the panel.
This patch series is the logical contiunation of a previous patch series where I proposed solving this problem by adding a board-specific compatible string [1]. In the discussion that followed it sounded like people were open to something like the solution proposed in this new series.
In version 2 I got rid of the idea that we could have a "fallback" compatible string that we'd use if we didn't recognize the ID in the EDID. This simplifies the bindings a lot and the implementation somewhat. As a result of not having a "fallback", though, I'm not confident in transitioning any existing boards over to this since we'll have to fallback to very conservative timings if we don't recognize the ID from the EDID and I can't guarantee that I've seen every panel that might have shipped on an existing product. The plan is to use "edp-panel" only on new boards or new revisions of old boards where we can guarantee that every EDID that ships out of the factory has an ID in the table.
Version 3 of this series now splits out all eDP panels to their own driver and adds the generic eDP panel support to this new driver. I believe this is what Sam was looking for [2].
Version 4 of this series is mostly small fixes / renames from review feedback. It's largely the same as v3. Other than naming / description / comment changes, the differences are:
- Dropped the MIPS config patch as per request.
- Reorder config patches first.
- Added a new patch to use the panel ID scheme for quirks.
- Landed the reorder of logicpd_type_28 / mitsubishi_aa070mc01 It could possibly be ready to land?
[1] https://lore.kernel.org/r/[email protected]/
[2] https://lore.kernel.org/r/YRTsFNTn%[email protected]/
Changes in v4:
- "u8 *edid" => "void *edid" to avoid cast.
- ("Use new encoded panel id style for quirks matching") new for v4.
- Don't put kmalloc() in the "if" test even if the old code did.
- Don't refer to "panel-simple" in commit message.
- PANEL_SIMPLE_EDP => PANEL_EDP
- Remove "non-eDP" in panel-simple description.
- Reordered config patches to be before code patch
- decode_edid_id() => drm_edid_decode_panel_id()
- drm_do_get_edid_blk0() => drm_do_get_edid_base_block()
- drm_get_panel_id() => drm_edid_get_panel_id()
- encode_edid_id() => drm_edid_encode_panel_id()
- panel-simple-edp => panel-edp
- split panel id extraction out to its own function.
Changes in v3:
- ("Better describe eDP panel delays") new for v3.
- ("Don't re-read the EDID every time") moved to eDP only patch.
- ("Non-eDP panels don't need "HPD" handling") new for v3.
- Add AUO B116XAN06.1 to table.
- Add Sharp LQ116M1JW10 to table.
- Adjust endianness of product ID.
- Change init order to we power at the end.
- Decode hex product ID w/ same endianness as everyone else.
- Fallback to conservative delays if panel not recognized.
- Fix "prepare_to_enable" patch new for v3.
- Generic "edp-panel" handled by the eDP panel driver now.
- Move wayward panels patch new for v3.
- Rename delays more generically so they can be reused.
- Split eDP panels patch new for v3.
- Split the delay structure out patch just on eDP now.
Changes in v2:
- Add "-ms" suffix to delays.
- Don't support a "fallback" panel. Probed panels must be probed.
- No longer allow fallback to panel-simple.
- Not based on patch to copy "desc"--just allocate for probed panels.
Douglas Anderson (15):
dt-bindings: drm/panel-simple-edp: Introduce generic eDP panels drm/edid: Break out reading block 0 of the EDID drm/edid: Allow querying/working with the panel ID from the EDID drm/edid: Use new encoded panel id style for quirks matching
ARM: configs: Everyone who had PANEL_SIMPLE now gets PANEL_EDP
arm64: defconfig: Everyone who had PANEL_SIMPLE now gets PANEL_EDP drm/panel-edp: Split eDP panels out of panel-simple drm/panel-edp: Move some wayward panels to the eDP driver drm/panel-simple: Non-eDP panels don't need "HPD" handling drm/panel-edp: Split the delay structure out drm/panel-edp: Better describe eDP panel delays drm/panel-edp: hpd_reliable shouldn't be subtraced from hpd_absent drm/panel-edp: Fix "prepare_to_enable" if panel doesn't handle HPD drm/panel-edp: Don't re-read the EDID every time we power off the
panel
drm/panel-edp: Implement generic "edp-panel"s probed by EDID
.../bindings/display/panel/panel-edp.yaml | 188 ++ arch/arm/configs/at91_dt_defconfig | 1 + arch/arm/configs/exynos_defconfig | 1 + arch/arm/configs/imx_v6_v7_defconfig | 1 + arch/arm/configs/lpc32xx_defconfig | 1 + arch/arm/configs/multi_v5_defconfig | 1 + arch/arm/configs/multi_v7_defconfig | 1 + arch/arm/configs/omap2plus_defconfig | 1 + arch/arm/configs/qcom_defconfig | 1 + arch/arm/configs/realview_defconfig | 1 + arch/arm/configs/sama5_defconfig | 1 + arch/arm/configs/shmobile_defconfig | 1 + arch/arm/configs/sunxi_defconfig | 1 + arch/arm/configs/tegra_defconfig | 1 + arch/arm/configs/versatile_defconfig | 1 + arch/arm/configs/vexpress_defconfig | 1 + arch/arm64/configs/defconfig | 1 + drivers/gpu/drm/drm_edid.c | 281 ++- drivers/gpu/drm/panel/Kconfig | 16 +- drivers/gpu/drm/panel/Makefile | 1 + drivers/gpu/drm/panel/panel-edp.c | 1896 +++++++++++++++++ drivers/gpu/drm/panel/panel-simple.c | 1072 +--------- include/drm/drm_edid.h | 47 + 23 files changed, 2355 insertions(+), 1162 deletions(-) create mode 100644 Documentation/devicetree/bindings/display/panel/panel-edp.yaml create mode 100644 drivers/gpu/drm/panel/panel-edp.c
Signature · 1 line
2.33.0.309.g3052b89438-goog
Douglas Anderson
reviewerPATCH v4 1/15 dt-bindings: drm/panel-simple-edp: Introduce generic eDP panels
eDP panels generally contain almost everything needed to control them in their EDID. This comes from their DP heritage were a computer needs to be able to properly control pretty much any DP display that's plugged into it.
The one big issue with eDP panels and the reason that we need a panel driver for them is that the power sequencing can be different per panel.
While it is true that eDP panel sequencing can be arbitrarily complex, in practice it turns out that many eDP panels are compatible with just some slightly different delays. See the contents of the bindings file introduced in this patch for some details.
The fact that eDP panels are 99% probable and that the power sequencing (especially power up) can be compatible between many panels means that there's a constant desire to plug multiple different panels into the same board. This could be for second sourcing purposes or to support multiple SKUs (maybe a 11" and a 13", for instance).
As discussed [1], it should be OK to support this by adding two properties to the device tree to specify the delays needed for powering up the panel the first time. We'll create a new "edp-panel" bindings file and define the two delays that might need to be specified. NOTE: in the vast majority of the cases (HPD is hooked up and isn't glitchy or is debounced) even these delays aren't needed.
[1] https://lore.kernel.org/r/CAD=FV=VZYOMPwQZzWdhJGh5cjJWw_EcM-wQVEivZ-bdGXjPrEQ@mail.gmail.com
---
(no changes since v2)
Changes in v2:
- Add "-ms" suffix to delays.
- No longer allow fallback to panel-simple.
.../bindings/display/panel/panel-edp.yaml | 188 ++++++++++++++++++ 1 file changed, 188 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/panel/panel-edp.yaml
Documentation/devicetree/bindings/display/panel/panel-edp.yaml new file +188 -0
@@ -0,0 +1,188 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/panel/panel-edp.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Probable (via DP AUX / EDID) eDP Panels with simple poweron sequences + +maintainers: + - Douglas Anderson <[email protected]> + +description: | + This binding file can be used to indicate that an eDP panel is connected + to a Embedded DisplayPort AUX bus (see display/dp-aux-bus.yaml) without + actually specifying exactly what panel is connected. This is useful for + the case that more than one different panel could be connected to the + board, either for second-sourcing purposes or to support multiple SKUs + with different LCDs that hook up to a common board. + + As per above, a requirement for using this binding is that the panel is + represented under the DP AUX bus. This means that we can use any + information provided by the DP AUX bus (including the EDID) to identify + the panel. We can use this to identify display size, resolution, and + timings among other things. + + One piece of information about eDP panels that is typically _not_ + provided anywhere on the DP AUX bus is the power sequencing timings. + This is the reason why, historically, we've always had to explicitly + list eDP panels. We solve that here with two tricks. The "worst case" + power on timings for any panels expected to be connected to a board are + specified in these bindings. Once we've powered on, it's expected that + the operating system will lookup the panel in a table (based on EDID + information) to figure out other power sequencing timings. + + eDP panels in general can have somewhat arbitrary power sequencing + requirements. However, even though it's arbitrary in general, the + vast majority of panel datasheets have a power sequence diagram that + looks the exactly the same as every other panel. Each panel datasheet + cares about different timings in this diagram but the fact that the + diagram is so similar means we can come up with a single driver to + handle it. + + These diagrams all look roughly like this, sometimes labeled with + slightly different numbers / lines but all pretty much the same + sequence. This is because much of this diagram comes straight from + the eDP Standard. + + __________________________________________________ + Vdd ___/: :\____ / + _/ : : \_____/ + :<T1>:<T2>: :<--T10-->:<T11>:<T12>: + : +-----------------------+---------+---------+ + eDP -----------+ Black video | Src vid | Blk vid + + Display : +-----------------------+---------+---------+ + : _______________________:_________:_________: + HPD :<T3>| : : | + ___________| : : |_____________ + : : : : + Sink +-----------------------:---------:---------+ + AUX CH -----------+ AUX Ch operational : : +------------- + +-----------------------:---------:---------+ + : : : : + :<T4>: :<T7>: : : + Src main +------+------+--------------+---------+ + lnk data----------------+LnkTrn| Idle |Valid vid data| Idle/off+------------- + +------+------+--------------+---------+ + : <T5> :<-T6->:<-T8->: : + :__:<T9>: + LED_EN | | + _____________________________________| |____________________________ + : : + __________:__:_ + PWM | : : | + __________________________| : : |__________________________ + : : : : + _____________:__________:__:_:______ + Bklight ____/: : : : : :\____ + power _______/ :<---T13---->: : : :<T16>: \______________ + (Vbl) :<T17>:<---------T14--------->: :<-T15->:<T18>: + + The above looks fairly complex but, as per above, each panel only cares + about a subset of those timings. + +allOf: + - $ref: panel-common.yaml# + +properties: + compatible: + const: edp-panel + + hpd-reliable-delay-ms: + description: + A fixed amount of time that must be waited after powering on the + panel's power-supply before the HPD signal is a reliable way to know + when the AUX channel is ready. This is useful for panels that glitch + the HPD at the start of power-on. This value is not needed if HPD is + always reliable for all panels that might be connected. + + hpd-absent-delay-ms: + description: + The panel specifies that HPD will be asserted this many milliseconds + from power on (timing T3 in the diagram above). If we have no way to + measure HPD then a fixed delay of this many milliseconds can be used. + This can also be used as a timeout when waiting for HPD. Does not + include the hpd-reliable-delay, so if hpd-reliable-delay was 80 ms + and hpd-absent-delay was 200 ms then we'd do a fixed 80 ms delay and + then we know HPD would assert in the next 120 ms. This value is not + needed if HPD hooked up, either through a GPIO in the panel node or + hooked up directly to the eDP controller. + + backlight: true + enable-gpios: true + port: true + power-supply: true + no-hpd: true + hpd-gpios: true + +additionalProperties: false + +required: + - compatible + - power-supply + +examples: + - | + #include <dt-bindings/clock/qcom,rpmh.h> + #include <dt-bindings/gpio/gpio.h> + #include <dt-bindings/interrupt-controller/irq.h> + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + bridge@2d { + compatible = "ti,sn65dsi86"; + reg = <0x2d>; + + interrupt-parent = <&tlmm>; + interrupts = <10 IRQ_TYPE_LEVEL_HIGH>; + + enable-gpios = <&tlmm 102 GPIO_ACTIVE_HIGH>; + + vpll-supply = <&src_pp1800_s4a>; + vccio-supply = <&src_pp1800_s4a>; + vcca-supply = <&src_pp1200_l2a>; + vcc-supply = <&src_pp1200_l2a>; + + clocks = <&rpmhcc RPMH_LN_BB_CLK2>; + clock-names = "refclk"; + + no-hpd; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + endpoint { + remote-endpoint = <&dsi0_out>; + }; + }; + + port@1 { + reg = <1>; + sn65dsi86_out: endpoint { + remote-endpoint = <&panel_in_edp>; + }; + }; + }; + + aux-bus { + panel { + compatible = "edp-panel"; + power-supply = <&pp3300_dx_edp>; + backlight = <&backlight>; + hpd-gpios = <&sn65dsi86_bridge 2 GPIO_ACTIVE_HIGH>; + hpd-reliable-delay-ms = <15>; + + port { + panel_in_edp: endpoint { + remote-endpoint = <&sn65dsi86_out>; + }; + }; + }; + }; + }; + };
Signature · 1 line
2.33.0.309.g3052b89438-goog
Re: [PATCH v4 01/15] dt-bindings: drm/panel-simple-edp: Introduce generic eDP panels
Quoting Douglas Anderson (2021-09-09 14:00:17)
Documentation/devicetree/bindings/display/panel/panel-edp.yaml line 7
Quoted 13 lines
Documentation/devicetree/bindings/display/panel/panel-edp.yaml new file +7
-0@@ -0,0 +1,188 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/panel/panel-edp.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Probable (via DP AUX / EDID) eDP Panels with simple poweron sequences
Should that be "Probeable" or "Probe-able" or "Detectable"? It's not about statistical probabilities right?
Doug Anderson
reviewerRe: [PATCH v4 01/15] dt-bindings: drm/panel-simple-edp: Introduce generic eDP panels
Hi,
Quoted 18 lines · Stephen Boyd
Quoting Douglas Anderson (2021-09-09 14:00:17)
Documentation/devicetree/bindings/display/panel/panel-edp.yaml line 7
Quoted 13 lines
Documentation/devicetree/bindings/display/panel/panel-edp.yaml new file +7
-0@@ -0,0 +1,188 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/panel/panel-edp.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Probable (via DP AUX / EDID) eDP Panels with simple poweron sequencesShould that be "Probeable" or "Probe-able" or "Detectable"? It's not about statistical probabilities right?
Thanks for the catch! Will be fixed in v5.
-Doug
Douglas Anderson
reviewerPATCH v4 2/15 drm/edid: Break out reading block 0 of the EDID
In reply to Douglas AndersonA future change wants to be able to read just block 0 of the EDID, so break it out of drm_do_get_edid() into a sub-function.
This is intended to be a no-op change--just code movement.
---
Changes in v4:
- "u8 *edid" => "void *edid" to avoid cast.
- Don't put kmalloc() in the "if" test even if the old code did.
- drm_do_get_edid_blk0() => drm_do_get_edid_base_block()
drivers/gpu/drm/drm_edid.c | 63 +++++++++++++++++++++++++++----------- 1 file changed, 45 insertions(+), 18 deletions(-)
drivers/gpu/drm/drm_edid.c +45 -18
@@ -1905,6 +1905,44 @@ int drm_add_override_edid_modes(struct drm_connector *connector) }EXPORT_SYMBOL (drm_add_override_edid_modes); +static struct edid *drm_do_get_edid_base_block ( +int (*get_edid_block)(void *data,u8 *buf,unsigned int block, +size_t len), +void *data,bool *edid_corrupt,int *null_edid_counter) +{ +int i; +void *edid; + + edid =kmalloc (EDID_LENGTH ,GFP_KERNEL ); +if (edid ==NULL ) +return NULL ; + +/* base block fetch */ +for (i =0 ; i <4 ; i++) { +if (get_edid_block (data, edid,0 ,EDID_LENGTH )) + goto out; +if (drm_edid_block_valid (edid,0 , false, edid_corrupt)) +break ; +if (i ==0 &&drm_edid_is_zero (edid,EDID_LENGTH )) { +if (null_edid_counter) + (*null_edid_counter)++; + goto carp; + } + } +if (i ==4 ) + goto carp; + +return edid; + +carp: +kfree (edid); +return ERR_PTR (-EINVAL ); + +out: +kfree (edid); +return NULL ; +} +/** * drm_do_get_edid - get EDID data using a custom EDID block read function * @connector: connector we're probing
@@ -1938,25 +1976,16 @@ struct edid *drm_do_get_edid(struct drm_connector *connector,if (override)return override; -if ((edid =kmalloc (EDID_LENGTH ,GFP_KERNEL )) ==NULL ) + edid = (u8 *)drm_do_get_edid_base_block (get_edid_block, data, + &connector->edid_corrupt, + &connector->null_edid_counter); +if (IS_ERR_OR_NULL (edid)) { +if (IS_ERR (edid)) +connector_bad_edid (connector, edid,1 );return NULL ; - -/* base block fetch */ -for (i =0 ; i <4 ; i++) { -if (get_edid_block (data, edid,0 ,EDID_LENGTH )) - goto out; -if (drm_edid_block_valid (edid,0 , false, - &connector->edid_corrupt)) -break ; -if (i ==0 &&drm_edid_is_zero (edid,EDID_LENGTH )) { - connector->null_edid_counter++; - goto carp; - } } -if (i ==4 ) - goto carp; -/* if there's no extensions, we're done */ +/* if there's no extensions or no connector, we're done */ valid_extensions = edid[0x7e ];if (valid_extensions ==0 )return (struct edid *)edid;
@@ -2010,8 +2039,6 @@ struct edid *drm_do_get_edid(struct drm_connector *connector,return (struct edid *)edid; -carp: -connector_bad_edid (connector, edid,1 ); out:kfree (edid);return NULL ;
Signature · 1 line
2.33.0.309.g3052b89438-goog
Re: [PATCH v4 02/15] drm/edid: Break out reading block 0 of the EDID
Quoted 7 lines · Douglas Anderson
A future change wants to be able to read just block 0 of the EDID, so break it out of
drm_do_get_edid()into a sub-function.This is intended to be a no-op change--just code movement.
Signed-off-by Douglas Anderson <[email protected]>Acked-by Sam Ravnborg <[email protected]>
Quoted 101 lines
---
Changes in v4:
- "u8 *edid" => "void *edid" to avoid cast.
- Don't putkmalloc()in the "if" test even if the old code did.
-drm_do_get_edid_blk0()=>drm_do_get_edid_base_block()drivers/gpu/drm/drm_edid.c | 63 +++++++++++++++++++++++++++----------- 1 file changed, 45 insertions(+), 18 deletions(-)drivers/gpu/drm/drm_edid.c +45
-18@@ -1905,6 +1905,44 @@ int drm_add_override_edid_modes(struct drm_connector *connector) }EXPORT_SYMBOL (drm_add_override_edid_modes); +static struct edid *drm_do_get_edid_base_block ( +int (*get_edid_block)(void *data,u8 *buf,unsigned int block, +size_t len), +void *data,bool *edid_corrupt,int *null_edid_counter) +{ +int i; +void *edid; + + edid =kmalloc (EDID_LENGTH ,GFP_KERNEL ); +if (edid ==NULL ) +return NULL ; + +/* base block fetch */ +for (i =0 ; i <4 ; i++) { +if (get_edid_block (data, edid,0 ,EDID_LENGTH )) + goto out; +if (drm_edid_block_valid (edid,0 , false, edid_corrupt)) +break ; +if (i ==0 &&drm_edid_is_zero (edid,EDID_LENGTH )) { +if (null_edid_counter) + (*null_edid_counter)++; + goto carp; + } + } +if (i ==4 ) + goto carp; + +return edid; + +carp: +kfree (edid); +return ERR_PTR (-EINVAL ); + +out: +kfree (edid); +return NULL ; +} +/** * drm_do_get_edid - get EDID data using a custom EDID block read function * @connector: connector we're probing @@ -1938,25 +1976,16 @@ struct edid *drm_do_get_edid(struct drm_connector *connector,if (override)return override; -if ((edid =kmalloc (EDID_LENGTH ,GFP_KERNEL )) ==NULL ) + edid = (u8 *)drm_do_get_edid_base_block (get_edid_block, data, + &connector->edid_corrupt, + &connector->null_edid_counter); +if (IS_ERR_OR_NULL (edid)) { +if (IS_ERR (edid)) +connector_bad_edid (connector, edid,1 );return NULL ; - -/* base block fetch */ -for (i =0 ; i <4 ; i++) { -if (get_edid_block (data, edid,0 ,EDID_LENGTH )) - goto out; -if (drm_edid_block_valid (edid,0 , false, - &connector->edid_corrupt)) -break ; -if (i ==0 &&drm_edid_is_zero (edid,EDID_LENGTH )) { - connector->null_edid_counter++; - goto carp; - } } -if (i ==4 ) - goto carp; -/* if there's no extensions, we're done */ +/* if there's no extensions or no connector, we're done */ valid_extensions = edid[0x7e ];if (valid_extensions ==0 )return (struct edid *)edid;@@ -2010,8 +2039,6 @@ struct edid *drm_do_get_edid(struct drm_connector *connector,return (struct edid *)edid; -carp: -connector_bad_edid (connector, edid,1 ); out:kfree (edid);return NULL ;
Signature · 1 line
Jani Nikula, Intel Open Source Graphics Center
Douglas Anderson
reviewerPATCH v4 3/15 drm/edid: Allow querying/working with the panel ID from the EDID
In reply to Douglas AndersonEDIDs have 32-bits worth of data which is intended to be used to uniquely identify the make/model of a panel. This has historically been used only internally in the EDID processing code to identify quirks with panels.
We'd like to use this panel ID in panel drivers to identify which panel is hooked up and from that information figure out power sequence timings. Let's expose this information from the EDID code and also allow it to be accessed early, before a connector has been created.
To make matching in the panel drivers code easier, we'll return the panel ID as a 32-bit value. We'll provide some functions for converting this value back and forth to something more human readable.
---
Changes in v4:
- Don't refer to "panel-simple" in commit message.
- decode_edid_id() => drm_edid_decode_panel_id()
- drm_do_get_edid_blk0() => drm_do_get_edid_base_block()
- drm_get_panel_id() => drm_edid_get_panel_id()
- encode_edid_id() => drm_edid_encode_panel_id()
- split panel id extraction out to its own function.
Changes in v3:
- Decode hex product ID w/ same endianness as everyone else.
drivers/gpu/drm/drm_edid.c | 67 ++++++++++++++++++++++++++++++++++++++ include/drm/drm_edid.h | 47 ++++++++++++++++++++++++++ 2 files changed, 114 insertions(+)
drivers/gpu/drm/drm_edid.c +67 -0
@@ -2087,6 +2087,73 @@ struct edid *drm_get_edid(struct drm_connector *connector, }EXPORT_SYMBOL (drm_get_edid); +static u32 edid_extract_panel_id (const struct edid *edid) +{ +/* +* In theory we could try to de-obfuscate this like edid_get_quirks() +* does, but it's easier to just deal with a 32-bit number since then +* it can be compared with "==". +* +* NOTE that we deal with endianness differently for the top half +* of this ID than for the bottom half. The bottom half (the product +* id) gets decoded as little endian by the EDID_PRODUCT_ID because +* that's how everyone seems to interpret it. The top half (the mfg_id) +* gets stored as big endian because that makes +* drm_edid_encode_panel_id() and drm_edid_decode_panel_id() easier +* to write (it's easier to extract the ASCII). It doesn't really +* matter, though, as long as the number here is unique. +*/ +return (u32 )edid->mfg_id[0 ] <<24 | + (u32 )edid->mfg_id[1 ] <<16 | + (u32 )EDID_PRODUCT_ID (edid); +} + +/** +* drm_edid_get_panel_id - Get a panel's ID through DDC +* @adapter: I2C adapter to use for DDC +* +* This function reads the first block of the EDID of a panel and (assuming +* that the EDID is valid) extracts the ID out of it. The ID is a 32-bit value +* (16 bits of manufacturer ID and 16 bits of per-manufacturer ID) that's +* supposed to be different for each different modem of panel. +* +* This function is intended to be used during early probing on devices where +* more than one panel might be present. Because of its intended use it must +* assume that the EDID of the panel is correct, at least as far as the ID +* is concerned (in other words, we don't process any overrides here). +* +* NOTE: it's expected that this function and drm_do_get_edid() will both +* be read the EDID, but there is no caching between them. Since we're only +* reading the first block, hopefully this extra overhead won't be too big. +* +* Return: A 32-bit ID that should be different for each make/model of panel. +* See the functions drm_edid_encode_panel_id() and +* drm_edid_decode_panel_id() for some details on the structure of this +* ID. +*/ + +u32 drm_edid_get_panel_id (struct i2c_adapter *adapter) +{ +struct edid *edid; +u32 panel_id; + + edid =drm_do_get_edid_base_block (drm_do_probe_ddc_edid, adapter, +NULL ,NULL ); + +/* +* There are no manufacturer IDs of 0, so if there is a problem reading +* the EDID then we'll just return 0. +*/ +if (IS_ERR_OR_NULL (edid)) +return 0 ; + + panel_id =edid_extract_panel_id (edid); +kfree (edid); + +return panel_id; +} +EXPORT_SYMBOL (drm_edid_get_panel_id); +/** * drm_get_edid_switcheroo - get EDID data for a vga_switcheroo output * @connector: connector we're probing
include/drm/drm_edid.h +47 -0
59 lines not on this page · raw message
Signature · 1 line
2.33.0.309.g3052b89438-goog
Re: [PATCH v4 03/15] drm/edid: Allow querying/working with the panel ID from the EDID
Quoted 10 lines · Douglas Anderson
EDIDs have 32-bits worth of data which is intended to be used to uniquely identify the make/model of a panel. This has historically been used only internally in the EDID processing code to identify quirks with panels.
We'd like to use this panel ID in panel drivers to identify which panel is hooked up and from that information figure out power sequence timings. Let's expose this information from the EDID code and also allow it to be accessed early, before a connector has been created.
Quoted 6 lines
To make matching in the panel drivers code easier, we'll return the panel ID as a 32-bit value. We'll provide some functions for converting this value back and forth to something more human readable.
Signed-off-by Douglas Anderson <[email protected]>Acked-by Sam Ravnborg <[email protected]>
Quoted 160 lines
---
Changes in v4:
- Don't refer to "panel-simple" in commit message.
-decode_edid_id()=>drm_edid_decode_panel_id()
-drm_do_get_edid_blk0()=>drm_do_get_edid_base_block()
-drm_get_panel_id()=>drm_edid_get_panel_id()
-encode_edid_id()=>drm_edid_encode_panel_id()
- split panel id extraction out to its own function.Changes in v3:
- Decode hex product ID w/ same endianness as everyone else.drivers/gpu/drm/drm_edid.c | 67 ++++++++++++++++++++++++++++++++++++++ include/drm/drm_edid.h | 47 ++++++++++++++++++++++++++ 2 files changed, 114 insertions(+)drivers/gpu/drm/drm_edid.c +67
-0@@ -2087,6 +2087,73 @@ struct edid *drm_get_edid(struct drm_connector *connector, }EXPORT_SYMBOL (drm_get_edid); +static u32 edid_extract_panel_id (const struct edid *edid) +{ +/* +* In theory we could try to de-obfuscate this like edid_get_quirks() +* does, but it's easier to just deal with a 32-bit number since then +* it can be compared with "==". +* +* NOTE that we deal with endianness differently for the top half +* of this ID than for the bottom half. The bottom half (the product +* id) gets decoded as little endian by the EDID_PRODUCT_ID because +* that's how everyone seems to interpret it. The top half (the mfg_id) +* gets stored as big endian because that makes +* drm_edid_encode_panel_id() and drm_edid_decode_panel_id() easier +* to write (it's easier to extract the ASCII). It doesn't really +* matter, though, as long as the number here is unique. +*/ +return (u32 )edid->mfg_id[0 ] <<24 | + (u32 )edid->mfg_id[1 ] <<16 | + (u32 )EDID_PRODUCT_ID (edid); +} + +/** +* drm_edid_get_panel_id - Get a panel's ID through DDC +* @adapter: I2C adapter to use for DDC +* +* This function reads the first block of the EDID of a panel and (assuming +* that the EDID is valid) extracts the ID out of it. The ID is a 32-bit value +* (16 bits of manufacturer ID and 16 bits of per-manufacturer ID) that's +* supposed to be different for each different modem of panel. +* +* This function is intended to be used during early probing on devices where +* more than one panel might be present. Because of its intended use it must +* assume that the EDID of the panel is correct, at least as far as the ID +* is concerned (in other words, we don't process any overrides here). +* +* NOTE: it's expected that this function and drm_do_get_edid() will both +* be read the EDID, but there is no caching between them. Since we're only +* reading the first block, hopefully this extra overhead won't be too big. +* +* Return: A 32-bit ID that should be different for each make/model of panel. +* See the functions drm_edid_encode_panel_id() and +* drm_edid_decode_panel_id() for some details on the structure of this +* ID. +*/ + +u32 drm_edid_get_panel_id (struct i2c_adapter *adapter) +{ +struct edid *edid; +u32 panel_id; + + edid =drm_do_get_edid_base_block (drm_do_probe_ddc_edid, adapter, +NULL ,NULL ); + +/* +* There are no manufacturer IDs of 0, so if there is a problem reading +* the EDID then we'll just return 0. +*/ +if (IS_ERR_OR_NULL (edid)) +return 0 ; + + panel_id =edid_extract_panel_id (edid); +kfree (edid); + +return panel_id; +} +EXPORT_SYMBOL (drm_edid_get_panel_id); +/** * drm_get_edid_switcheroo - get EDID data for a vga_switcheroo output * @connector: connector we're probing include/drm/drm_edid.h +47
-0@@ -508,6 +508,52 @@ static inline u8 drm_eld_get_conn_type(const uint8_t *eld)return eld[DRM_ELD_SAD_COUNT_CONN_TYPE ] &DRM_ELD_CONN_TYPE_MASK ; } +/** +* drm_edid_encode_panel_id - Encode an ID for matching against drm_edid_get_panel_id() +* @vend_chr_0: First character of the vendor string. +* @vend_chr_2: Second character of the vendor string. +* @vend_chr_3: Third character of the vendor string. +* @product_id: The 16-bit product ID. +* +* This is a macro so that it can be calculated at compile time and used +* as an initializer. +* +* For instance: +* drm_edid_encode_panel_id('B', 'O', 'E', 0x2d08) => 0x09e52d08 +* +* Return: a 32-bit ID per panel. +*/ +#define drm_edid_encode_panel_id (vend_chr_0, vend_chr_1, vend_chr_2, product_id) \ + ((((u32)(vend_chr_0) - '@') & 0x1f) << 26 | \ + (((u32)(vend_chr_1) - '@') & 0x1f) << 21 | \ + (((u32)(vend_chr_2) - '@') & 0x1f) << 16 | \ + ((product_id) & 0xffff)) + +/** +* drm_edid_decode_panel_id - Decode a panel ID from drm_edid_encode_panel_id() +* @panel_id: The panel ID to decode. +* @vend: A 4-byte buffer to store the 3-letter vendor string plus a '\0' +* termination +* @product_id: The product ID will be returned here. +* +* For instance, after: +* drm_edid_decode_panel_id(0x09e52d08, vend, &product_id) +* These will be true: +* vend[0] = 'B' +* vend[1] = 'O' +* vend[2] = 'E' +* vend[3] = '\0' +* product_id = 0x2d08 +*/ +static inline void drm_edid_decode_panel_id (u32 panel_id,char vend[4 ],u16 *product_id) +{ + *product_id = (u16)(panel_id &0xffff ); + vend[0 ] ='@' + ((panel_id >>26 ) &0x1f ); + vend[1 ] ='@' + ((panel_id >>21 ) &0x1f ); + vend[2 ] ='@' + ((panel_id >>16 ) &0x1f ); + vend[3 ] ='\0' ; +} +bool drm_probe_ddc (struct i2c_adapter *adapter); struct edid *drm_do_get_edid(struct drm_connector *connector, int (*get_edid_block)(void *data, u8 *buf, unsigned int block,@@ -515,6 +561,7 @@ struct edid *drm_do_get_edid(struct drm_connector *connector, void *data);struct edid *drm_get_edid (struct drm_connector *connector,struct i2c_adapter *adapter); +u32 drm_edid_get_panel_id (struct i2c_adapter *adapter);struct edid *drm_get_edid_switcheroo (struct drm_connector *connector,struct i2c_adapter *adapter);struct edid *drm_edid_duplicate (const struct edid *edid);
Signature · 1 line
Jani Nikula, Intel Open Source Graphics Center
Douglas Anderson
reviewerPATCH v4 4/15 drm/edid: Use new encoded panel id style for quirks matching
In reply to Douglas AndersonIn the patch ("drm/edid: Allow the querying/working with the panel ID from the EDID") we introduced a different way of working with the panel ID stored in the EDID. Let's use this new way for the quirks code.
Advantages of the new style:
* Smaller data structure size. Saves 4 bytes per panel.
* Iterate through quirks structure with just "==" instead of strncmp()
* In-kernel storage is more similar to what's stored in the EDID itself making it easier to grok that they are referring to the same value.
The quirk table itself is arguably a bit less readable in the new style but not a ton less and it feels like the above advantages make up for it.
---
This commit is only compile-tested. I don't have any DP panels that exercise this code. Transition from the old table to the new one was done with a regexp.
Changes in v4:
- ("Use new encoded panel id style for quirks matching") new for v4.
drivers/gpu/drm/drm_edid.c | 157 +++++++++++++++++-------------------- 1 file changed, 71 insertions(+), 86 deletions(-)
drivers/gpu/drm/drm_edid.c +71 -86
@@ -100,122 +100,128 @@ struct detailed_mode_closure {#define LEVEL_GTF2 2#define LEVEL_CVT 3 +#define EDID_QUIRK (vend_chr_0, vend_chr_1, vend_chr_2, product_id, _quirks) \ +{ \ + .panel_id = drm_edid_encode_panel_id(vend_chr_0, vend_chr_1, vend_chr_2, \ + product_id), \ + .quirks = _quirks \ +} +static const struct edid_quirk { -char vendor[4 ]; -int product_id; +u32 panel_id;u32 quirks; } edid_quirk_list[] = {/* Acer AL1706 */ - {"ACR" ,44358 ,EDID_QUIRK_PREFER_LARGE_60 }, +EDID_QUIRK ('A' ,'C' ,'R' ,44358 ,EDID_QUIRK_PREFER_LARGE_60 ),/* Acer F51 */ - {"API" ,0x7602 ,EDID_QUIRK_PREFER_LARGE_60 }, +EDID_QUIRK ('A' ,'P' ,'I' ,0x7602 ,EDID_QUIRK_PREFER_LARGE_60 ),/* AEO model 0 reports 8 bpc, but is a 6 bpc panel */ - {"AEO" ,0 ,EDID_QUIRK_FORCE_6BPC }, +EDID_QUIRK ('A' ,'E' ,'O' ,0 ,EDID_QUIRK_FORCE_6BPC ),/* BOE model on HP Pavilion 15-n233sl reports 8 bpc, but is a 6 bpc panel */ - {"BOE" ,0x78b ,EDID_QUIRK_FORCE_6BPC }, +EDID_QUIRK ('B' ,'O' ,'E' ,0x78b ,EDID_QUIRK_FORCE_6BPC ),/* CPT panel of Asus UX303LA reports 8 bpc, but is a 6 bpc panel */ - {"CPT" ,0x17df ,EDID_QUIRK_FORCE_6BPC }, +EDID_QUIRK ('C' ,'P' ,'T' ,0x17df ,EDID_QUIRK_FORCE_6BPC ),/* SDC panel of Lenovo B50-80 reports 8 bpc, but is a 6 bpc panel */ - {"SDC" ,0x3652 ,EDID_QUIRK_FORCE_6BPC }, +EDID_QUIRK ('S' ,'D' ,'C' ,0x3652 ,EDID_QUIRK_FORCE_6BPC ),/* BOE model 0x0771 reports 8 bpc, but is a 6 bpc panel */ - {"BOE" ,0x0771 ,EDID_QUIRK_FORCE_6BPC }, +EDID_QUIRK ('B' ,'O' ,'E' ,0x0771 ,EDID_QUIRK_FORCE_6BPC ),/* Belinea 10 15 55 */ - {"MAX" ,1516 ,EDID_QUIRK_PREFER_LARGE_60 }, - {"MAX" ,0x77e ,EDID_QUIRK_PREFER_LARGE_60 }, +EDID_QUIRK ('M' ,'A' ,'X' ,1516 ,EDID_QUIRK_PREFER_LARGE_60 ), +EDID_QUIRK ('M' ,'A' ,'X' ,0x77e ,EDID_QUIRK_PREFER_LARGE_60 ),/* Envision Peripherals, Inc. EN-7100e */ - {"EPI" ,59264 ,EDID_QUIRK_135_CLOCK_TOO_HIGH }, +EDID_QUIRK ('E' ,'P' ,'I' ,59264 ,EDID_QUIRK_135_CLOCK_TOO_HIGH ),/* Envision EN2028 */ - {"EPI" ,8232 ,EDID_QUIRK_PREFER_LARGE_60 }, +EDID_QUIRK ('E' ,'P' ,'I' ,8232 ,EDID_QUIRK_PREFER_LARGE_60 ),/* Funai Electronics PM36B */ - {"FCM" ,13600 ,EDID_QUIRK_PREFER_LARGE_75 | -EDID_QUIRK_DETAILED_IN_CM }, +EDID_QUIRK ('F' ,'C' ,'M' ,13600 ,EDID_QUIRK_PREFER_LARGE_75 | +EDID_QUIRK_DETAILED_IN_CM ),/* LGD panel of HP zBook 17 G2, eDP 10 bpc, but reports unknown bpc */ - {"LGD" ,764 ,EDID_QUIRK_FORCE_10BPC }, +EDID_QUIRK ('L' ,'G' ,'D' ,764 ,EDID_QUIRK_FORCE_10BPC ),/* LG Philips LCD LP154W01-A5 */ - {"LPL" ,0 ,EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE }, - {"LPL" ,0x2a00 ,EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE }, +EDID_QUIRK ('L' ,'P' ,'L' ,0 ,EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE ), +EDID_QUIRK ('L' ,'P' ,'L' ,0x2a00 ,EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE ),/* Samsung SyncMaster 205BW. Note: irony */ - {"SAM" ,541 ,EDID_QUIRK_DETAILED_SYNC_PP }, +EDID_QUIRK ('S' ,'A' ,'M' ,541 ,EDID_QUIRK_DETAILED_SYNC_PP ),/* Samsung SyncMaster 22[5-6]BW */ - {"SAM" ,596 ,EDID_QUIRK_PREFER_LARGE_60 }, - {"SAM" ,638 ,EDID_QUIRK_PREFER_LARGE_60 }, +EDID_QUIRK ('S' ,'A' ,'M' ,596 ,EDID_QUIRK_PREFER_LARGE_60 ), +EDID_QUIRK ('S' ,'A' ,'M' ,638 ,EDID_QUIRK_PREFER_LARGE_60 ),/* Sony PVM-2541A does up to 12 bpc, but only reports max 8 bpc */ - {"SNY" ,0x2541 ,EDID_QUIRK_FORCE_12BPC }, +EDID_QUIRK ('S' ,'N' ,'Y' ,0x2541 ,EDID_QUIRK_FORCE_12BPC ),/* ViewSonic VA2026w */ - {"VSC" ,5020 ,EDID_QUIRK_FORCE_REDUCED_BLANKING }, +EDID_QUIRK ('V' ,'S' ,'C' ,5020 ,EDID_QUIRK_FORCE_REDUCED_BLANKING ),/* Medion MD 30217 PG */ - {"MED" ,0x7b8 ,EDID_QUIRK_PREFER_LARGE_75 }, +EDID_QUIRK ('M' ,'E' ,'D' ,0x7b8 ,EDID_QUIRK_PREFER_LARGE_75 ),/* Lenovo G50 */ - {"SDC" ,18514 ,EDID_QUIRK_FORCE_6BPC }, +EDID_QUIRK ('S' ,'D' ,'C' ,18514 ,EDID_QUIRK_FORCE_6BPC ),/* Panel in Samsung NP700G7A-S01PL notebook reports 6bpc */ - {"SEC" ,0xd033 ,EDID_QUIRK_FORCE_8BPC }, +EDID_QUIRK ('S' ,'E' ,'C' ,0xd033 ,EDID_QUIRK_FORCE_8BPC ),/* Rotel RSX-1058 forwards sink's EDID but only does HDMI 1.1*/ - {"ETR" ,13896 ,EDID_QUIRK_FORCE_8BPC }, +EDID_QUIRK ('E' ,'T' ,'R' ,13896 ,EDID_QUIRK_FORCE_8BPC ),/* Valve Index Headset */ - {"VLV" ,0x91a8 ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91b0 ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91b1 ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91b2 ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91b3 ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91b4 ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91b5 ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91b6 ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91b7 ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91b8 ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91b9 ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91ba ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91bb ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91bc ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91bd ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91be ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91bf ,EDID_QUIRK_NON_DESKTOP }, +EDID_QUIRK ('V' ,'L' ,'V' ,0x91a8 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91b0 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91b1 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91b2 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91b3 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91b4 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91b5 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91b6 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91b7 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91b8 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91b9 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91ba ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91bb ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91bc ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91bd ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91be ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91bf ,EDID_QUIRK_NON_DESKTOP ),/* HTC Vive and Vive Pro VR Headsets */ - {"HVR" ,0xaa01 ,EDID_QUIRK_NON_DESKTOP }, - {"HVR" ,0xaa02 ,EDID_QUIRK_NON_DESKTOP }, +EDID_QUIRK ('H' ,'V' ,'R' ,0xaa01 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('H' ,'V' ,'R' ,0xaa02 ,EDID_QUIRK_NON_DESKTOP ),/* Oculus Rift DK1, DK2, CV1 and Rift S VR Headsets */ - {"OVR" ,0x0001 ,EDID_QUIRK_NON_DESKTOP }, - {"OVR" ,0x0003 ,EDID_QUIRK_NON_DESKTOP }, - {"OVR" ,0x0004 ,EDID_QUIRK_NON_DESKTOP }, - {"OVR" ,0x0012 ,EDID_QUIRK_NON_DESKTOP }, +EDID_QUIRK ('O' ,'V' ,'R' ,0x0001 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('O' ,'V' ,'R' ,0x0003 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('O' ,'V' ,'R' ,0x0004 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('O' ,'V' ,'R' ,0x0012 ,EDID_QUIRK_NON_DESKTOP ),/* Windows Mixed Reality Headsets */ - {"ACR" ,0x7fce ,EDID_QUIRK_NON_DESKTOP }, - {"HPN" ,0x3515 ,EDID_QUIRK_NON_DESKTOP }, - {"LEN" ,0x0408 ,EDID_QUIRK_NON_DESKTOP }, - {"LEN" ,0xb800 ,EDID_QUIRK_NON_DESKTOP }, - {"FUJ" ,0x1970 ,EDID_QUIRK_NON_DESKTOP }, - {"DEL" ,0x7fce ,EDID_QUIRK_NON_DESKTOP }, - {"SEC" ,0x144a ,EDID_QUIRK_NON_DESKTOP }, - {"AUS" ,0xc102 ,EDID_QUIRK_NON_DESKTOP }, +EDID_QUIRK ('A' ,'C' ,'R' ,0x7fce ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('H' ,'P' ,'N' ,0x3515 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('L' ,'E' ,'N' ,0x0408 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('L' ,'E' ,'N' ,0xb800 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('F' ,'U' ,'J' ,0x1970 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('D' ,'E' ,'L' ,0x7fce ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('S' ,'E' ,'C' ,0x144a ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('A' ,'U' ,'S' ,0xc102 ,EDID_QUIRK_NON_DESKTOP ),/* Sony PlayStation VR Headset */ - {"SNY" ,0x0704 ,EDID_QUIRK_NON_DESKTOP }, +EDID_QUIRK ('S' ,'N' ,'Y' ,0x0704 ,EDID_QUIRK_NON_DESKTOP ),/* Sensics VR Headsets */ - {"SEN" ,0x1019 ,EDID_QUIRK_NON_DESKTOP }, +EDID_QUIRK ('S' ,'E' ,'N' ,0x1019 ,EDID_QUIRK_NON_DESKTOP ),/* OSVR HDK and HDK2 VR Headsets */ - {"SVR" ,0x1019 ,EDID_QUIRK_NON_DESKTOP }, +EDID_QUIRK ('S' ,'V' ,'R' ,0x1019 ,EDID_QUIRK_NON_DESKTOP ), };/*
@@ -2090,9 +2096,8 @@ EXPORT_SYMBOL(drm_get_edid);static u32 edid_extract_panel_id (const struct edid *edid) {/* -* In theory we could try to de-obfuscate this like edid_get_quirks() -* does, but it's easier to just deal with a 32-bit number since then -* it can be compared with "==". +* We represent the ID as a 32-bit number so it can easily be compared +* with "==". * * NOTE that we deal with endianness differently for the top half * of this ID than for the bottom half. The bottom half (the product
@@ -2197,25 +2202,6 @@ EXPORT_SYMBOL(drm_edid_duplicate);/*** EDID parsing ***/ -/** -* edid_vendor - match a string against EDID's obfuscated vendor field -* @edid: EDID to match -* @vendor: vendor string -* -* Returns true if @vendor is in @edid, false otherwise -*/ -static bool edid_vendor (const struct edid *edid,const char *vendor) -{ -char edid_vendor[3 ]; - - edid_vendor[0 ] = ((edid->mfg_id[0 ] &0x7c ) >>2 ) +'@' ; - edid_vendor[1 ] = (((edid->mfg_id[0 ] &0x3 ) <<3 ) | - ((edid->mfg_id[1 ] &0xe0 ) >>5 )) +'@' ; - edid_vendor[2 ] = (edid->mfg_id[1 ] &0x1f ) +'@' ; - -return !strncmp (edid_vendor, vendor,3 ); -} -/** * edid_get_quirks - return quirk flags for a given EDID * @edid: EDID to process
@@ -2224,14 +2210,13 @@ static bool edid_vendor(const struct edid *edid, const char *vendor)*/ static u32 edid_get_quirks (const struct edid *edid) { +u32 panel_id =edid_extract_panel_id (edid);const struct edid_quirk *quirk;int i;for (i =0 ; i <ARRAY_SIZE (edid_quirk_list); i++) { quirk = &edid_quirk_list[i]; - -if (edid_vendor (edid, quirk->vendor) && - (EDID_PRODUCT_ID (edid) == quirk->product_id)) +if (quirk->panel_id == panel_id)return quirk->quirks; }
Signature · 1 line
2.33.0.309.g3052b89438-goog
Re: [PATCH v4 04/15] drm/edid: Use new encoded panel id style for quirks matching
Quoted 12 lines · Douglas Anderson
In the patch ("drm/edid: Allow the querying/working with the panel ID from the EDID") we introduced a different way of working with the panel ID stored in the EDID. Let's use this new way for the quirks code.
Advantages of the new style:
* Smaller data structure size. Saves 4 bytes per panel.
* Iterate through quirks structure with just "==" instead ofstrncmp()
* In-kernel storage is more similar to what's stored in the EDID itself making it easier to grok that they are referring to the same value.
Quoted 3 lines
The quirk table itself is arguably a bit less readable in the new style but not a ton less and it feels like the above advantages make up for it.
I suppose you could pass vendor as a string to EDID_QUIRK() to retain better readability?
Just bikeshedding, really. ;)
BR,
Jani.
Quoted 261 lines
Signed-off-by Douglas Anderson <[email protected]>---
This commit is only compile-tested. I don't have any DP panels that exercise this code. Transition from the old table to the new one was done with a regexp.Changes in v4:
- ("Use new encoded panel id style for quirks matching") new for v4.drivers/gpu/drm/drm_edid.c | 157 +++++++++++++++++-------------------- 1 file changed, 71 insertions(+), 86 deletions(-)drivers/gpu/drm/drm_edid.c +71
-86@@ -100,122 +100,128 @@ struct detailed_mode_closure {#define LEVEL_GTF2 2#define LEVEL_CVT 3 +#define EDID_QUIRK (vend_chr_0, vend_chr_1, vend_chr_2, product_id, _quirks) \ +{ \ + .panel_id = drm_edid_encode_panel_id(vend_chr_0, vend_chr_1, vend_chr_2, \ + product_id), \ + .quirks = _quirks \ +} +static const struct edid_quirk { -char vendor[4 ]; -int product_id; +u32 panel_id;u32 quirks; } edid_quirk_list[] = {/* Acer AL1706 */ - {"ACR" ,44358 ,EDID_QUIRK_PREFER_LARGE_60 }, +EDID_QUIRK ('A' ,'C' ,'R' ,44358 ,EDID_QUIRK_PREFER_LARGE_60 ),/* Acer F51 */ - {"API" ,0x7602 ,EDID_QUIRK_PREFER_LARGE_60 }, +EDID_QUIRK ('A' ,'P' ,'I' ,0x7602 ,EDID_QUIRK_PREFER_LARGE_60 ),/* AEO model 0 reports 8 bpc, but is a 6 bpc panel */ - {"AEO" ,0 ,EDID_QUIRK_FORCE_6BPC }, +EDID_QUIRK ('A' ,'E' ,'O' ,0 ,EDID_QUIRK_FORCE_6BPC ),/* BOE model on HP Pavilion 15-n233sl reports 8 bpc, but is a 6 bpc panel */ - {"BOE" ,0x78b ,EDID_QUIRK_FORCE_6BPC }, +EDID_QUIRK ('B' ,'O' ,'E' ,0x78b ,EDID_QUIRK_FORCE_6BPC ),/* CPT panel of Asus UX303LA reports 8 bpc, but is a 6 bpc panel */ - {"CPT" ,0x17df ,EDID_QUIRK_FORCE_6BPC }, +EDID_QUIRK ('C' ,'P' ,'T' ,0x17df ,EDID_QUIRK_FORCE_6BPC ),/* SDC panel of Lenovo B50-80 reports 8 bpc, but is a 6 bpc panel */ - {"SDC" ,0x3652 ,EDID_QUIRK_FORCE_6BPC }, +EDID_QUIRK ('S' ,'D' ,'C' ,0x3652 ,EDID_QUIRK_FORCE_6BPC ),/* BOE model 0x0771 reports 8 bpc, but is a 6 bpc panel */ - {"BOE" ,0x0771 ,EDID_QUIRK_FORCE_6BPC }, +EDID_QUIRK ('B' ,'O' ,'E' ,0x0771 ,EDID_QUIRK_FORCE_6BPC ),/* Belinea 10 15 55 */ - {"MAX" ,1516 ,EDID_QUIRK_PREFER_LARGE_60 }, - {"MAX" ,0x77e ,EDID_QUIRK_PREFER_LARGE_60 }, +EDID_QUIRK ('M' ,'A' ,'X' ,1516 ,EDID_QUIRK_PREFER_LARGE_60 ), +EDID_QUIRK ('M' ,'A' ,'X' ,0x77e ,EDID_QUIRK_PREFER_LARGE_60 ),/* Envision Peripherals, Inc. EN-7100e */ - {"EPI" ,59264 ,EDID_QUIRK_135_CLOCK_TOO_HIGH }, +EDID_QUIRK ('E' ,'P' ,'I' ,59264 ,EDID_QUIRK_135_CLOCK_TOO_HIGH ),/* Envision EN2028 */ - {"EPI" ,8232 ,EDID_QUIRK_PREFER_LARGE_60 }, +EDID_QUIRK ('E' ,'P' ,'I' ,8232 ,EDID_QUIRK_PREFER_LARGE_60 ),/* Funai Electronics PM36B */ - {"FCM" ,13600 ,EDID_QUIRK_PREFER_LARGE_75 | -EDID_QUIRK_DETAILED_IN_CM }, +EDID_QUIRK ('F' ,'C' ,'M' ,13600 ,EDID_QUIRK_PREFER_LARGE_75 | +EDID_QUIRK_DETAILED_IN_CM ),/* LGD panel of HP zBook 17 G2, eDP 10 bpc, but reports unknown bpc */ - {"LGD" ,764 ,EDID_QUIRK_FORCE_10BPC }, +EDID_QUIRK ('L' ,'G' ,'D' ,764 ,EDID_QUIRK_FORCE_10BPC ),/* LG Philips LCD LP154W01-A5 */ - {"LPL" ,0 ,EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE }, - {"LPL" ,0x2a00 ,EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE }, +EDID_QUIRK ('L' ,'P' ,'L' ,0 ,EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE ), +EDID_QUIRK ('L' ,'P' ,'L' ,0x2a00 ,EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE ),/* Samsung SyncMaster 205BW. Note: irony */ - {"SAM" ,541 ,EDID_QUIRK_DETAILED_SYNC_PP }, +EDID_QUIRK ('S' ,'A' ,'M' ,541 ,EDID_QUIRK_DETAILED_SYNC_PP ),/* Samsung SyncMaster 22[5-6]BW */ - {"SAM" ,596 ,EDID_QUIRK_PREFER_LARGE_60 }, - {"SAM" ,638 ,EDID_QUIRK_PREFER_LARGE_60 }, +EDID_QUIRK ('S' ,'A' ,'M' ,596 ,EDID_QUIRK_PREFER_LARGE_60 ), +EDID_QUIRK ('S' ,'A' ,'M' ,638 ,EDID_QUIRK_PREFER_LARGE_60 ),/* Sony PVM-2541A does up to 12 bpc, but only reports max 8 bpc */ - {"SNY" ,0x2541 ,EDID_QUIRK_FORCE_12BPC }, +EDID_QUIRK ('S' ,'N' ,'Y' ,0x2541 ,EDID_QUIRK_FORCE_12BPC ),/* ViewSonic VA2026w */ - {"VSC" ,5020 ,EDID_QUIRK_FORCE_REDUCED_BLANKING }, +EDID_QUIRK ('V' ,'S' ,'C' ,5020 ,EDID_QUIRK_FORCE_REDUCED_BLANKING ),/* Medion MD 30217 PG */ - {"MED" ,0x7b8 ,EDID_QUIRK_PREFER_LARGE_75 }, +EDID_QUIRK ('M' ,'E' ,'D' ,0x7b8 ,EDID_QUIRK_PREFER_LARGE_75 ),/* Lenovo G50 */ - {"SDC" ,18514 ,EDID_QUIRK_FORCE_6BPC }, +EDID_QUIRK ('S' ,'D' ,'C' ,18514 ,EDID_QUIRK_FORCE_6BPC ),/* Panel in Samsung NP700G7A-S01PL notebook reports 6bpc */ - {"SEC" ,0xd033 ,EDID_QUIRK_FORCE_8BPC }, +EDID_QUIRK ('S' ,'E' ,'C' ,0xd033 ,EDID_QUIRK_FORCE_8BPC ),/* Rotel RSX-1058 forwards sink's EDID but only does HDMI 1.1*/ - {"ETR" ,13896 ,EDID_QUIRK_FORCE_8BPC }, +EDID_QUIRK ('E' ,'T' ,'R' ,13896 ,EDID_QUIRK_FORCE_8BPC ),/* Valve Index Headset */ - {"VLV" ,0x91a8 ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91b0 ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91b1 ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91b2 ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91b3 ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91b4 ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91b5 ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91b6 ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91b7 ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91b8 ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91b9 ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91ba ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91bb ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91bc ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91bd ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91be ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91bf ,EDID_QUIRK_NON_DESKTOP }, +EDID_QUIRK ('V' ,'L' ,'V' ,0x91a8 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91b0 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91b1 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91b2 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91b3 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91b4 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91b5 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91b6 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91b7 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91b8 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91b9 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91ba ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91bb ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91bc ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91bd ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91be ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91bf ,EDID_QUIRK_NON_DESKTOP ),/* HTC Vive and Vive Pro VR Headsets */ - {"HVR" ,0xaa01 ,EDID_QUIRK_NON_DESKTOP }, - {"HVR" ,0xaa02 ,EDID_QUIRK_NON_DESKTOP }, +EDID_QUIRK ('H' ,'V' ,'R' ,0xaa01 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('H' ,'V' ,'R' ,0xaa02 ,EDID_QUIRK_NON_DESKTOP ),/* Oculus Rift DK1, DK2, CV1 and Rift S VR Headsets */ - {"OVR" ,0x0001 ,EDID_QUIRK_NON_DESKTOP }, - {"OVR" ,0x0003 ,EDID_QUIRK_NON_DESKTOP }, - {"OVR" ,0x0004 ,EDID_QUIRK_NON_DESKTOP }, - {"OVR" ,0x0012 ,EDID_QUIRK_NON_DESKTOP }, +EDID_QUIRK ('O' ,'V' ,'R' ,0x0001 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('O' ,'V' ,'R' ,0x0003 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('O' ,'V' ,'R' ,0x0004 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('O' ,'V' ,'R' ,0x0012 ,EDID_QUIRK_NON_DESKTOP ),/* Windows Mixed Reality Headsets */ - {"ACR" ,0x7fce ,EDID_QUIRK_NON_DESKTOP }, - {"HPN" ,0x3515 ,EDID_QUIRK_NON_DESKTOP }, - {"LEN" ,0x0408 ,EDID_QUIRK_NON_DESKTOP }, - {"LEN" ,0xb800 ,EDID_QUIRK_NON_DESKTOP }, - {"FUJ" ,0x1970 ,EDID_QUIRK_NON_DESKTOP }, - {"DEL" ,0x7fce ,EDID_QUIRK_NON_DESKTOP }, - {"SEC" ,0x144a ,EDID_QUIRK_NON_DESKTOP }, - {"AUS" ,0xc102 ,EDID_QUIRK_NON_DESKTOP }, +EDID_QUIRK ('A' ,'C' ,'R' ,0x7fce ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('H' ,'P' ,'N' ,0x3515 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('L' ,'E' ,'N' ,0x0408 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('L' ,'E' ,'N' ,0xb800 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('F' ,'U' ,'J' ,0x1970 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('D' ,'E' ,'L' ,0x7fce ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('S' ,'E' ,'C' ,0x144a ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('A' ,'U' ,'S' ,0xc102 ,EDID_QUIRK_NON_DESKTOP ),/* Sony PlayStation VR Headset */ - {"SNY" ,0x0704 ,EDID_QUIRK_NON_DESKTOP }, +EDID_QUIRK ('S' ,'N' ,'Y' ,0x0704 ,EDID_QUIRK_NON_DESKTOP ),/* Sensics VR Headsets */ - {"SEN" ,0x1019 ,EDID_QUIRK_NON_DESKTOP }, +EDID_QUIRK ('S' ,'E' ,'N' ,0x1019 ,EDID_QUIRK_NON_DESKTOP ),/* OSVR HDK and HDK2 VR Headsets */ - {"SVR" ,0x1019 ,EDID_QUIRK_NON_DESKTOP }, +EDID_QUIRK ('S' ,'V' ,'R' ,0x1019 ,EDID_QUIRK_NON_DESKTOP ), };/* @@ -2090,9 +2096,8 @@ EXPORT_SYMBOL(drm_get_edid);static u32 edid_extract_panel_id (const struct edid *edid) {/* -* In theory we could try to de-obfuscate this like edid_get_quirks() -* does, but it's easier to just deal with a 32-bit number since then -* it can be compared with "==". +* We represent the ID as a 32-bit number so it can easily be compared +* with "==". * * NOTE that we deal with endianness differently for the top half * of this ID than for the bottom half. The bottom half (the product @@ -2197,25 +2202,6 @@ EXPORT_SYMBOL(drm_edid_duplicate);/*** EDID parsing ***/ -/** -* edid_vendor - match a string against EDID's obfuscated vendor field -* @edid: EDID to match -* @vendor: vendor string -* -* Returns true if @vendor is in @edid, false otherwise -*/ -static bool edid_vendor (const struct edid *edid,const char *vendor) -{ -char edid_vendor[3 ]; - - edid_vendor[0 ] = ((edid->mfg_id[0 ] &0x7c ) >>2 ) +'@' ; - edid_vendor[1 ] = (((edid->mfg_id[0 ] &0x3 ) <<3 ) | - ((edid->mfg_id[1 ] &0xe0 ) >>5 )) +'@' ; - edid_vendor[2 ] = (edid->mfg_id[1 ] &0x1f ) +'@' ; - -return !strncmp (edid_vendor, vendor,3 ); -} -/** * edid_get_quirks - return quirk flags for a given EDID * @edid: EDID to process @@ -2224,14 +2210,13 @@ static bool edid_vendor(const struct edid *edid, const char *vendor)*/ static u32 edid_get_quirks (const struct edid *edid) { +u32 panel_id =edid_extract_panel_id (edid);const struct edid_quirk *quirk;int i;for (i =0 ; i <ARRAY_SIZE (edid_quirk_list); i++) { quirk = &edid_quirk_list[i]; - -if (edid_vendor (edid, quirk->vendor) && - (EDID_PRODUCT_ID (edid) == quirk->product_id)) +if (quirk->panel_id == panel_id)return quirk->quirks; }
Signature · 1 line
Jani Nikula, Intel Open Source Graphics Center
Doug Anderson
reviewerRe: [PATCH v4 04/15] drm/edid: Use new encoded panel id style for quirks matching
Hi,
Quoted 14 lines · Jani Nikula
Quoted 12 lines · Douglas Anderson
In the patch ("drm/edid: Allow the querying/working with the panel ID from the EDID") we introduced a different way of working with the panel ID stored in the EDID. Let's use this new way for the quirks code.
Advantages of the new style:
* Smaller data structure size. Saves 4 bytes per panel.
* Iterate through quirks structure with just "==" instead ofstrncmp()
* In-kernel storage is more similar to what's stored in the EDID itself making it easier to grok that they are referring to the same value.
Quoted 6 lines
Quoted 3 lines
The quirk table itself is arguably a bit less readable in the new style but not a ton less and it feels like the above advantages make up for it.
I suppose you could pass vendor as a string to
EDID_QUIRK()to retain better readability?
I would love to, but I couldn't figure out how to do this and have it compile! Notably I need the compiler to be able to do math at compile time to compute the final u32 to store in the init data. I don't think the compiler can dereference strings (even constant strings) and do math on the result at compile time.
I _think_ you could make it work with four-character codes (only specifying 3 characters), AKA single-quoting something like 'AUO' but I think four-character codes are not dealt with in a standard enough way between compilers so they're not allowed in Linux.
If you like it better, I could do something like this:
#define ACR_CODE 'A', 'C', 'R'
#define AUO_CODE 'A', 'U', 'O'
...
...
...then I could refer to the #defines...
Quoted 1 line
Just bikeshedding, really. ;)
I'll take this comment (without any formal tags) as:
* You've seen this patch (and the previous ones) and wouldn't object to it merging.
* You're not planning on any deeper review / testing, so I shouldn't wait for more stuff from you before merging. Please yell if this is not the case. I'm happy to wait but I don't want to wait if no further review is planned.
In general I'm still planning to give this series at least another week for comments before merging. ${SUBJECT} patch also is the only one lacking any type of Review / Ack tags so I'll see if I can find someone to give it something before merging, too.
-Doug
Re: [PATCH v4 04/15] drm/edid: Use new encoded panel id style for quirks matching
Quoted 22 lines · Doug Anderson
Hi,
Quoted 18 lines · Jani Nikula
Quoted 15 lines · Douglas Anderson
In the patch ("drm/edid: Allow the querying/working with the panel ID from the EDID") we introduced a different way of working with the panel ID stored in the EDID. Let's use this new way for the quirks code.
Advantages of the new style:
* Smaller data structure size. Saves 4 bytes per panel.
* Iterate through quirks structure with just "==" instead ofstrncmp()
* In-kernel storage is more similar to what's stored in the EDID itself making it easier to grok that they are referring to the same value.The quirk table itself is arguably a bit less readable in the new style but not a ton less and it feels like the above advantages make up for it.
Quoted 8 lines
Quoted 2 lines
I suppose you could pass vendor as a string to
EDID_QUIRK()to retain better readability?I would love to, but I couldn't figure out how to do this and have it compile! Notably I need the compiler to be able to do math at compile time to compute the final u32 to store in the init data. I don't think the compiler can dereference strings (even constant strings) and do math on the result at compile time.
Ah, right.
Quoted 6 lines
I _think_ you could make it work with four-character codes (only specifying 3 characters), AKA single-quoting something like 'AUO' but I think four-character codes are not dealt with in a standard enough way between compilers so they're not allowed in Linux.
Quoted 8 lines
If you like it better, I could do something like this:
#define
ACR_CODE'A', 'C', 'R'
#defineAUO_CODE'A', 'U', 'O'
...
......then I could refer to the #defines...
Nah.
Quoted 6 lines
Quoted 3 lines
Just bikeshedding, really. ;)
I'll take this comment (without any formal tags) as:
Quoted 7 lines
* You've seen this patch (and the previous ones) and wouldn't object to it merging.
* You're not planning on any deeper review / testing, so I shouldn't wait for more stuff from you before merging. Please yell if this is not the case. I'm happy to wait but I don't want to wait if no further review is planned.
I have now reviewed the ones where my review is relevant, and certainly don't expect me to comment on the rest. ;)
BR,
Jani.
Quoted 9 lines
In general I'm still planning to give this series at least another week for comments before merging. ${SUBJECT} patch also is the only one lacking any type of Review / Ack tags so I'll see if I can find someone to give it something before merging, too.
-Doug
Signature · 1 line
Jani Nikula, Intel Open Source Graphics Center
Re: [PATCH v4 04/15] drm/edid: Use new encoded panel id style for quirks matching
W dniu 14.09.2021 o 20:59, Jani Nikula pisze:
Quoted 21 lines · Doug Anderson
Quoted 20 lines
Hi,
Quoted 16 lines · Jani Nikula
Quoted 15 lines · Douglas Anderson
In the patch ("drm/edid: Allow the querying/working with the panel ID from the EDID") we introduced a different way of working with the panel ID stored in the EDID. Let's use this new way for the quirks code.
Advantages of the new style:
* Smaller data structure size. Saves 4 bytes per panel.
* Iterate through quirks structure with just "==" instead ofstrncmp()
* In-kernel storage is more similar to what's stored in the EDID itself making it easier to grok that they are referring to the same value.The quirk table itself is arguably a bit less readable in the new style but not a ton less and it feels like the above advantages make up for it.
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
I suppose you could pass vendor as a string to
EDID_QUIRK()to retain better readability?I would love to, but I couldn't figure out how to do this and have it compile! Notably I need the compiler to be able to do math at compile time to compute the final u32 to store in the init data. I don't think the compiler can dereference strings (even constant strings) and do math on the result at compile time.
Ah, right.
What about:
+#define drm_edid_encode_panel_id(vend, product_id) \
+ ((((u32)((vend)[0]) - '@') & 0x1f) << 26 | \ + (((u32)((vend)[1]) - '@') & 0x1f) << 21 | \ + (((u32)((vend)[2]) - '@') & 0x1f) << 16 | \
+ ((product_id) & 0xffff))
Regards
Andrzej
Quoted 41 lines
Quoted 6 lines
I _think_ you could make it work with four-character codes (only specifying 3 characters), AKA single-quoting something like 'AUO' but I think four-character codes are not dealt with in a standard enough way between compilers so they're not allowed in Linux.
Quoted 8 lines
If you like it better, I could do something like this:
#define
ACR_CODE'A', 'C', 'R'
#defineAUO_CODE'A', 'U', 'O'
...
......then I could refer to the #defines...
Nah.
Quoted 11 lines
Quoted 2 lines
Just bikeshedding, really. ;)
I'll take this comment (without any formal tags) as:
* You've seen this patch (and the previous ones) and wouldn't object to it merging.
* You're not planning on any deeper review / testing, so I shouldn't wait for more stuff from you before merging. Please yell if this is not the case. I'm happy to wait but I don't want to wait if no further review is planned.
I have now reviewed the ones where my review is relevant, and certainly don't expect me to comment on the rest. ;)
BR,
Jani.Quoted 8 lines
In general I'm still planning to give this series at least another week for comments before merging. ${SUBJECT} patch also is the only one lacking any type of Review / Ack tags so I'll see if I can find someone to give it something before merging, too.
-Doug
Doug Anderson
reviewerRe: [PATCH v4 04/15] drm/edid: Use new encoded panel id style for quirks matching
Hi,
Quoted 36 lines · Andrzej Hajda
W dniu 14.09.2021 o 20:59, Jani Nikula pisze:
Quoted 21 lines · Doug Anderson
Quoted 20 lines
Hi,
Quoted 16 lines · Jani Nikula
Quoted 15 lines · Douglas Anderson
In the patch ("drm/edid: Allow the querying/working with the panel ID from the EDID") we introduced a different way of working with the panel ID stored in the EDID. Let's use this new way for the quirks code.
Advantages of the new style:
* Smaller data structure size. Saves 4 bytes per panel.
* Iterate through quirks structure with just "==" instead ofstrncmp()
* In-kernel storage is more similar to what's stored in the EDID itself making it easier to grok that they are referring to the same value.The quirk table itself is arguably a bit less readable in the new style but not a ton less and it feels like the above advantages make up for it.
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
I suppose you could pass vendor as a string to
EDID_QUIRK()to retain better readability?I would love to, but I couldn't figure out how to do this and have it compile! Notably I need the compiler to be able to do math at compile time to compute the final u32 to store in the init data. I don't think the compiler can dereference strings (even constant strings) and do math on the result at compile time.
Ah, right.
What about:
Review
Quoted 5 lines
(quoted diff) +5
-0+#define drm_edid_encode_panel_id(vend, product_id) \ + ((((u32)((vend)[0]) - '@') & 0x1f) << 26 | \ + (((u32)((vend)[1]) - '@') & 0x1f) << 21 | \ + (((u32)((vend)[2]) - '@') & 0x1f) << 16 | \ + ((product_id) & 0xffff))
Wow, I _swear_ I tried exactly that syntax, but clearly I didn't. It works great and it looks _sooo_ much nicer now. Thanks! I'll send out a v5 shortly with this.
-Doug
Re: [PATCH v4 04/15] drm/edid: Use new encoded panel id style for quirks matching
In reply to Douglas AndersonQuoted 12 lines · Douglas Anderson
In the patch ("drm/edid: Allow the querying/working with the panel ID from the EDID") we introduced a different way of working with the panel ID stored in the EDID. Let's use this new way for the quirks code.
Advantages of the new style:
* Smaller data structure size. Saves 4 bytes per panel.
* Iterate through quirks structure with just "==" instead ofstrncmp()
* In-kernel storage is more similar to what's stored in the EDID itself making it easier to grok that they are referring to the same value.
Quoted 5 lines
The quirk table itself is arguably a bit less readable in the new style but not a ton less and it feels like the above advantages make up for it.
Signed-off-by Douglas Anderson <[email protected]>
Eyeballed the edid_quirk_list, but did not check every bit.
Quoted 259 lines
---
This commit is only compile-tested. I don't have any DP panels that exercise this code. Transition from the old table to the new one was done with a regexp.Changes in v4:
- ("Use new encoded panel id style for quirks matching") new for v4.drivers/gpu/drm/drm_edid.c | 157 +++++++++++++++++-------------------- 1 file changed, 71 insertions(+), 86 deletions(-)drivers/gpu/drm/drm_edid.c +71
-86@@ -100,122 +100,128 @@ struct detailed_mode_closure {#define LEVEL_GTF2 2#define LEVEL_CVT 3 +#define EDID_QUIRK (vend_chr_0, vend_chr_1, vend_chr_2, product_id, _quirks) \ +{ \ + .panel_id = drm_edid_encode_panel_id(vend_chr_0, vend_chr_1, vend_chr_2, \ + product_id), \ + .quirks = _quirks \ +} +static const struct edid_quirk { -char vendor[4 ]; -int product_id; +u32 panel_id;u32 quirks; } edid_quirk_list[] = {/* Acer AL1706 */ - {"ACR" ,44358 ,EDID_QUIRK_PREFER_LARGE_60 }, +EDID_QUIRK ('A' ,'C' ,'R' ,44358 ,EDID_QUIRK_PREFER_LARGE_60 ),/* Acer F51 */ - {"API" ,0x7602 ,EDID_QUIRK_PREFER_LARGE_60 }, +EDID_QUIRK ('A' ,'P' ,'I' ,0x7602 ,EDID_QUIRK_PREFER_LARGE_60 ),/* AEO model 0 reports 8 bpc, but is a 6 bpc panel */ - {"AEO" ,0 ,EDID_QUIRK_FORCE_6BPC }, +EDID_QUIRK ('A' ,'E' ,'O' ,0 ,EDID_QUIRK_FORCE_6BPC ),/* BOE model on HP Pavilion 15-n233sl reports 8 bpc, but is a 6 bpc panel */ - {"BOE" ,0x78b ,EDID_QUIRK_FORCE_6BPC }, +EDID_QUIRK ('B' ,'O' ,'E' ,0x78b ,EDID_QUIRK_FORCE_6BPC ),/* CPT panel of Asus UX303LA reports 8 bpc, but is a 6 bpc panel */ - {"CPT" ,0x17df ,EDID_QUIRK_FORCE_6BPC }, +EDID_QUIRK ('C' ,'P' ,'T' ,0x17df ,EDID_QUIRK_FORCE_6BPC ),/* SDC panel of Lenovo B50-80 reports 8 bpc, but is a 6 bpc panel */ - {"SDC" ,0x3652 ,EDID_QUIRK_FORCE_6BPC }, +EDID_QUIRK ('S' ,'D' ,'C' ,0x3652 ,EDID_QUIRK_FORCE_6BPC ),/* BOE model 0x0771 reports 8 bpc, but is a 6 bpc panel */ - {"BOE" ,0x0771 ,EDID_QUIRK_FORCE_6BPC }, +EDID_QUIRK ('B' ,'O' ,'E' ,0x0771 ,EDID_QUIRK_FORCE_6BPC ),/* Belinea 10 15 55 */ - {"MAX" ,1516 ,EDID_QUIRK_PREFER_LARGE_60 }, - {"MAX" ,0x77e ,EDID_QUIRK_PREFER_LARGE_60 }, +EDID_QUIRK ('M' ,'A' ,'X' ,1516 ,EDID_QUIRK_PREFER_LARGE_60 ), +EDID_QUIRK ('M' ,'A' ,'X' ,0x77e ,EDID_QUIRK_PREFER_LARGE_60 ),/* Envision Peripherals, Inc. EN-7100e */ - {"EPI" ,59264 ,EDID_QUIRK_135_CLOCK_TOO_HIGH }, +EDID_QUIRK ('E' ,'P' ,'I' ,59264 ,EDID_QUIRK_135_CLOCK_TOO_HIGH ),/* Envision EN2028 */ - {"EPI" ,8232 ,EDID_QUIRK_PREFER_LARGE_60 }, +EDID_QUIRK ('E' ,'P' ,'I' ,8232 ,EDID_QUIRK_PREFER_LARGE_60 ),/* Funai Electronics PM36B */ - {"FCM" ,13600 ,EDID_QUIRK_PREFER_LARGE_75 | -EDID_QUIRK_DETAILED_IN_CM }, +EDID_QUIRK ('F' ,'C' ,'M' ,13600 ,EDID_QUIRK_PREFER_LARGE_75 | +EDID_QUIRK_DETAILED_IN_CM ),/* LGD panel of HP zBook 17 G2, eDP 10 bpc, but reports unknown bpc */ - {"LGD" ,764 ,EDID_QUIRK_FORCE_10BPC }, +EDID_QUIRK ('L' ,'G' ,'D' ,764 ,EDID_QUIRK_FORCE_10BPC ),/* LG Philips LCD LP154W01-A5 */ - {"LPL" ,0 ,EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE }, - {"LPL" ,0x2a00 ,EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE }, +EDID_QUIRK ('L' ,'P' ,'L' ,0 ,EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE ), +EDID_QUIRK ('L' ,'P' ,'L' ,0x2a00 ,EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE ),/* Samsung SyncMaster 205BW. Note: irony */ - {"SAM" ,541 ,EDID_QUIRK_DETAILED_SYNC_PP }, +EDID_QUIRK ('S' ,'A' ,'M' ,541 ,EDID_QUIRK_DETAILED_SYNC_PP ),/* Samsung SyncMaster 22[5-6]BW */ - {"SAM" ,596 ,EDID_QUIRK_PREFER_LARGE_60 }, - {"SAM" ,638 ,EDID_QUIRK_PREFER_LARGE_60 }, +EDID_QUIRK ('S' ,'A' ,'M' ,596 ,EDID_QUIRK_PREFER_LARGE_60 ), +EDID_QUIRK ('S' ,'A' ,'M' ,638 ,EDID_QUIRK_PREFER_LARGE_60 ),/* Sony PVM-2541A does up to 12 bpc, but only reports max 8 bpc */ - {"SNY" ,0x2541 ,EDID_QUIRK_FORCE_12BPC }, +EDID_QUIRK ('S' ,'N' ,'Y' ,0x2541 ,EDID_QUIRK_FORCE_12BPC ),/* ViewSonic VA2026w */ - {"VSC" ,5020 ,EDID_QUIRK_FORCE_REDUCED_BLANKING }, +EDID_QUIRK ('V' ,'S' ,'C' ,5020 ,EDID_QUIRK_FORCE_REDUCED_BLANKING ),/* Medion MD 30217 PG */ - {"MED" ,0x7b8 ,EDID_QUIRK_PREFER_LARGE_75 }, +EDID_QUIRK ('M' ,'E' ,'D' ,0x7b8 ,EDID_QUIRK_PREFER_LARGE_75 ),/* Lenovo G50 */ - {"SDC" ,18514 ,EDID_QUIRK_FORCE_6BPC }, +EDID_QUIRK ('S' ,'D' ,'C' ,18514 ,EDID_QUIRK_FORCE_6BPC ),/* Panel in Samsung NP700G7A-S01PL notebook reports 6bpc */ - {"SEC" ,0xd033 ,EDID_QUIRK_FORCE_8BPC }, +EDID_QUIRK ('S' ,'E' ,'C' ,0xd033 ,EDID_QUIRK_FORCE_8BPC ),/* Rotel RSX-1058 forwards sink's EDID but only does HDMI 1.1*/ - {"ETR" ,13896 ,EDID_QUIRK_FORCE_8BPC }, +EDID_QUIRK ('E' ,'T' ,'R' ,13896 ,EDID_QUIRK_FORCE_8BPC ),/* Valve Index Headset */ - {"VLV" ,0x91a8 ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91b0 ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91b1 ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91b2 ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91b3 ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91b4 ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91b5 ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91b6 ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91b7 ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91b8 ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91b9 ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91ba ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91bb ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91bc ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91bd ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91be ,EDID_QUIRK_NON_DESKTOP }, - {"VLV" ,0x91bf ,EDID_QUIRK_NON_DESKTOP }, +EDID_QUIRK ('V' ,'L' ,'V' ,0x91a8 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91b0 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91b1 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91b2 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91b3 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91b4 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91b5 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91b6 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91b7 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91b8 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91b9 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91ba ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91bb ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91bc ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91bd ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91be ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('V' ,'L' ,'V' ,0x91bf ,EDID_QUIRK_NON_DESKTOP ),/* HTC Vive and Vive Pro VR Headsets */ - {"HVR" ,0xaa01 ,EDID_QUIRK_NON_DESKTOP }, - {"HVR" ,0xaa02 ,EDID_QUIRK_NON_DESKTOP }, +EDID_QUIRK ('H' ,'V' ,'R' ,0xaa01 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('H' ,'V' ,'R' ,0xaa02 ,EDID_QUIRK_NON_DESKTOP ),/* Oculus Rift DK1, DK2, CV1 and Rift S VR Headsets */ - {"OVR" ,0x0001 ,EDID_QUIRK_NON_DESKTOP }, - {"OVR" ,0x0003 ,EDID_QUIRK_NON_DESKTOP }, - {"OVR" ,0x0004 ,EDID_QUIRK_NON_DESKTOP }, - {"OVR" ,0x0012 ,EDID_QUIRK_NON_DESKTOP }, +EDID_QUIRK ('O' ,'V' ,'R' ,0x0001 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('O' ,'V' ,'R' ,0x0003 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('O' ,'V' ,'R' ,0x0004 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('O' ,'V' ,'R' ,0x0012 ,EDID_QUIRK_NON_DESKTOP ),/* Windows Mixed Reality Headsets */ - {"ACR" ,0x7fce ,EDID_QUIRK_NON_DESKTOP }, - {"HPN" ,0x3515 ,EDID_QUIRK_NON_DESKTOP }, - {"LEN" ,0x0408 ,EDID_QUIRK_NON_DESKTOP }, - {"LEN" ,0xb800 ,EDID_QUIRK_NON_DESKTOP }, - {"FUJ" ,0x1970 ,EDID_QUIRK_NON_DESKTOP }, - {"DEL" ,0x7fce ,EDID_QUIRK_NON_DESKTOP }, - {"SEC" ,0x144a ,EDID_QUIRK_NON_DESKTOP }, - {"AUS" ,0xc102 ,EDID_QUIRK_NON_DESKTOP }, +EDID_QUIRK ('A' ,'C' ,'R' ,0x7fce ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('H' ,'P' ,'N' ,0x3515 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('L' ,'E' ,'N' ,0x0408 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('L' ,'E' ,'N' ,0xb800 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('F' ,'U' ,'J' ,0x1970 ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('D' ,'E' ,'L' ,0x7fce ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('S' ,'E' ,'C' ,0x144a ,EDID_QUIRK_NON_DESKTOP ), +EDID_QUIRK ('A' ,'U' ,'S' ,0xc102 ,EDID_QUIRK_NON_DESKTOP ),/* Sony PlayStation VR Headset */ - {"SNY" ,0x0704 ,EDID_QUIRK_NON_DESKTOP }, +EDID_QUIRK ('S' ,'N' ,'Y' ,0x0704 ,EDID_QUIRK_NON_DESKTOP ),/* Sensics VR Headsets */ - {"SEN" ,0x1019 ,EDID_QUIRK_NON_DESKTOP }, +EDID_QUIRK ('S' ,'E' ,'N' ,0x1019 ,EDID_QUIRK_NON_DESKTOP ),/* OSVR HDK and HDK2 VR Headsets */ - {"SVR" ,0x1019 ,EDID_QUIRK_NON_DESKTOP }, +EDID_QUIRK ('S' ,'V' ,'R' ,0x1019 ,EDID_QUIRK_NON_DESKTOP ), };/* @@ -2090,9 +2096,8 @@ EXPORT_SYMBOL(drm_get_edid);static u32 edid_extract_panel_id (const struct edid *edid) {/* -* In theory we could try to de-obfuscate this like edid_get_quirks() -* does, but it's easier to just deal with a 32-bit number since then -* it can be compared with "==". +* We represent the ID as a 32-bit number so it can easily be compared +* with "==". * * NOTE that we deal with endianness differently for the top half * of this ID than for the bottom half. The bottom half (the product @@ -2197,25 +2202,6 @@ EXPORT_SYMBOL(drm_edid_duplicate);/*** EDID parsing ***/ -/** -* edid_vendor - match a string against EDID's obfuscated vendor field -* @edid: EDID to match -* @vendor: vendor string -* -* Returns true if @vendor is in @edid, false otherwise -*/ -static bool edid_vendor (const struct edid *edid,const char *vendor) -{ -char edid_vendor[3 ]; - - edid_vendor[0 ] = ((edid->mfg_id[0 ] &0x7c ) >>2 ) +'@' ; - edid_vendor[1 ] = (((edid->mfg_id[0 ] &0x3 ) <<3 ) | - ((edid->mfg_id[1 ] &0xe0 ) >>5 )) +'@' ; - edid_vendor[2 ] = (edid->mfg_id[1 ] &0x1f ) +'@' ; - -return !strncmp (edid_vendor, vendor,3 ); -} -/** * edid_get_quirks - return quirk flags for a given EDID * @edid: EDID to process @@ -2224,14 +2210,13 @@ static bool edid_vendor(const struct edid *edid, const char *vendor)*/ static u32 edid_get_quirks (const struct edid *edid) { +u32 panel_id =edid_extract_panel_id (edid);const struct edid_quirk *quirk;int i;for (i =0 ; i <ARRAY_SIZE (edid_quirk_list); i++) { quirk = &edid_quirk_list[i]; - -if (edid_vendor (edid, quirk->vendor) && - (EDID_PRODUCT_ID (edid) == quirk->product_id)) +if (quirk->panel_id == panel_id)return quirk->quirks; }
Signature · 1 line
Jani Nikula, Intel Open Source Graphics Center
Douglas Anderson
reviewerPATCH v4 5/15 ARM: configs: Everyone who had PANEL_SIMPLE now gets PANEL_EDP
In reply to Douglas AndersonIn the patch ("drm/panel-simple-edp: Split eDP panels out of panel-simple") we will split the PANEL_SIMPLE driver in two. By default let's give everyone who had the old driver enabled the new driver too. If folks want to opt-out of one or the other they always can later.
---
Changes in v4:
- PANEL_SIMPLE_EDP => PANEL_EDP
- Reordered config patches to be before code patch
arch/arm/configs/at91_dt_defconfig | 1 + arch/arm/configs/exynos_defconfig | 1 + arch/arm/configs/imx_v6_v7_defconfig | 1 + arch/arm/configs/lpc32xx_defconfig | 1 + arch/arm/configs/multi_v5_defconfig | 1 + arch/arm/configs/multi_v7_defconfig | 1 + arch/arm/configs/omap2plus_defconfig | 1 + arch/arm/configs/qcom_defconfig | 1 + arch/arm/configs/realview_defconfig | 1 + arch/arm/configs/sama5_defconfig | 1 + arch/arm/configs/shmobile_defconfig | 1 + arch/arm/configs/sunxi_defconfig | 1 + arch/arm/configs/tegra_defconfig | 1 + arch/arm/configs/versatile_defconfig | 1 + arch/arm/configs/vexpress_defconfig | 1 + 15 files changed, 15 insertions(+)
arch/arm/configs/at91_dt_defconfig +1 -0
@@ -144,6 +144,7 @@ CONFIG_VIDEO_MT9V032=m CONFIG_DRM=y CONFIG_DRM_ATMEL_HLCDC=y CONFIG_DRM_PANEL_SIMPLE=y +CONFIG_DRM_PANEL_EDP=y CONFIG_FB_ATMEL=y CONFIG_BACKLIGHT_ATMEL_LCDC=y CONFIG_BACKLIGHT_PWM=y
arch/arm/configs/exynos_defconfig +1 -0
@@ -227,6 +227,7 @@ CONFIG_DRM_EXYNOS_DPI=y CONFIG_DRM_EXYNOS_DSI=y CONFIG_DRM_EXYNOS_HDMI=y CONFIG_DRM_PANEL_SIMPLE=y +CONFIG_DRM_PANEL_EDP=y CONFIG_DRM_PANEL_SAMSUNG_LD9040=y CONFIG_DRM_PANEL_SAMSUNG_S6E63J0X03=y CONFIG_DRM_PANEL_SAMSUNG_S6E8AA0=y
arch/arm/configs/imx_v6_v7_defconfig +1 -0
@@ -280,6 +280,7 @@ CONFIG_DRM=y CONFIG_DRM_MSM=y CONFIG_DRM_PANEL_LVDS=y CONFIG_DRM_PANEL_SIMPLE=y +CONFIG_DRM_PANEL_EDP=y CONFIG_DRM_PANEL_SEIKO_43WVF1G=y CONFIG_DRM_TI_TFP410=y CONFIG_DRM_DW_HDMI_AHB_AUDIO=m
arch/arm/configs/lpc32xx_defconfig +1 -0
@@ -108,6 +108,7 @@ CONFIG_REGULATOR=y CONFIG_REGULATOR_FIXED_VOLTAGE=y CONFIG_DRM=y CONFIG_DRM_PANEL_SIMPLE=y +CONFIG_DRM_PANEL_EDP=y CONFIG_DRM_PL111=y CONFIG_FB_MODE_HELPERS=y CONFIG_BACKLIGHT_CLASS_DEVICE=y
arch/arm/configs/multi_v5_defconfig +1 -0
@@ -194,6 +194,7 @@ CONFIG_VIDEO_ATMEL_ISI=m CONFIG_DRM=y CONFIG_DRM_ATMEL_HLCDC=m CONFIG_DRM_PANEL_SIMPLE=y +CONFIG_DRM_PANEL_EDP=y CONFIG_DRM_ASPEED_GFX=m CONFIG_FB_IMX=y CONFIG_FB_ATMEL=y
arch/arm/configs/multi_v7_defconfig +1 -0
@@ -699,6 +699,7 @@ CONFIG_DRM_TEGRA=y CONFIG_DRM_STM=m CONFIG_DRM_STM_DSI=m CONFIG_DRM_PANEL_SIMPLE=y +CONFIG_DRM_PANEL_EDP=y CONFIG_DRM_PANEL_SAMSUNG_LD9040=m CONFIG_DRM_PANEL_ORISETECH_OTM8009A=m CONFIG_DRM_PANEL_RAYDIUM_RM68200=m
arch/arm/configs/omap2plus_defconfig +1 -0
@@ -511,6 +511,7 @@ CONFIG_OMAP2_DSS_DSI=y CONFIG_DRM_TILCDC=m CONFIG_DRM_PANEL_DSI_CM=m CONFIG_DRM_PANEL_SIMPLE=m +CONFIG_DRM_PANEL_EDP=m CONFIG_DRM_PANEL_LG_LB035Q02=m CONFIG_DRM_PANEL_NEC_NL8048HL11=m CONFIG_DRM_PANEL_SHARP_LS037V7DW01=m
arch/arm/configs/qcom_defconfig +1 -0
@@ -158,6 +158,7 @@ CONFIG_MEDIA_SUPPORT=y CONFIG_DRM=y CONFIG_DRM_MSM=m CONFIG_DRM_PANEL_SIMPLE=y +CONFIG_DRM_PANEL_EDP=y CONFIG_DRM_ANALOGIX_ANX78XX=m CONFIG_FB=y CONFIG_FRAMEBUFFER_CONSOLE=y
arch/arm/configs/realview_defconfig +1 -0
@@ -61,6 +61,7 @@ CONFIG_REGULATOR=y CONFIG_REGULATOR_FIXED_VOLTAGE=y CONFIG_DRM=y CONFIG_DRM_PANEL_SIMPLE=y +CONFIG_DRM_PANEL_EDP=y CONFIG_DRM_DISPLAY_CONNECTOR=y CONFIG_DRM_SIMPLE_BRIDGE=y CONFIG_DRM_PL111=y
arch/arm/configs/sama5_defconfig +1 -0
@@ -160,6 +160,7 @@ CONFIG_VIDEO_MT9V032=m CONFIG_DRM=y CONFIG_DRM_ATMEL_HLCDC=y CONFIG_DRM_PANEL_SIMPLE=y +CONFIG_DRM_PANEL_EDP=y CONFIG_LCD_CLASS_DEVICE=y CONFIG_BACKLIGHT_CLASS_DEVICE=y CONFIG_BACKLIGHT_PWM=y
arch/arm/configs/shmobile_defconfig +1 -0
@@ -129,6 +129,7 @@ CONFIG_VIDEO_ML86V7667=y CONFIG_DRM=y CONFIG_DRM_RCAR_DU=y CONFIG_DRM_PANEL_SIMPLE=y +CONFIG_DRM_PANEL_EDP=y CONFIG_DRM_DISPLAY_CONNECTOR=y CONFIG_DRM_LVDS_CODEC=y CONFIG_DRM_SII902X=y
arch/arm/configs/sunxi_defconfig +1 -0
@@ -108,6 +108,7 @@ CONFIG_DRM_SUN4I_HDMI_CEC=y CONFIG_DRM_SUN8I_DW_HDMI=y CONFIG_DRM_PANEL_LVDS=y CONFIG_DRM_PANEL_SIMPLE=y +CONFIG_DRM_PANEL_EDP=y CONFIG_DRM_SIMPLE_BRIDGE=y CONFIG_DRM_LIMA=y CONFIG_FB_SIMPLE=y
arch/arm/configs/tegra_defconfig +1 -0
@@ -204,6 +204,7 @@ CONFIG_DRM_TEGRA=y CONFIG_DRM_TEGRA_STAGING=y CONFIG_DRM_PANEL_LVDS=y CONFIG_DRM_PANEL_SIMPLE=y +CONFIG_DRM_PANEL_EDP=y CONFIG_DRM_LVDS_CODEC=y # CONFIG_LCD_CLASS_DEVICE is not set CONFIG_BACKLIGHT_CLASS_DEVICE=y
arch/arm/configs/versatile_defconfig +1 -0
@@ -57,6 +57,7 @@ CONFIG_GPIO_PL061=y CONFIG_DRM=y CONFIG_DRM_PANEL_ARM_VERSATILE=y CONFIG_DRM_PANEL_SIMPLE=y +CONFIG_DRM_PANEL_EDP=y CONFIG_DRM_DISPLAY_CONNECTOR=y CONFIG_DRM_SIMPLE_BRIDGE=y CONFIG_DRM_PL111=y
arch/arm/configs/vexpress_defconfig +1 -0
@@ -77,6 +77,7 @@ CONFIG_SENSORS_VEXPRESS=y CONFIG_REGULATOR_VEXPRESS=y CONFIG_DRM=y CONFIG_DRM_PANEL_SIMPLE=y +CONFIG_DRM_PANEL_EDP=y CONFIG_DRM_SII902X=y CONFIG_DRM_PL111=y CONFIG_FB=y
Signature · 1 line
2.33.0.309.g3052b89438-goog
Douglas Anderson
reviewerPATCH v4 6/15 arm64: defconfig: Everyone who had PANEL_SIMPLE now gets PANEL_EDP
In reply to Douglas AndersonIn the patch ("drm/panel-simple-edp: Split eDP panels out of panel-simple") we split the PANEL_SIMPLE driver in 2. Let's enable the new config.
---
Changes in v4:
- PANEL_SIMPLE_EDP => PANEL_EDP
- Reordered config patches to be before code patch
arch/arm64/configs/defconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm64/configs/defconfig +1 -0
@@ -697,6 +697,7 @@ CONFIG_DRM_MSM=m CONFIG_DRM_TEGRA=m CONFIG_DRM_PANEL_LVDS=m CONFIG_DRM_PANEL_SIMPLE=m +CONFIG_DRM_PANEL_EDP=m CONFIG_DRM_PANEL_BOE_TV101WUM_NL6=m CONFIG_DRM_PANEL_MANTIX_MLAF057WE51=m CONFIG_DRM_PANEL_RAYDIUM_RM67191=m
Signature · 1 line
2.33.0.309.g3052b89438-goog
Douglas Anderson
reviewerPATCH v4 7/15 drm/panel-edp: Split eDP panels out of panel-simple
In reply to Douglas AndersonThe panel-simple driver handles way too much. Let's start trying to get a handle on it by splitting out the eDP panels. This patch does this:
1. Start by copying simple-panel verbatim over to a new driver, simple-panel-edp.
2. Rename "panel_simple" to "panel_edp" in the new driver.
3. Keep only panels marked with DRM_MODE_CONNECTOR_eDP in the new driver. Remove those panels from the old driver.
4. Remove all recent "DP AUX bus" stuff from the old driver. The DP AUX bus is only possible on DP panels.
5. Remove all DSI / MIPI related functions from the new driver.
6. Remove bus_format / bus_flags from eDP driver. These things don't seem to make any sense for eDP panels so let's stop filling in made up stuff.
In the end we end up with a bunch of duplicated code for now. Future patches will try to address _some_ of this duplicated code though some of it will be unavoidable.
NOTE: This may not actually move all eDP panels over to the new driver since not all panels were properly marked with DRM_MODE_CONNECTOR_eDP. A future patch will attempt to move wayward panels I could identify but even so there may be some missed.
---
Changes in v4:
- PANEL_SIMPLE_EDP => PANEL_EDP
- Remove "non-eDP" in panel-simple description.
- panel-simple-edp => panel-edp
Changes in v3:
- Split eDP panels patch new for v3.
drivers/gpu/drm/panel/Kconfig | 16 +- drivers/gpu/drm/panel/Makefile | 1 + drivers/gpu/drm/panel/panel-edp.c | 1298 ++++++++++++++++++++++++++ drivers/gpu/drm/panel/panel-simple.c | 573 +----------- 4 files changed, 1322 insertions(+), 566 deletions(-) create mode 100644 drivers/gpu/drm/panel/panel-edp.c
drivers/gpu/drm/panel/Kconfig +14 -2
@@ -77,14 +77,26 @@ config DRM_PANEL_LVDS backlight handling if the panel is attached to a backlight controller. config DRM_PANEL_SIMPLE - tristate "support for simple panels" + tristate "support for simple panels (other than eDP ones)" + depends on OF + depends on BACKLIGHT_CLASS_DEVICE + depends on PM + select VIDEOMODE_HELPERS + help + DRM panel driver for dumb non-eDP panels that need at most a regulator + and a GPIO to be powered up. Optionally a backlight can be attached so + that it can be automatically turned off when the panel goes into a + low power state. + +config DRM_PANEL_EDP + tristate "support for simple Embedded DisplayPort panels" depends on OF depends on BACKLIGHT_CLASS_DEVICE depends on PM select VIDEOMODE_HELPERS select DRM_DP_AUX_BUS help - DRM panel driver for dumb panels that need at most a regulator and + DRM panel driver for dumb eDP panels that need at most a regulator and a GPIO to be powered up. Optionally a backlight can be attached so that it can be automatically turned off when the panel goes into a low power state.
drivers/gpu/drm/panel/Makefile +1 -0
@@ -7,6 +7,7 @@ obj-$(CONFIG_DRM_PANEL_BOE_TV101WUM_NL6) += panel-boe-tv101wum-nl6.o obj-$(CONFIG_DRM_PANEL_DSI_CM) += panel-dsi-cm.o obj-$(CONFIG_DRM_PANEL_LVDS) += panel-lvds.o obj-$(CONFIG_DRM_PANEL_SIMPLE) += panel-simple.o +obj-$(CONFIG_DRM_PANEL_EDP) += panel-edp.o obj-$(CONFIG_DRM_PANEL_ELIDA_KD35T133) += panel-elida-kd35t133.o obj-$(CONFIG_DRM_PANEL_FEIXIN_K101_IM2BA02) += panel-feixin-k101-im2ba02.o obj-$(CONFIG_DRM_PANEL_FEIYANG_FY07024DI26A30D) += panel-feiyang-fy07024di26a30d.o
drivers/gpu/drm/panel/panel-edp.c new file +1298 -0
1,298 lines not on this page · raw message
drivers/gpu/drm/panel/panel-simple.c +9 -564
751 lines not on this page · raw message
Signature · 1 line
2.33.0.309.g3052b89438-goog
Douglas Anderson
reviewerPATCH v4 8/15 drm/panel-edp: Move some wayward panels to the eDP driver
In reply to Douglas AndersonNot all panels in panel-simple were marked what type of panel they were. I searched through ARM/ARM64 Chromebooks or Chromebook-related reference boards that I was aware of and found some panels that needed to be moved. I also skimmed for panels that had no mode and were "big" since it's quite rare to see a small eDP panel. Here's what I found:
* auo,b101ean01 - rk3288-veyron-minnie
* auo,b133htn01 - exynos5800-peach-pi
* auo,b133xtn01 - tegra124-nyan-big
* boe,nv101wxmn51 - rk3399-gru-bob
* innolux,p120zdg-bf1 - sdm845-cheza
* lg,lp079qx1-sp0v - rk3399-evb and similar
* lg,lp097qx1-spa1 - According to commit 0355dde26e52 ("drm/panel:
simple: Add support for LG LP097QX1-SPA1 panel") this is an eDP panel.
* lg,lp129qe - tegra124-venice2
* samsung,lsn122dl01-c01 - According to commit 0330eaf39082 ("drm/panel: simple: Add support for Samsung LSN122DL01-C01 panel") this is an eDP panel.
* samsung,ltn140at29-301 - tegra124-nyan-blaze
* sharp,ld-d5116z01b - According to commit cd5e1cbe1f0a ("drm/panel:
simple: Add support for Sharp LD-D5116Z01B panel") this is an eDP panel.
* sharp,lq123p1jx31 - rk3399-gru-kevin
* starry,kr122ea0sra - rk3399-gru-gru (reference board, not upstream)
I won't promise that I didn't miss a single panel, but that's fairly complete I think.
I'm not sure the full impact of the fact that they didn't have the connector type specified, but at least as of commit 9f069c6fbc72 ("drm/panel: panel-simple: add default connector_type") we may have been accidentally thinking of them as DPI panels. We also would certainly have had a warning. In any case since we don't want to support anything eDP in the old simple-panel driver, we should move these.
---
Changes in v4:
- panel-simple-edp => panel-edp
Changes in v3:
- Move wayward panels patch new for v3.
drivers/gpu/drm/panel/panel-edp.c | 363 ++++++++++++++++++++++++++ drivers/gpu/drm/panel/panel-simple.c | 365 --------------------------- 2 files changed, 363 insertions(+), 365 deletions(-)
drivers/gpu/drm/panel/panel-edp.c +363 -0
@@ -723,6 +723,28 @@ static void panel_edp_shutdown(struct device *dev)drm_panel_unprepare (&panel->base); } +static const struct display_timing auo_b101ean01_timing = { + .pixelclock = {65300000 ,72500000 ,75000000 }, + .hactive = {1280 ,1280 ,1280 }, + .hfront_porch = {18 ,119 ,119 }, + .hback_porch = {21 ,21 ,21 }, + .hsync_len = {32 ,32 ,32 }, + .vactive = {800 ,800 ,800 }, + .vfront_porch = {4 ,4 ,4 }, + .vback_porch = {8 ,8 ,8 }, + .vsync_len = {18 ,20 ,20 }, +}; + +static const struct panel_desc auo_b101ean01 = { + .timings = &auo_b101ean01_timing, + .num_timings =1 , + .bpc =6 , + .size = { + .width =217 , + .height =136 , + }, +}; +static const struct drm_display_mode auo_b116xak01_mode = { .clock =69300 , .hdisplay =1366 ,
@@ -802,6 +824,55 @@ static const struct panel_desc auo_b133han05 = { }, }; +static const struct drm_display_mode auo_b133htn01_mode = { + .clock =150660 , + .hdisplay =1920 , + .hsync_start =1920 +172 , + .hsync_end =1920 +172 +80 , + .htotal =1920 +172 +80 +60 , + .vdisplay =1080 , + .vsync_start =1080 +25 , + .vsync_end =1080 +25 +10 , + .vtotal =1080 +25 +10 +10 , +}; + +static const struct panel_desc auo_b133htn01 = { + .modes = &auo_b133htn01_mode, + .num_modes =1 , + .bpc =6 , + .size = { + .width =293 , + .height =165 , + }, + .delay = { + .prepare =105 , + .enable =20 , + .unprepare =50 , + }, +}; + +static const struct drm_display_mode auo_b133xtn01_mode = { + .clock =69500 , + .hdisplay =1366 , + .hsync_start =1366 +48 , + .hsync_end =1366 +48 +32 , + .htotal =1366 +48 +32 +20 , + .vdisplay =768 , + .vsync_start =768 +3 , + .vsync_end =768 +3 +6 , + .vtotal =768 +3 +6 +13 , +}; + +static const struct panel_desc auo_b133xtn01 = { + .modes = &auo_b133xtn01_mode, + .num_modes =1 , + .bpc =6 , + .size = { + .width =293 , + .height =165 , + }, +}; +static const struct drm_display_mode auo_b140han06_mode = { .clock =141000 , .hdisplay =1920 ,
@@ -829,6 +900,46 @@ static const struct panel_desc auo_b140han06 = { }, }; +static const struct drm_display_mode boe_nv101wxmn51_modes[] = { + { + .clock =71900 , + .hdisplay =1280 , + .hsync_start =1280 +48 , + .hsync_end =1280 +48 +32 , + .htotal =1280 +48 +32 +80 , + .vdisplay =800 , + .vsync_start =800 +3 , + .vsync_end =800 +3 +5 , + .vtotal =800 +3 +5 +24 , + }, + { + .clock =57500 , + .hdisplay =1280 , + .hsync_start =1280 +48 , + .hsync_end =1280 +48 +32 , + .htotal =1280 +48 +32 +80 , + .vdisplay =800 , + .vsync_start =800 +3 , + .vsync_end =800 +3 +5 , + .vtotal =800 +3 +5 +24 , + }, +}; + +static const struct panel_desc boe_nv101wxmn51 = { + .modes = boe_nv101wxmn51_modes, + .num_modes =ARRAY_SIZE (boe_nv101wxmn51_modes), + .bpc =8 , + .size = { + .width =217 , + .height =136 , + }, + .delay = { + .prepare =210 , + .enable =50 , + .unprepare =160 , + }, +}; +static const struct drm_display_mode boe_nv110wtm_n61_modes[] = { { .clock =207800 ,
@@ -1027,6 +1138,33 @@ static const struct panel_desc innolux_n125hce_gn1 = { }, }; +static const struct drm_display_mode innolux_p120zdg_bf1_mode = { + .clock =206016 , + .hdisplay =2160 , + .hsync_start =2160 +48 , + .hsync_end =2160 +48 +32 , + .htotal =2160 +48 +32 +80 , + .vdisplay =1440 , + .vsync_start =1440 +3 , + .vsync_end =1440 +3 +10 , + .vtotal =1440 +3 +10 +27 , + .flags =DRM_MODE_FLAG_PHSYNC |DRM_MODE_FLAG_PVSYNC , +}; + +static const struct panel_desc innolux_p120zdg_bf1 = { + .modes = &innolux_p120zdg_bf1_mode, + .num_modes =1 , + .bpc =8 , + .size = { + .width =254 , + .height =169 , + }, + .delay = { + .hpd_absent_delay =200 , + .unprepare =500 , + }, +}; +static const struct drm_display_mode ivo_m133nwf4_r0_mode = { .clock =138778 , .hdisplay =1920 ,
@@ -1080,6 +1218,49 @@ static const struct panel_desc kingdisplay_kd116n21_30nv_a010 = { }, }; +static const struct drm_display_mode lg_lp079qx1_sp0v_mode = { + .clock =200000 , + .hdisplay =1536 , + .hsync_start =1536 +12 , + .hsync_end =1536 +12 +16 , + .htotal =1536 +12 +16 +48 , + .vdisplay =2048 , + .vsync_start =2048 +8 , + .vsync_end =2048 +8 +4 , + .vtotal =2048 +8 +4 +8 , + .flags =DRM_MODE_FLAG_NVSYNC |DRM_MODE_FLAG_NHSYNC , +}; + +static const struct panel_desc lg_lp079qx1_sp0v = { + .modes = &lg_lp079qx1_sp0v_mode, + .num_modes =1 , + .size = { + .width =129 , + .height =171 , + }, +}; + +static const struct drm_display_mode lg_lp097qx1_spa1_mode = { + .clock =205210 , + .hdisplay =2048 , + .hsync_start =2048 +150 , + .hsync_end =2048 +150 +5 , + .htotal =2048 +150 +5 +5 , + .vdisplay =1536 , + .vsync_start =1536 +3 , + .vsync_end =1536 +3 +1 , + .vtotal =1536 +3 +1 +9 , +}; + +static const struct panel_desc lg_lp097qx1_spa1 = { + .modes = &lg_lp097qx1_spa1_mode, + .num_modes =1 , + .size = { + .width =208 , + .height =147 , + }, +}; +static const struct drm_display_mode lg_lp120up1_mode = { .clock =162300 , .hdisplay =1920 ,
@@ -1102,6 +1283,28 @@ static const struct panel_desc lg_lp120up1 = { }, }; +static const struct drm_display_mode lg_lp129qe_mode = { + .clock =285250 , + .hdisplay =2560 , + .hsync_start =2560 +48 , + .hsync_end =2560 +48 +32 , + .htotal =2560 +48 +32 +80 , + .vdisplay =1700 , + .vsync_start =1700 +3 , + .vsync_end =1700 +3 +10 , + .vtotal =1700 +3 +10 +36 , +}; + +static const struct panel_desc lg_lp129qe = { + .modes = &lg_lp129qe_mode, + .num_modes =1 , + .bpc =8 , + .size = { + .width =272 , + .height =181 , + }, +}; +static const struct drm_display_mode neweast_wjfh116008a_modes[] = { { .clock =138500 ,
@@ -1143,8 +1346,132 @@ static const struct panel_desc neweast_wjfh116008a = { }, }; +static const struct drm_display_mode samsung_lsn122dl01_c01_mode = { + .clock =271560 , + .hdisplay =2560 , + .hsync_start =2560 +48 , + .hsync_end =2560 +48 +32 , + .htotal =2560 +48 +32 +80 , + .vdisplay =1600 , + .vsync_start =1600 +2 , + .vsync_end =1600 +2 +5 , + .vtotal =1600 +2 +5 +57 , +}; + +static const struct panel_desc samsung_lsn122dl01_c01 = { + .modes = &samsung_lsn122dl01_c01_mode, + .num_modes =1 , + .size = { + .width =263 , + .height =164 , + }, +}; + +static const struct drm_display_mode samsung_ltn140at29_301_mode = { + .clock =76300 , + .hdisplay =1366 , + .hsync_start =1366 +64 , + .hsync_end =1366 +64 +48 , + .htotal =1366 +64 +48 +128 , + .vdisplay =768 , + .vsync_start =768 +2 , + .vsync_end =768 +2 +5 , + .vtotal =768 +2 +5 +17 , +}; + +static const struct panel_desc samsung_ltn140at29_301 = { + .modes = &samsung_ltn140at29_301_mode, + .num_modes =1 , + .bpc =6 , + .size = { + .width =320 , + .height =187 , + }, +}; + +static const struct drm_display_mode sharp_ld_d5116z01b_mode = { + .clock =168480 , + .hdisplay =1920 , + .hsync_start =1920 +48 , + .hsync_end =1920 +48 +32 , + .htotal =1920 +48 +32 +80 , + .vdisplay =1280 , + .vsync_start =1280 +3 , + .vsync_end =1280 +3 +10 , + .vtotal =1280 +3 +10 +57 , + .flags =DRM_MODE_FLAG_PHSYNC |DRM_MODE_FLAG_PVSYNC , +}; + +static const struct panel_desc sharp_ld_d5116z01b = { + .modes = &sharp_ld_d5116z01b_mode, + .num_modes =1 , + .bpc =8 , + .size = { + .width =260 , + .height =120 , + }, +}; + +static const struct display_timing sharp_lq123p1jx31_timing = { + .pixelclock = {252750000 ,252750000 ,266604720 }, + .hactive = {2400 ,2400 ,2400 }, + .hfront_porch = {48 ,48 ,48 }, + .hback_porch = {80 ,80 ,84 }, + .hsync_len = {32 ,32 ,32 }, + .vactive = {1600 ,1600 ,1600 }, + .vfront_porch = {3 ,3 ,3 }, + .vback_porch = {33 ,33 ,120 }, + .vsync_len = {10 ,10 ,10 }, + .flags =DISPLAY_FLAGS_VSYNC_LOW |DISPLAY_FLAGS_HSYNC_LOW , +}; + +static const struct panel_desc sharp_lq123p1jx31 = { + .timings = &sharp_lq123p1jx31_timing, + .num_timings =1 , + .bpc =8 , + .size = { + .width =259 , + .height =173 , + }, + .delay = { + .prepare =110 , + .enable =50 , + .unprepare =550 , + }, +}; + +static const struct drm_display_mode starry_kr122ea0sra_mode = { + .clock =147000 , + .hdisplay =1920 , + .hsync_start =1920 +16 , + .hsync_end =1920 +16 +16 , + .htotal =1920 +16 +16 +32 , + .vdisplay =1200 , + .vsync_start =1200 +15 , + .vsync_end =1200 +15 +2 , + .vtotal =1200 +15 +2 +18 , + .flags =DRM_MODE_FLAG_NVSYNC |DRM_MODE_FLAG_NHSYNC , +}; + +static const struct panel_desc starry_kr122ea0sra = { + .modes = &starry_kr122ea0sra_mode, + .num_modes =1 , + .size = { + .width =263 , + .height =164 , + }, + .delay = { + .prepare =10 +200 , + .enable =50 , + .unprepare =10 +500 , + }, +}; +static const struct of_device_id platform_of_match[] = { { + .compatible ="auo,b101ean01" , + .data = &auo_b101ean01, + }, { .compatible ="auo,b116xa01" , .data = &auo_b116xak01, }, {
@@ -1153,9 +1480,18 @@ static const struct of_device_id platform_of_match[] = { }, { .compatible = "auo,b133han05", .data = &auo_b133han05, + }, { + .compatible = "auo,b133htn01", + .data = &auo_b133htn01, + }, { + .compatible = "auo,b133xtn01", + .data = &auo_b133xtn01, }, { .compatible = "auo,b140han06", .data = &auo_b140han06, + }, { + .compatible = "boe,nv101wxmn51", + .data = &boe_nv101wxmn51, }, { .compatible = "boe,nv110wtm-n61", .data = &boe_nv110wtm_n61,
@@ -1177,18 +1513,45 @@ static const struct of_device_id platform_of_match[] = { }, { .compatible = "innolux,n125hce-gn1", .data = &innolux_n125hce_gn1, + }, { + .compatible = "innolux,p120zdg-bf1", + .data = &innolux_p120zdg_bf1, }, { .compatible = "ivo,m133nwf4-r0", .data = &ivo_m133nwf4_r0, }, { .compatible = "kingdisplay,kd116n21-30nv-a010", .data = &kingdisplay_kd116n21_30nv_a010, + }, { + .compatible = "lg,lp079qx1-sp0v", + .data = &lg_lp079qx1_sp0v, + }, { + .compatible = "lg,lp097qx1-spa1", + .data = &lg_lp097qx1_spa1, }, { .compatible = "lg,lp120up1", .data = &lg_lp120up1, + }, { + .compatible = "lg,lp129qe", + .data = &lg_lp129qe, }, { .compatible = "neweast,wjfh116008a", .data = &neweast_wjfh116008a, + }, { + .compatible = "samsung,lsn122dl01-c01", + .data = &samsung_lsn122dl01_c01, + }, { + .compatible = "samsung,ltn140at29-301", + .data = &samsung_ltn140at29_301, + }, { + .compatible = "sharp,ld-d5116z01b", + .data = &sharp_ld_d5116z01b, + }, { + .compatible = "sharp,lq123p1jx31", + .data = &sharp_lq123p1jx31, + }, { + .compatible = "starry,kr122ea0sra", + .data = &starry_kr122ea0sra, }, { /* sentinel */ }
drivers/gpu/drm/panel/panel-simple.c +0 -365
476 lines not on this page · raw message
Signature · 1 line
2.33.0.309.g3052b89438-goog
Douglas Anderson
reviewerPATCH v4 9/15 drm/panel-simple: Non-eDP panels don't need "HPD" handling
In reply to Douglas AndersonAll of the "HPD" handling added to panel-simple recently was for eDP panels. Remove it from panel-simple now that panel-edp handles eDP panels. The "prepare_to_enable" delay only makes sense in the context of HPD, so remove it too. No non-eDP panels used it anyway.
---
Changes in v4:
- panel-simple-edp => panel-edp
Changes in v3:
- ("Non-eDP panels don't need "HPD" handling") new for v3.
drivers/gpu/drm/panel/panel-simple.c | 134 +-------------------------- 1 file changed, 4 insertions(+), 130 deletions(-)
drivers/gpu/drm/panel/panel-simple.c +4 -130
@@ -23,7 +23,6 @@#include <linux/delay.h> #include <linux/gpio/consumer.h> -#include <linux/iopoll.h> #include <linux/module.h> #include <linux/of_platform.h> #include <linux/platform_device.h>
@@ -92,44 +91,6 @@ struct panel_desc {*/ unsigned int prepare; -/** -* @delay.hpd_absent_delay: Time to wait if HPD isn't hooked up. -* -* Add this to the prepare delay if we know Hot Plug Detect -* isn't used. -*/ -unsigned int hpd_absent_delay; - -/** -* @delay.prepare_to_enable: Time between prepare and enable. -* -* The minimum time, in milliseconds, that needs to have passed -* between when prepare finished and enable may begin. If at -* enable time less time has passed since prepare finished, -* the driver waits for the remaining time. -* -* If a fixed enable delay is also specified, we'll start -* counting before delaying for the fixed delay. -* -* If a fixed prepare delay is also specified, we won't start -* counting until after the fixed delay. We can't overlap this -* fixed delay with the min time because the fixed delay -* doesn't happen at the end of the function if a HPD GPIO was -* specified. -* -* In other words: -* prepare() -* ... -* // do fixed prepare delay -* // wait for HPD GPIO if applicable -* // start counting for prepare_to_enable -* -* enable() -* // do fixed enable delay -* // enforce prepare_to_enable min time -*/ -unsigned int prepare_to_enable; -/** * @delay.enable: Time for the panel to display a valid frame. *
@@ -174,7 +135,6 @@ struct panel_desc {struct panel_simple {struct drm_panel base;bool enabled; -bool no_hpd;bool prepared;
@@ -187,7 +147,6 @@ struct panel_simple {struct i2c_adapter *ddc;struct gpio_desc *enable_gpio; -struct gpio_desc *hpd_gpio;struct edid *edid;
@@ -371,30 +330,10 @@ static int panel_simple_unprepare(struct drm_panel *panel)return 0 ; } -static int panel_simple_get_hpd_gpio (struct device *dev,struct panel_simple *p) -{ -int err; - - p->hpd_gpio =devm_gpiod_get_optional (dev,"hpd" ,GPIOD_IN ); -if (IS_ERR (p->hpd_gpio)) { - err =PTR_ERR (p->hpd_gpio); - -if (err != -EPROBE_DEFER ) -dev_err (dev,"failed to get 'hpd' GPIO: %d\n" , err); - -return err; - } - -return 0 ; -} - -static int panel_simple_prepare_once (struct panel_simple *p) +static int panel_simple_resume (struct device *dev) { -struct device *dev = p->base.dev; -unsigned int delay; +struct panel_simple *p =dev_get_drvdata (dev);int err; -int hpd_asserted; -unsigned long hpd_wait_us;panel_simple_wait (p->unprepared_time, p->desc->delay.unprepare);
@@ -406,68 +345,12 @@ static int panel_simple_prepare_once(struct panel_simple *p)gpiod_set_value_cansleep (p->enable_gpio,1 ); - delay = p->desc->delay.prepare; -if (p->no_hpd) - delay += p->desc->delay.hpd_absent_delay; -if (delay) -msleep (delay); - -if (p->hpd_gpio) { -if (p->desc->delay.hpd_absent_delay) - hpd_wait_us = p->desc->delay.hpd_absent_delay *1000UL ; -else - hpd_wait_us =2000000 ; - - err =readx_poll_timeout (gpiod_get_value_cansleep, p->hpd_gpio, - hpd_asserted, hpd_asserted, -1000 , hpd_wait_us); -if (hpd_asserted <0 ) - err = hpd_asserted; - -if (err) { -if (err != -ETIMEDOUT ) -dev_err (dev, -"error waiting for hpd GPIO: %d\n" , err); - goto error; - } - } +if (p->desc->delay.prepare) +msleep (p->desc->delay.prepare); p->prepared_time =ktime_get ();return 0 ; - -error: -gpiod_set_value_cansleep (p->enable_gpio,0 ); -regulator_disable (p->supply); - p->unprepared_time =ktime_get (); - -return err; -} - -/* -* Some panels simply don't always come up and need to be power cycled to -* work properly. We'll allow for a handful of retries. -*/ -#define MAX_PANEL_PREPARE_TRIES 5 - -static int panel_simple_resume (struct device *dev) -{ -struct panel_simple *p =dev_get_drvdata (dev); -int ret; -int try; - -for (try =0 ; try <MAX_PANEL_PREPARE_TRIES ; try++) { - ret =panel_simple_prepare_once (p); -if (ret != -ETIMEDOUT ) -break ; - } - -if (ret == -ETIMEDOUT ) -dev_err (dev,"Prepare timeout after %d tries\n" , try); -else if (try) -dev_warn (dev,"Prepare needed %d retries\n" , try); - -return ret; }static int panel_simple_prepare (struct drm_panel *panel)
@@ -500,8 +383,6 @@ static int panel_simple_enable(struct drm_panel *panel)if (p->desc->delay.enable)msleep (p->desc->delay.enable); -panel_simple_wait (p->prepared_time, p->desc->delay.prepare_to_enable); - p->enabled = true;return 0 ;
@@ -674,13 +555,6 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc) panel->prepared_time =0 ; panel->desc = desc; - panel->no_hpd =of_property_read_bool (dev->of_node,"no-hpd" ); -if (!panel->no_hpd) { - err =panel_simple_get_hpd_gpio (dev, panel); -if (err) -return err; - } - panel->supply =devm_regulator_get (dev,"power" );if (IS_ERR (panel->supply))return PTR_ERR (panel->supply);
Signature · 1 line
2.33.0.309.g3052b89438-goog
Douglas Anderson
reviewerPATCH v4 10/15 drm/panel-edp: Split the delay structure out
In reply to Douglas AndersonIn the case where we can read an EDID for a panel the only part of the panel description that can't be found directly from the EDID is the description of the delays. Let's break the delay structure out so that we can specify just the delays for panels that are detected by EDID.
This is simple code motion. No functional change is intended.
---
Changes in v4:
- panel-simple-edp => panel-edp
Changes in v3:
- Split the delay structure out patch just on eDP now.
drivers/gpu/drm/panel/panel-edp.c | 159 +++++++++++++++--------------- 1 file changed, 82 insertions(+), 77 deletions(-)
drivers/gpu/drm/panel/panel-edp.c +82 -77
@@ -40,6 +40,87 @@#include <drm/drm_dp_helper.h> #include <drm/drm_panel.h> +/** +* struct panel_delay - Describes delays for a simple panel. +*/ +struct panel_delay { +/** +* @prepare: Time for the panel to become ready. +* +* The time (in milliseconds) that it takes for the panel to +* become ready and start receiving video data +*/ +unsigned int prepare; + +/** +* @hpd_absent_delay: Time to wait if HPD isn't hooked up. +* +* Add this to the prepare delay if we know Hot Plug Detect +* isn't used. +*/ +unsigned int hpd_absent_delay; + +/** +* @prepare_to_enable: Time between prepare and enable. +* +* The minimum time, in milliseconds, that needs to have passed +* between when prepare finished and enable may begin. If at +* enable time less time has passed since prepare finished, +* the driver waits for the remaining time. +* +* If a fixed enable delay is also specified, we'll start +* counting before delaying for the fixed delay. +* +* If a fixed prepare delay is also specified, we won't start +* counting until after the fixed delay. We can't overlap this +* fixed delay with the min time because the fixed delay +* doesn't happen at the end of the function if a HPD GPIO was +* specified. +* +* In other words: +* prepare() +* ... +* // do fixed prepare delay +* // wait for HPD GPIO if applicable +* // start counting for prepare_to_enable +* +* enable() +* // do fixed enable delay +* // enforce prepare_to_enable min time +*/ +unsigned int prepare_to_enable; + +/** +* @enable: Time for the panel to display a valid frame. +* +* The time (in milliseconds) that it takes for the panel to +* display the first valid frame after starting to receive +* video data. +*/ +unsigned int enable; + +/** +* @disable: Time for the panel to turn the display off. +* +* The time (in milliseconds) that it takes for the panel to +* turn the display off (no content is visible). +*/ +unsigned int disable; + +/** +* @unprepare: Time to power down completely. +* +* The time (in milliseconds) that it takes for the panel +* to power itself down completely. +* +* This time is used to prevent a future "prepare" from +* starting until at least this many milliseconds has passed. +* If at prepare time less time has passed since unprepare +* finished, the driver waits for the remaining time. +*/ +unsigned int unprepare; +}; +/** * struct panel_desc - Describes a simple panel. */
@@ -84,83 +165,7 @@ struct panel_desc { } size;/** @delay: Structure containing various delay values for this panel. */ -struct { -/** -* @delay.prepare: Time for the panel to become ready. -* -* The time (in milliseconds) that it takes for the panel to -* become ready and start receiving video data -*/ -unsigned int prepare; - -/** -* @delay.hpd_absent_delay: Time to wait if HPD isn't hooked up. -* -* Add this to the prepare delay if we know Hot Plug Detect -* isn't used. -*/ -unsigned int hpd_absent_delay; - -/** -* @delay.prepare_to_enable: Time between prepare and enable. -* -* The minimum time, in milliseconds, that needs to have passed -* between when prepare finished and enable may begin. If at -* enable time less time has passed since prepare finished, -* the driver waits for the remaining time. -* -* If a fixed enable delay is also specified, we'll start -* counting before delaying for the fixed delay. -* -* If a fixed prepare delay is also specified, we won't start -* counting until after the fixed delay. We can't overlap this -* fixed delay with the min time because the fixed delay -* doesn't happen at the end of the function if a HPD GPIO was -* specified. -* -* In other words: -* prepare() -* ... -* // do fixed prepare delay -* // wait for HPD GPIO if applicable -* // start counting for prepare_to_enable -* -* enable() -* // do fixed enable delay -* // enforce prepare_to_enable min time -*/ -unsigned int prepare_to_enable; - -/** -* @delay.enable: Time for the panel to display a valid frame. -* -* The time (in milliseconds) that it takes for the panel to -* display the first valid frame after starting to receive -* video data. -*/ -unsigned int enable; - -/** -* @delay.disable: Time for the panel to turn the display off. -* -* The time (in milliseconds) that it takes for the panel to -* turn the display off (no content is visible). -*/ -unsigned int disable; - -/** -* @delay.unprepare: Time to power down completely. -* -* The time (in milliseconds) that it takes for the panel -* to power itself down completely. -* -* This time is used to prevent a future "prepare" from -* starting until at least this many milliseconds has passed. -* If at prepare time less time has passed since unprepare -* finished, the driver waits for the remaining time. -*/ -unsigned int unprepare; - } delay; +struct panel_delay delay; };struct panel_edp {
Signature · 1 line
2.33.0.309.g3052b89438-goog
Douglas Anderson
reviewerPATCH v4 11/15 drm/panel-edp: Better describe eDP panel delays
In reply to Douglas AndersonNow that the eDP panel driver only handles eDP panels we can make better sense of the delays here. Let's describe them in terms of the standard eDP timing diagram from the eDP spec.
As part of this, it becomes pretty clear that some eDP panels have too long of a "hpd_reliable_delay". This used to be the "prepare" delay. It's the fixed delay that we do in the panel driver after powering on our panel before we look at the HPD signal. To understand this better, first realize that there could be 3 paths we follow depending on how HPD is hooked up. Let's walk through them:
1. HPD is handled by the eDP controller driver. Until "recently" (commit 48834e6084f1 ("drm/panel-simple: Support hpd-gpios for delaying prepare()") in May 2020) this was the only supported way. This is supposed to be when the controller driver gets HPD straight to a dedicated pin. In this case the controller driver should be waiting for HPD in its pre_enable() routine which should be called right after the panel's prepare() function is called. That means that the old "prepare" delay was only needed as a delay after powering the panel but before looking at HPD.
2. HPD is handled via hpd-gpios in the panel. This is much like #1 but much easier to follow since all the handling is in the panel driver.
3. The no-hpd case. This is also easy to follow.
In any case, even though it seems like some old panel data was using this incorrectly, let's not touch the old data structures but we'll add a note indicating that something seems off.
---
Changes in v4:
- panel-simple-edp => panel-edp
Changes in v3:
- ("Better describe eDP panel delays") new for v3.
drivers/gpu/drm/panel/panel-edp.c | 82 ++++++++++++++++++++----------- 1 file changed, 53 insertions(+), 29 deletions(-)
drivers/gpu/drm/panel/panel-edp.c +53 -29
@@ -45,20 +45,28 @@*/ struct panel_delay {/** -* @prepare: Time for the panel to become ready. +* @hpd_reliable: Time for HPD to be reliable * -* The time (in milliseconds) that it takes for the panel to -* become ready and start receiving video data +* The time (in milliseconds) that it takes after powering the panel +* before the HPD signal is reliable. Ideally this is 0 but some panels, +* board designs, or bad pulldown configs can cause a glitch here. +* +* NOTE: on some old panel data this number appers to be much too big. +* Presumably some old panels simply didn't have HPD hooked up and put +* the hpd_absent here because this field predates the +* hpd_absent. While that works, it's non-ideal. */ -unsigned int prepare; +unsigned int hpd_reliable;/** -* @hpd_absent_delay: Time to wait if HPD isn't hooked up. +* @hpd_absent: Time to wait if HPD isn't hooked up. * -* Add this to the prepare delay if we know Hot Plug Detect -* isn't used. +* Add this to the prepare delay if we know Hot Plug Detect isn't used. +* +* This is T3-max on eDP timing diagrams or the delay from power on +* until HPD is guaranteed to be asserted. */ -unsigned int hpd_absent_delay; +unsigned int hpd_absent;/** * @prepare_to_enable: Time between prepare and enable.
@@ -87,6 +95,10 @@ struct panel_delay {* enable() * // do fixed enable delay * // enforce prepare_to_enable min time +* +* This is not specified in a standard way on eDP timing diagrams. +* It is effectively the time from HPD going high till you can +* turn on the backlight. */ unsigned int prepare_to_enable;
@@ -96,6 +108,10 @@ struct panel_delay {* The time (in milliseconds) that it takes for the panel to * display the first valid frame after starting to receive * video data. +* +* This is (T6-min + max(T7-max, T8-min)) on eDP timing diagrams or +* the delay after link training finishes until we can turn the +* backlight on and see valid data. */ unsigned int enable;
@@ -104,6 +120,9 @@ struct panel_delay {* * The time (in milliseconds) that it takes for the panel to * turn the display off (no content is visible). +* +* This is T9-min (delay from backlight off to end of valid video +* data) on eDP timing diagrams. It is not common to set. */ unsigned int disable;
@@ -117,6 +136,8 @@ struct panel_delay {* starting until at least this many milliseconds has passed. * If at prepare time less time has passed since unprepare * finished, the driver waits for the remaining time. +* +* This is T12-min on eDP timing diagrams. */ unsigned int unprepare; };
@@ -400,15 +421,15 @@ static int panel_edp_prepare_once(struct panel_edp *p)gpiod_set_value_cansleep (p->enable_gpio,1 ); - delay = p->desc->delay.prepare; + delay = p->desc->delay.hpd_reliable;if (p->no_hpd) - delay += p->desc->delay.hpd_absent_delay; + delay += p->desc->delay.hpd_absent;if (delay)msleep (delay);if (p->hpd_gpio) { -if (p->desc->delay.hpd_absent_delay) - hpd_wait_us = p->desc->delay.hpd_absent_delay *1000UL ; +if (p->desc->delay.hpd_absent) + hpd_wait_us = p->desc->delay.hpd_absent *1000UL ;else hpd_wait_us =2000000 ;
@@ -772,7 +793,7 @@ static const struct panel_desc auo_b116xak01 = { .height = 144, }, .delay = { - .hpd_absent_delay = 200, + .hpd_absent = 200, }, };
@@ -823,7 +844,7 @@ static const struct panel_desc auo_b133han05 = { .height = 165, }, .delay = { - .prepare = 100, + .hpd_reliable = 100, .enable = 20, .unprepare = 50, },
@@ -850,7 +871,7 @@ static const struct panel_desc auo_b133htn01 = { .height = 165, }, .delay = { - .prepare = 105, + .hpd_reliable = 105, .enable = 20, .unprepare = 50, },
@@ -899,7 +920,7 @@ static const struct panel_desc auo_b140han06 = { .height = 174, }, .delay = { - .prepare = 100, + .hpd_reliable = 100, .enable = 20, .unprepare = 50, },
@@ -939,7 +960,8 @@ static const struct panel_desc boe_nv101wxmn51 = { .height = 136, }, .delay = { - .prepare = 210, +/* TODO: should be hpd-absent and no-hpd should be set? */ + .hpd_reliable = 210, .enable = 50, .unprepare = 160, },
@@ -981,7 +1003,7 @@ static const struct panel_desc boe_nv110wtm_n61 = { .height = 155, }, .delay = { - .hpd_absent_delay = 200, + .hpd_absent = 200, .prepare_to_enable = 80, .enable = 50, .unprepare = 500,
@@ -1018,14 +1040,14 @@ static const struct panel_desc boe_nv133fhm_n61 = {* was until the TCON data download was complete. On * one system this was measured at 8 ms. We'll put 15 ms * in the prepare delay just to be safe and take it away -* from the hpd_absent_delay (which would otherwise be 200 ms) +* from the hpd_absent (which would otherwise be 200 ms) * to handle this. That means: * - If HPD isn't hooked up you still have 200 ms delay. * - If HPD is hooked up we won't try to look at it for the * first 15 ms. */ - .prepare = 15, - .hpd_absent_delay = 185, + .hpd_reliable = 15, + .hpd_absent = 185, .unprepare = 500, },
@@ -1054,7 +1076,8 @@ static const struct panel_desc boe_nv140fhmn49 = { .height = 174, }, .delay = { - .prepare = 210, +/* TODO: should be hpd-absent and no-hpd should be set? */ + .hpd_reliable = 210, .enable = 50, .unprepare = 160, },
@@ -1082,7 +1105,7 @@ static const struct panel_desc innolux_n116bca_ea1 = { .height = 144, }, .delay = { - .hpd_absent_delay = 200, + .hpd_absent = 200, .prepare_to_enable = 80, .unprepare = 500, },
@@ -1165,7 +1188,7 @@ static const struct panel_desc innolux_p120zdg_bf1 = { .height = 169, }, .delay = { - .hpd_absent_delay = 200, + .hpd_absent = 200, .unprepare = 500, }, };
@@ -1192,7 +1215,7 @@ static const struct panel_desc ivo_m133nwf4_r0 = { .height = 165, }, .delay = { - .hpd_absent_delay = 200, + .hpd_absent = 200, .unprepare = 500, }, };
@@ -1219,7 +1242,7 @@ static const struct panel_desc kingdisplay_kd116n21_30nv_a010 = { .height = 144, }, .delay = { - .hpd_absent_delay = 200, + .hpd_absent = 200, }, };
@@ -1345,7 +1368,7 @@ static const struct panel_desc neweast_wjfh116008a = { .height = 150, }, .delay = { - .prepare = 110, + .hpd_reliable = 110, .enable = 20, .unprepare = 500, },
@@ -1439,7 +1462,7 @@ static const struct panel_desc sharp_lq123p1jx31 = { .height = 173, }, .delay = { - .prepare = 110, + .hpd_reliable = 110, .enable = 50, .unprepare = 550, },
@@ -1466,7 +1489,8 @@ static const struct panel_desc starry_kr122ea0sra = { .height = 164, }, .delay = { - .prepare = 10 + 200, +/* TODO: should be hpd-absent and no-hpd should be set? */ + .hpd_reliable = 10 + 200, .enable = 50, .unprepare = 10 + 500, },
Signature · 1 line
2.33.0.309.g3052b89438-goog
Douglas Anderson
reviewerPATCH v4 12/15 drm/panel-edp: hpd_reliable shouldn't be subtraced from hpd_absent
In reply to Douglas AndersonNow that the delays are named / described with eDP-centric names, it becomes clear that we should really specify the "hpd_reliable" and "hpd_absent" separately without taking the other into account. Let's fix it.
This should be a no-op change and just adjust how we specify things. The actual delays should be the same before and after for the one panel that currently species both "hpd_reliable" and "hpd_absent".
---
Changes in v4:
- panel-simple-edp => panel-edp
drivers/gpu/drm/panel/panel-edp.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/gpu/drm/panel/panel-edp.c +3 -5
@@ -423,7 +423,7 @@ static int panel_edp_prepare_once(struct panel_edp *p) delay = p->desc->delay.hpd_reliable;if (p->no_hpd) - delay += p->desc->delay.hpd_absent; + delay =max (delay, p->desc->delay.hpd_absent);if (delay)msleep (delay);
@@ -1039,15 +1039,13 @@ static const struct panel_desc boe_nv133fhm_n61 = {* spike on the HPD line. It was explained that this spike * was until the TCON data download was complete. On * one system this was measured at 8 ms. We'll put 15 ms -* in the prepare delay just to be safe and take it away -* from the hpd_absent (which would otherwise be 200 ms) -* to handle this. That means: +* in the prepare delay just to be safe. That means: * - If HPD isn't hooked up you still have 200 ms delay. * - If HPD is hooked up we won't try to look at it for the * first 15 ms. */ .hpd_reliable = 15, - .hpd_absent = 185, + .hpd_absent = 200, .unprepare = 500, },
Signature · 1 line
2.33.0.309.g3052b89438-goog
Douglas Anderson
reviewerPATCH v4 13/15 drm/panel-edp: Fix "prepare_to_enable" if panel doesn't handle HPD
In reply to Douglas AndersonWhile cleaning up the descriptions of the delay for eDP panels I realized that we'd have a bug if any panels need the "prepare_to_enable" but HPD handling isn't happening in the panel driver. Let's put in a stopgap to at least make us not violate timings. This is not perfectly optimal but trying to do better is hard. At the moment only 2 panels specify this delay and only 30 ms is at stake. These panels are also currently hooked up with "hpd-gpios" so effectively this "fix" is just a theoretical fix and won't actually do anything for any devices currently supported in mainline.
---
Changes in v4:
- panel-simple-edp => panel-edp
Changes in v3:
- Fix "prepare_to_enable" patch new for v3.
drivers/gpu/drm/panel/panel-edp.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-)
drivers/gpu/drm/panel/panel-edp.c +22 -2
@@ -508,12 +508,32 @@ static int panel_edp_prepare(struct drm_panel *panel)static int panel_edp_enable (struct drm_panel *panel) {struct panel_edp *p =to_panel_edp (panel); +unsigned int delay;if (p->enabled)return 0 ; -if (p->desc->delay.enable) -msleep (p->desc->delay.enable); + delay = p->desc->delay.enable; + +/* +* If there is a "prepare_to_enable" delay then that's supposed to be +* the delay from HPD going high until we can turn the backlight on. +* However, we can only count this if HPD is handled by the panel +* driver, not if it goes to a dedicated pin on the controller. +* If we aren't handling the HPD pin ourselves then the best we +* can do is assume that HPD went high immediately before we were +* called (and link training took zero time). +* +* NOTE: if we ever end up in this "if" statement then we're +* guaranteed that the panel_edp_wait() call below will do no delay. +* It already handles that case, though, so we don't need any special +* code for it. +*/ +if (p->desc->delay.prepare_to_enable && !p->hpd_gpio && !p->no_hpd) + delay =max (delay, p->desc->delay.prepare_to_enable); + +if (delay) +msleep (delay);panel_edp_wait (p->prepared_time, p->desc->delay.prepare_to_enable);
Signature · 1 line
2.33.0.309.g3052b89438-goog
Douglas Anderson
reviewerPATCH v4 14/15 drm/panel-edp: Don't re-read the EDID every time we power off the panel
In reply to Douglas AndersonThe simple-panel driver is for panels that are not hot-pluggable at runtime. Let's keep our cached EDID around until driver unload.
---
Changes in v4:
- panel-simple-edp => panel-edp
Changes in v3:
- ("Don't re-read the EDID every time") moved to eDP only patch.
drivers/gpu/drm/panel/panel-edp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/panel/panel-edp.c +3 -3
@@ -362,9 +362,6 @@ static int panel_edp_suspend(struct device *dev)regulator_disable (p->supply); p->unprepared_time =ktime_get (); -kfree (p->edid); - p->edid =NULL ; -return 0 ; }
@@ -758,6 +755,9 @@ static int panel_edp_remove(struct device *dev)if (panel->ddc && (!panel->aux || panel->ddc != &panel->aux->ddc))put_device (&panel->ddc->dev); +kfree (panel->edid); + panel->edid =NULL ; +return 0 ; }
Signature · 1 line
2.33.0.309.g3052b89438-goog
Douglas Anderson
reviewerPATCH v4 15/15 drm/panel-edp: Implement generic "edp-panel"s probed by EDID
In reply to Douglas AndersonAs discussed in the patch ("dt-bindings: drm/panel-simple: Introduce generic eDP panels") we can actually support probing eDP panels at runtime instead of hardcoding what panel is connected. Add support to the panel-edp driver for this.
We'll implement a solution like this:
* We'll read in two delays from the device tree that are used for powering up the panel the initial time (to read the EDID).
* In the EDID we can find a 32-bit ID that identifies what panel we've found. From this ID we can look up the full set of delays.
After this change we'll still need to add per-panel delays into the panel-simple driver but we will no longer need to specify exactly which panel is connected to which board in the device tree. Nicely, any panels that are only supported this way also don't need to hardcode mode data since it's guaranteed that we can get that through the EDID.
This patch will seed the ID-to-delay table with a few panels that I have access to, many of which are on sc7180-trogdor devices.
---
Changes in v4:
- decode_edid_id() => drm_edid_decode_panel_id()
- drm_get_panel_id() => drm_edid_get_panel_id()
- encode_edid_id() => drm_edid_encode_panel_id()
- panel-simple-edp => panel-edp
Changes in v3:
- Add AUO B116XAN06.1 to table.
- Add Sharp LQ116M1JW10 to table.
- Adjust endianness of product ID.
- Change init order to we power at the end.
- Fallback to conservative delays if panel not recognized.
- Generic "edp-panel" handled by the eDP panel driver now.
- Rename delays more generically so they can be reused.
Changes in v2:
- Add "-ms" suffix to delays.
- Don't support a "fallback" panel. Probed panels must be probed.
- Not based on patch to copy "desc"--just allocate for probed panels.
drivers/gpu/drm/panel/panel-edp.c | 216 ++++++++++++++++++++++++++++-- 1 file changed, 202 insertions(+), 14 deletions(-)
drivers/gpu/drm/panel/panel-edp.c +202 -14
@@ -189,6 +189,20 @@ struct panel_desc {struct panel_delay delay; }; +/** +* struct edp_panel_entry - Maps panel ID to delay / panel name. +*/ +struct edp_panel_entry { +/** @panel_id: 32-bit ID for panel, encoded with drm_edid_encode_panel_id(). */ +u32 panel_id; + +/* @delay: The power sequencing delays needed for this panel. */ +const struct panel_delay *delay; + +/* @name: Name of this panel (for printing to logs). */ +const char *name; +}; +struct panel_edp {struct drm_panel base;bool enabled;
@@ -559,8 +573,15 @@ static int panel_edp_get_modes(struct drm_panel *panel,pm_runtime_put_autosuspend (panel->dev); } -/* add hard-coded panel modes */ - num +=panel_edp_get_non_edid_modes (p, connector); +/* +* Add hard-coded panel modes. Don't call this if there are no timings +* and no modes (the generic edp-panel case) because it will clobber +* the display_info that was already set by drm_add_edid_modes(). +*/ +if (p->desc->num_timings || p->desc->num_modes) + num +=panel_edp_get_non_edid_modes (p, connector); +else if (!num) +dev_warn (p->base.dev,"No display modes\n" );/* set up connector's "panel orientation" property */ drm_connector_set_panel_orientation (connector, p->orientation);
@@ -641,6 +662,94 @@ static void panel_edp_parse_panel_timing_node(struct device *dev,dev_err (dev,"Reject override mode: No display_timing found\n" ); } +static const struct edp_panel_entry *find_edp_panel (u32 panel_id); + +static int generic_edp_panel_probe (struct device *dev,struct panel_edp *panel) +{ +const struct edp_panel_entry *edp_panel; +struct panel_desc *desc; +u32 panel_id; +char vend[4 ]; +u16 product_id; +u32 reliable_ms =0 ; +u32 absent_ms =0 ; +int ret; + + desc =devm_kzalloc (dev,sizeof (*desc),GFP_KERNEL ); +if (!desc) +return -ENOMEM ; + panel->desc = desc; + +/* +* Read the dts properties for the initial probe. These are used by +* the runtime resume code which will get called by the +* pm_runtime_get_sync() call below. +*/ +of_property_read_u32 (dev->of_node,"hpd-reliable-delay-ms" , &reliable_ms); + desc->delay.hpd_reliable = reliable_ms; +of_property_read_u32 (dev->of_node,"hpd-absent-delay-ms" , &absent_ms); + desc->delay.hpd_reliable = absent_ms; + +/* Power the panel on so we can read the EDID */ + ret =pm_runtime_get_sync (dev); +if (ret <0 ) { +dev_err (dev,"Couldn't power on panel to read EDID: %d\n" , ret); + goto exit; + } + + panel_id =drm_edid_get_panel_id (panel->ddc); +if (!panel_id) { +dev_err (dev,"Couldn't identify panel via EDID\n" ); + ret = -EIO ; + goto exit; + } +drm_edid_decode_panel_id (panel_id, vend, &product_id); + + edp_panel =find_edp_panel (panel_id); + +/* +* We're using non-optimized timings and want it really obvious that +* someone needs to add an entry to the table, so we'll do a WARN_ON +* splat. +*/ +if (WARN_ON (!edp_panel)) { +dev_warn (dev, +"Unknown panel %s %#06x, using conservative timings\n" , + vend, product_id); + +/* +* It's highly likely that the panel will work if we use very +* conservative timings, so let's do that. We already know that +* the HPD-related delays must have worked since we got this +* far, so we really just need the "unprepare" / "enable" +* delays. We don't need "prepare_to_enable" since that +* overlaps the "enable" delay anyway. +* +* Nearly all panels have a "unprepare" delay of 500 ms though +* there are a few with 1000. Let's stick 2000 in just to be +* super conservative. +* +* An "enable" delay of 80 ms seems the most common, but we'll +* throw in 200 ms to be safe. +*/ + desc->delay.unprepare =2000 ; + desc->delay.enable =200 ; + }else { +dev_info (dev,"Detected %s %s (%#06x)\n" , + vend, edp_panel->name, product_id); + +/* Update the delay; everything else comes from EDID */ + desc->delay = *edp_panel->delay; + } + + ret =0 ; +exit: +pm_runtime_mark_last_busy (dev); +pm_runtime_put_autosuspend (dev); + +return ret; +} +static int panel_edp_probe (struct device *dev,const struct panel_desc *desc,struct drm_dp_aux *aux) {
@@ -698,12 +807,14 @@ static int panel_edp_probe(struct device *dev, const struct panel_desc *desc,if (!of_get_display_timing (dev->of_node,"panel-timing" , &dt))panel_edp_parse_panel_timing_node (dev, panel, &dt); -/* Catch common mistakes for panels. */ -if (desc->bpc !=6 && desc->bpc !=8 && desc->bpc !=10 ) -dev_warn (dev,"Expected bpc in {6,8,10} but got: %u\n" , desc->bpc); -dev_set_drvdata (dev, panel); +drm_panel_init (&panel->base, dev, &panel_edp_funcs, DRM_MODE_CONNECTOR_eDP); + + err =drm_panel_of_backlight (&panel->base); +if (err) + goto err_finished_ddc_init; +/* * We use runtime PM for prepare / unprepare since those power the panel * on and off and those can be very slow operations. This is important
@@ -714,11 +825,18 @@ static int panel_edp_probe(struct device *dev, const struct panel_desc *desc,pm_runtime_set_autosuspend_delay (dev,1000 );pm_runtime_use_autosuspend (dev); -drm_panel_init (&panel->base, dev, &panel_edp_funcs, DRM_MODE_CONNECTOR_eDP); - - err =drm_panel_of_backlight (&panel->base); -if (err) - goto disable_pm_runtime; +if (of_device_is_compatible (dev->of_node,"edp-panel" )) { + err =generic_edp_panel_probe (dev, panel); +if (err) { +dev_err_probe (dev, err, +"Couldn't detect panel nor find a fallback\n" ); + goto err_finished_pm_runtime; + } +/* generic_edp_panel_probe() replaces desc in the panel */ + desc = panel->desc; + }else if (desc->bpc !=6 && desc->bpc !=8 && desc->bpc !=10 ) { +dev_warn (dev,"Expected bpc in {6,8,10} but got: %u\n" , desc->bpc); + }if (!panel->base.backlight && panel->aux) {pm_runtime_get_sync (dev);
@@ -726,16 +844,17 @@ static int panel_edp_probe(struct device *dev, const struct panel_desc *desc,pm_runtime_mark_last_busy (dev);pm_runtime_put_autosuspend (dev);if (err) - goto disable_pm_runtime; + goto err_finished_pm_runtime; }drm_panel_add (&panel->base);return 0 ; -disable_pm_runtime: +err_finished_pm_runtime:pm_runtime_dont_use_autosuspend (dev);pm_runtime_disable (dev); +err_finished_ddc_init:if (panel->ddc && (!panel->aux || panel->ddc != &panel->aux->ddc))put_device (&panel->ddc->dev);
@@ -1516,6 +1635,9 @@ static const struct panel_desc starry_kr122ea0sra = {static const struct of_device_id platform_of_match[] = { { +/* Must be first */ + .compatible ="edp-panel" , + }, { .compatible ="auo,b101ean01" , .data = &auo_b101ean01, }, {
@@ -1605,11 +1727,77 @@ static const struct of_device_id platform_of_match[] = { };MODULE_DEVICE_TABLE (of, platform_of_match); +static const struct panel_delay delay_200_500_p2e80 = { + .hpd_absent =200 , + .unprepare =500 , + .prepare_to_enable =80 , +}; + +static const struct panel_delay delay_200_500_p2e100 = { + .hpd_absent =200 , + .unprepare =500 , + .prepare_to_enable =100 , +}; + +static const struct panel_delay delay_200_500_e50 = { + .hpd_absent =200 , + .unprepare =500 , + .enable =50 , +}; + +#define EDP_PANEL_ENTRY (vend_chr_0, vend_chr_1, vend_chr_2, product_id, _delay, _name) \ +{ \ + .name = _name, \ + .panel_id = drm_edid_encode_panel_id(vend_chr_0, vend_chr_1, vend_chr_2, \ + product_id), \ + .delay = _delay \ +} + +/* +* This table is used to figure out power sequencing delays for panels that +* are detected by EDID. Entries here may point to entries in the +* platform_of_match table (if a panel is listed in both places). +* +* Sort first by vendor, then by product ID. +*/ +static const struct edp_panel_entry edp_panels[] = { +EDP_PANEL_ENTRY ('A' ,'U' ,'O' ,0x405c , &auo_b116xak01.delay,"B116XAK01" ), +EDP_PANEL_ENTRY ('A' ,'U' ,'O' ,0x615c , &delay_200_500_e50,"B116XAN06.1" ), + +EDP_PANEL_ENTRY ('B' ,'O' ,'E' ,0x0786 , &delay_200_500_p2e80,"NV116WHM-T01" ), +EDP_PANEL_ENTRY ('B' ,'O' ,'E' ,0x07d1 , &boe_nv133fhm_n61.delay,"NV133FHM-N61" ), +EDP_PANEL_ENTRY ('B' ,'O' ,'E' ,0x082d , &boe_nv133fhm_n61.delay,"NV133FHM-N62" ), +EDP_PANEL_ENTRY ('B' ,'O' ,'E' ,0x098d , &boe_nv110wtm_n61.delay,"NV110WTM-N61" ), + +EDP_PANEL_ENTRY ('C' ,'M' ,'N' ,0x114c , &innolux_n116bca_ea1.delay,"N116BCA-EA1" ), + +EDP_PANEL_ENTRY ('K' ,'D' ,'B' ,0x0624 , &kingdisplay_kd116n21_30nv_a010.delay,"116N21-30NV-A010" ), + +EDP_PANEL_ENTRY ('S' ,'H' ,'P' ,0x154c , &delay_200_500_p2e100,"LQ116M1JW10" ), + + {/* sentinal */ } +}; + +static const struct edp_panel_entry *find_edp_panel (u32 panel_id) +{ +const struct edp_panel_entry *panel; + +if (!panel_id) +return NULL ; + +for (panel = edp_panels; panel->panel_id; panel++) +if (panel->panel_id == panel_id) +return panel; + +return NULL ; +} +static int panel_edp_platform_probe (struct platform_device *pdev) {const struct of_device_id *id; - id =of_match_node (platform_of_match, pdev->dev.of_node); +/* Skip one since "edp-panel" is only supported on DP AUX bus */ + id =of_match_node (platform_of_match +1 , pdev->dev.of_node);if (!id)return -ENODEV ;
Signature · 1 line
2.33.0.309.g3052b89438-goog