drm/panel: Fix panel mode type setting logic
PATCH 1/1 drm/panel: Fix panel mode type setting logic
Some panels set mode type to DRM_MODE_TYPE_PREFERRED by the number of modes. It isn't reasonable, so set the first mode type to DRM_MODE_TYPE_PREFERRED. This should be more reasonable.
--- drivers/gpu/drm/panel/panel-abt-y030xx067a.c | 2 +- drivers/gpu/drm/panel/panel-auo-a030jtn01.c | 2 +- drivers/gpu/drm/panel/panel-edp.c | 4 ++-- drivers/gpu/drm/panel/panel-innolux-ej030na.c | 2 +- drivers/gpu/drm/panel/panel-newvision-nv3051d.c | 2 +- drivers/gpu/drm/panel/panel-newvision-nv3052c.c | 2 +- drivers/gpu/drm/panel/panel-novatek-nt35950.c | 2 +- drivers/gpu/drm/panel/panel-novatek-nt39016.c | 2 +- drivers/gpu/drm/panel/panel-orisetech-ota5601a.c | 2 +- drivers/gpu/drm/panel/panel-seiko-43wvf1g.c | 4 ++-- drivers/gpu/drm/panel/panel-simple.c | 4 ++-- 11 files changed, 14 insertions(+), 14 deletions(-)
drivers/gpu/drm/panel/panel-abt-y030xx067a.c +1 -1
@@ -240,7 +240,7 @@ static int y030xx067a_get_modes(struct drm_panel *panel,drm_mode_set_name (mode); mode->type =DRM_MODE_TYPE_DRIVER ; -if (panel_info->num_modes ==1 ) +if (i ==0 ) mode->type |=DRM_MODE_TYPE_PREFERRED ;drm_mode_probed_add (connector, mode);
drivers/gpu/drm/panel/panel-auo-a030jtn01.c +1 -1
@@ -151,7 +151,7 @@ static int a030jtn01_get_modes(struct drm_panel *panel,drm_mode_set_name (mode); mode->type =DRM_MODE_TYPE_DRIVER ; -if (panel_info->num_modes ==1 ) +if (i ==0 ) mode->type |=DRM_MODE_TYPE_PREFERRED ;drm_mode_probed_add (connector, mode);
drivers/gpu/drm/panel/panel-edp.c +2 -2
@@ -260,7 +260,7 @@ static unsigned int panel_edp_get_timings_modes(struct panel_edp *panel, mode->type |=DRM_MODE_TYPE_DRIVER ; -if (panel->desc->num_timings ==1 ) +if (i ==0 ) mode->type |=DRM_MODE_TYPE_PREFERRED ;drm_mode_probed_add (connector, mode);
@@ -289,7 +289,7 @@ static unsigned int panel_edp_get_display_modes(struct panel_edp *panel, mode->type |=DRM_MODE_TYPE_DRIVER ; -if (panel->desc->num_modes ==1 ) +if (i ==0 ) mode->type |=DRM_MODE_TYPE_PREFERRED ;drm_mode_set_name (mode);
drivers/gpu/drm/panel/panel-innolux-ej030na.c +1 -1
@@ -166,7 +166,7 @@ static int ej030na_get_modes(struct drm_panel *panel,drm_mode_set_name (mode); mode->type =DRM_MODE_TYPE_DRIVER ; -if (panel_info->num_modes ==1 ) +if (i ==0 ) mode->type |=DRM_MODE_TYPE_PREFERRED ;drm_mode_probed_add (connector, mode);
drivers/gpu/drm/panel/panel-newvision-nv3051d.c +1 -1
@@ -331,7 +331,7 @@ static int panel_nv3051d_get_modes(struct drm_panel *panel,drm_mode_set_name (mode); mode->type =DRM_MODE_TYPE_DRIVER ; -if (panel_info->num_modes ==1 ) +if (i ==0 ) mode->type |=DRM_MODE_TYPE_PREFERRED ;drm_mode_probed_add (connector, mode);
drivers/gpu/drm/panel/panel-newvision-nv3052c.c +1 -1
@@ -347,7 +347,7 @@ static int nv3052c_get_modes(struct drm_panel *panel,drm_mode_set_name (mode); mode->type =DRM_MODE_TYPE_DRIVER ; -if (panel_info->num_modes ==1 ) +if (i ==0 ) mode->type |=DRM_MODE_TYPE_PREFERRED ;drm_mode_probed_add (connector, mode);
drivers/gpu/drm/panel/panel-novatek-nt35950.c +1 -1
@@ -508,7 +508,7 @@ static int nt35950_get_modes(struct drm_panel *panel,drm_mode_set_name (mode); mode->type |=DRM_MODE_TYPE_DRIVER ; -if (nt->desc->num_modes ==1 ) +if (i ==0 ) mode->type |=DRM_MODE_TYPE_PREFERRED ;drm_mode_probed_add (connector, mode);
drivers/gpu/drm/panel/panel-novatek-nt39016.c +1 -1
@@ -216,7 +216,7 @@ static int nt39016_get_modes(struct drm_panel *drm_panel,drm_mode_set_name (mode); mode->type =DRM_MODE_TYPE_DRIVER ; -if (panel_info->num_modes ==1 ) +if (i ==0 ) mode->type |=DRM_MODE_TYPE_PREFERRED ;drm_mode_probed_add (connector, mode);
drivers/gpu/drm/panel/panel-orisetech-ota5601a.c +1 -1
@@ -206,7 +206,7 @@ static int ota5601a_get_modes(struct drm_panel *drm_panel,drm_mode_set_name (mode); mode->type =DRM_MODE_TYPE_DRIVER ; -if (panel_info->num_modes ==1 ) +if (i ==0 ) mode->type |=DRM_MODE_TYPE_PREFERRED ;drm_mode_probed_add (connector, mode);
drivers/gpu/drm/panel/panel-seiko-43wvf1g.c +2 -2
@@ -80,7 +80,7 @@ static int seiko_panel_get_fixed_modes(struct seiko_panel *panel, mode->type |=DRM_MODE_TYPE_DRIVER ; -if (panel->desc->num_timings ==1 ) +if (i ==0 ) mode->type |=DRM_MODE_TYPE_PREFERRED ;drm_mode_probed_add (connector, mode);
@@ -100,7 +100,7 @@ static int seiko_panel_get_fixed_modes(struct seiko_panel *panel, mode->type |=DRM_MODE_TYPE_DRIVER ; -if (panel->desc->num_modes ==1 ) +if (i ==0 ) mode->type |=DRM_MODE_TYPE_PREFERRED ;drm_mode_set_name (mode);
drivers/gpu/drm/panel/panel-simple.c +2 -2
@@ -185,7 +185,7 @@ static unsigned int panel_simple_get_timings_modes(struct panel_simple *panel, mode->type |=DRM_MODE_TYPE_DRIVER ; -if (panel->desc->num_timings ==1 ) +if (i ==0 ) mode->type |=DRM_MODE_TYPE_PREFERRED ;drm_mode_probed_add (connector, mode);
@@ -214,7 +214,7 @@ static unsigned int panel_simple_get_display_modes(struct panel_simple *panel, mode->type |=DRM_MODE_TYPE_DRIVER ; -if (panel->desc->num_modes ==1 ) +if (i ==0 ) mode->type |=DRM_MODE_TYPE_PREFERRED ;drm_mode_set_name (mode);
Signature · 1 line
2.39.2
Doug Anderson
reviewerHi,
Quoted 6 lines · Jianhua Lu
Some panels set mode type to
DRM_MODE_TYPE_PREFERREDby the number of modes. It isn't reasonable, so set the first mode type toDRM_MODE_TYPE_PREFERRED. This should be more reasonable.Signed-off-by Jianhua Lu <[email protected]>
Quoted 13 lines
--- drivers/gpu/drm/panel/panel-abt-y030xx067a.c | 2 +- drivers/gpu/drm/panel/panel-auo-a030jtn01.c | 2 +- drivers/gpu/drm/panel/panel-edp.c | 4 ++-- drivers/gpu/drm/panel/panel-innolux-ej030na.c | 2 +- drivers/gpu/drm/panel/panel-newvision-nv3051d.c | 2 +- drivers/gpu/drm/panel/panel-newvision-nv3052c.c | 2 +- drivers/gpu/drm/panel/panel-novatek-nt35950.c | 2 +- drivers/gpu/drm/panel/panel-novatek-nt39016.c | 2 +- drivers/gpu/drm/panel/panel-orisetech-ota5601a.c | 2 +- drivers/gpu/drm/panel/panel-seiko-43wvf1g.c | 4 ++-- drivers/gpu/drm/panel/panel-simple.c | 4 ++-- 11 files changed, 14 insertions(+), 14 deletions(-)
Can you explain more about your motivation here? At least for panel-edp and panel-simple it seems like it would be better to leave the logic alone and manually add DRM_MODE_TYPE_PREFERRED to the right mode for the rare panel that actually has more than one mode listed. That feels more explicit to me.
-Doug
Quoted 23 lines · Doug Anderson
Hi,
Quoted 6 lines · Jianhua Lu
Some panels set mode type to
DRM_MODE_TYPE_PREFERREDby the number of modes. It isn't reasonable, so set the first mode type toDRM_MODE_TYPE_PREFERRED. This should be more reasonable.Signed-off-by Jianhua Lu <[email protected]>Quoted 13 lines
--- drivers/gpu/drm/panel/panel-abt-y030xx067a.c | 2 +- drivers/gpu/drm/panel/panel-auo-a030jtn01.c | 2 +- drivers/gpu/drm/panel/panel-edp.c | 4 ++-- drivers/gpu/drm/panel/panel-innolux-ej030na.c | 2 +- drivers/gpu/drm/panel/panel-newvision-nv3051d.c | 2 +- drivers/gpu/drm/panel/panel-newvision-nv3052c.c | 2 +- drivers/gpu/drm/panel/panel-novatek-nt35950.c | 2 +- drivers/gpu/drm/panel/panel-novatek-nt39016.c | 2 +- drivers/gpu/drm/panel/panel-orisetech-ota5601a.c | 2 +- drivers/gpu/drm/panel/panel-seiko-43wvf1g.c | 4 ++-- drivers/gpu/drm/panel/panel-simple.c | 4 ++-- 11 files changed, 14 insertions(+), 14 deletions(-)
Quoted 1 line
Can you explain more about your motivation here? At least for
This demonstrates a bad way to set DRM_MODE_TYPE_PREFERRED for panels with more than one mode. It mislead the future contributors to send a patch with this piece of code. There is also a discussion for it.
https://lore.kernel.org/lkml/[email protected]/
Quoted 3 lines
panel-edp and panel-simple it seems like it would be better to leave the logic alone and manually add
DRM_MODE_TYPE_PREFERREDto the right mode for the rare panel that actually has more than one mode listed.
I think we can order it to the first mode if the mode type should be DRM_MODE_TYPE_PREFERRED, It's also same.
Quoted 3 lines
That feels more explicit to me.
-Doug
Doug Anderson
reviewerHi,
Quoted 30 lines · Jianhua Lu
Quoted 23 lines · Doug Anderson
Hi,
Quoted 6 lines · Jianhua Lu
Some panels set mode type to
DRM_MODE_TYPE_PREFERREDby the number of modes. It isn't reasonable, so set the first mode type toDRM_MODE_TYPE_PREFERRED. This should be more reasonable.Signed-off-by Jianhua Lu <[email protected]>Quoted 13 lines
--- drivers/gpu/drm/panel/panel-abt-y030xx067a.c | 2 +- drivers/gpu/drm/panel/panel-auo-a030jtn01.c | 2 +- drivers/gpu/drm/panel/panel-edp.c | 4 ++-- drivers/gpu/drm/panel/panel-innolux-ej030na.c | 2 +- drivers/gpu/drm/panel/panel-newvision-nv3051d.c | 2 +- drivers/gpu/drm/panel/panel-newvision-nv3052c.c | 2 +- drivers/gpu/drm/panel/panel-novatek-nt35950.c | 2 +- drivers/gpu/drm/panel/panel-novatek-nt39016.c | 2 +- drivers/gpu/drm/panel/panel-orisetech-ota5601a.c | 2 +- drivers/gpu/drm/panel/panel-seiko-43wvf1g.c | 4 ++-- drivers/gpu/drm/panel/panel-simple.c | 4 ++-- 11 files changed, 14 insertions(+), 14 deletions(-)Quoted 1 line
Can you explain more about your motivation here? At least for
This demonstrates a bad way to set
DRM_MODE_TYPE_PREFERREDfor panels with more than one mode. It mislead the future contributors to send a patch with this piece of code. There is also a discussion for it.
https://lore.kernel.org/lkml/[email protected]/
Quoted 5 lines
Quoted 3 lines
panel-edp and panel-simple it seems like it would be better to leave the logic alone and manually add
DRM_MODE_TYPE_PREFERREDto the right mode for the rare panel that actually has more than one mode listed.I think we can order it to the first mode if the mode type should be
DRM_MODE_TYPE_PREFERRED, It's also same.
A pointer to the original discussion would have been super helpful to be provided in your patch description.
Personally, I still stand by my assertion that I'd rather that DRM_MODE_TYPE_PREFERRED be placed in the actual data instead of being done like this in post-processing. To me the old check for "num_modes == 1" is basically saying that the people creating the "static const" data in this file were lazy and didn't feel like they needed to set a DRM_MODE_TYPE_PREFERRED when there was only one mode listed. Thus, we can add it for them. When "num_modes" is more than 1 then we shouldn't allow the people making the "static const" data to be lazy. We should force them to set one of the modes to be PREFERRED rather than for them to have to know about this magic rule.
Thus, for me, my order of preference would be these (note, I've mostly looked at panel-edp and panel-simple):
1. Leave the check as "num_modes == 1" and document that we're basically allowing the people writing the "static const" structure to be lazy if there's only one mode. Manually add the DRM_MODE_TYPE_PREFERRED flag to the small number of cases where there is more than one mode. Possibly add a warning printout if we end up without a PREFERRED mode. I'd give a Reviewed-by for this.
2. Fully get rid of this logic and add DRM_MODE_TYPE_PREFERRED to all of the "static const" data. I guess maybe we can't do that for the "timings" in panel-edp and panel-simple. I guess for those I'd be OK with just setting PREFERRED on the first timing like your patch is doing. I'd give a Reviewed-by for this.
3. Your patch. I won't NAK it since it seems like this is what other (more senior) DRM folks were suggesting. ...but I don't love it. I won't give a Reviewed-by for this but won't object to someone else doing so.
-Doug
Neil Armstrong
maintainerHi,
Quoted 70 lines · Doug Anderson
Hi,
Quoted 30 lines · Jianhua Lu
Quoted 23 lines · Doug Anderson
Hi,
Quoted 6 lines · Jianhua Lu
Some panels set mode type to
DRM_MODE_TYPE_PREFERREDby the number of modes. It isn't reasonable, so set the first mode type toDRM_MODE_TYPE_PREFERRED. This should be more reasonable.Signed-off-by Jianhua Lu <[email protected]>Quoted 13 lines
--- drivers/gpu/drm/panel/panel-abt-y030xx067a.c | 2 +- drivers/gpu/drm/panel/panel-auo-a030jtn01.c | 2 +- drivers/gpu/drm/panel/panel-edp.c | 4 ++-- drivers/gpu/drm/panel/panel-innolux-ej030na.c | 2 +- drivers/gpu/drm/panel/panel-newvision-nv3051d.c | 2 +- drivers/gpu/drm/panel/panel-newvision-nv3052c.c | 2 +- drivers/gpu/drm/panel/panel-novatek-nt35950.c | 2 +- drivers/gpu/drm/panel/panel-novatek-nt39016.c | 2 +- drivers/gpu/drm/panel/panel-orisetech-ota5601a.c | 2 +- drivers/gpu/drm/panel/panel-seiko-43wvf1g.c | 4 ++-- drivers/gpu/drm/panel/panel-simple.c | 4 ++-- 11 files changed, 14 insertions(+), 14 deletions(-)Quoted 1 line
Can you explain more about your motivation here? At least for
This demonstrates a bad way to set
DRM_MODE_TYPE_PREFERREDfor panels with more than one mode. It mislead the future contributors to send a patch with this piece of code. There is also a discussion for it.
https://lore.kernel.org/lkml/[email protected]/Quoted 5 lines
Quoted 3 lines
panel-edp and panel-simple it seems like it would be better to leave the logic alone and manually add
DRM_MODE_TYPE_PREFERREDto the right mode for the rare panel that actually has more than one mode listed.I think we can order it to the first mode if the mode type should be
DRM_MODE_TYPE_PREFERRED, It's also same.A pointer to the original discussion would have been super helpful to be provided in your patch description.
Personally, I still stand by my assertion that I'd rather that
DRM_MODE_TYPE_PREFERREDbe placed in the actual data instead of being done like this in post-processing. To me the old check for "num_modes== 1" is basically saying that the people creating the "static const" data in this file were lazy and didn't feel like they needed to set aDRM_MODE_TYPE_PREFERREDwhen there was only one mode listed. Thus, we can add it for them. When "num_modes" is more than 1 then we shouldn't allow the people making the "static const" data to be lazy. We should force them to set one of the modes to be PREFERRED rather than for them to have to know about this magic rule.Thus, for me, my order of preference would be these (note, I've mostly looked at panel-edp and panel-simple):
1. Leave the check as "
num_modes== 1" and document that we're basically allowing the people writing the "static const" structure to be lazy if there's only one mode. Manually add theDRM_MODE_TYPE_PREFERREDflag to the small number of cases where there is more than one mode. Possibly add a warning printout if we end up without a PREFERRED mode. I'd give a Reviewed-by for this.2. Fully get rid of this logic and add
DRM_MODE_TYPE_PREFERREDto all of the "static const" data. I guess maybe we can't do that for the "timings" in panel-edp and panel-simple. I guess for those I'd be OK with just setting PREFERRED on the first timing like your patch is doing. I'd give a Reviewed-by for this.
Quoted 4 lines
3. Your patch. I won't NAK it since it seems like this is what other (more senior) DRM folks were suggesting. ...but I don't love it. I won't give a Reviewed-by for this but won't object to someone else doing so.
I'm aligned with Doug's analysis, I don't have a strong opinion on what to do, but 1 or 2 would be OK.
Neil
Quoted 2 lines
-Doug