Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RG350M panel glitch fix proposal #7

Closed
wants to merge 11 commits into from
Closed
2 changes: 2 additions & 0 deletions Documentation/devicetree/bindings/vendor-prefixes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ patternProperties:
description: Abilis Systems
"^abracon,.*":
description: Abracon Corporation
"^abt,.*":
description: ShenZhen Asia Better Technology Ltd.
"^acer,.*":
description: Acer Inc.
"^acme,.*":
Expand Down
79 changes: 79 additions & 0 deletions arch/mips/boot/dts/ingenic/rg280m.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// SPDX-License-Identifier: GPL-2.0
/dts-v1/;

#include "rg350.dts"

/ {
compatible = "ylm,rg280m", "ingenic,jz4770";
model = "Anbernic RG-280M";

spi {
compatible = "spi-gpio";
#address-cells = <1>;
#size-cells = <0>;

sck-gpios = <&gpe 15 0>;
mosi-gpios = <&gpe 17 0>;
cs-gpios = <&gpe 16 0>;
num-chipselects = <1>;

panel@0 {
compatible = "abt,y030xx067a";
reg = <0>;

spi-max-frequency = <15000000>;

reset-gpios = <&gpe 2 GPIO_ACTIVE_LOW>;

backlight = <&backlight>;
power-supply = <&vcc>;

port {
y030xx067a_input: endpoint {
remote-endpoint = <&panel_output>;
};
};
};
};
};

&panel_output {
remote-endpoint = <&y030xx067a_input>;
};

&panel {
status = "disabled";
};

/* Make Frida panel port a dummy to avoid DTC complaints */
&panel_input {
remote-endpoint = <&panel_input>;
};

&joystick {
status = "disabled";
};

rg280m-joystick {
compatible = "adc-joystick";
io-channels = <&adc INGENIC_ADC_TOUCH_YP>,
<&adc INGENIC_ADC_TOUCH_XP>;
#address-cells = <1>;
#size-cells = <0>;

axis@0 {
reg = <0>;
linux,code = <ABS_X>;
abs-range = <3000 200>;
abs-fuzz = <4>;
abs-flat = <200>;
};

axis@1 {
reg = <1>;
linux,code = <ABS_Y>;
abs-range = <3000 200>;
abs-fuzz = <4>;
abs-flat = <200>;
};
};
2 changes: 1 addition & 1 deletion arch/mips/boot/dts/ingenic/rg350.dts
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@
};
};

joystick {
joystick: joystick {
compatible = "adc-joystick";
io-channels = <&adc INGENIC_ADC_TOUCH_YP>,
<&adc INGENIC_ADC_TOUCH_XP>,
Expand Down
36 changes: 27 additions & 9 deletions drivers/gpu/drm/ingenic/ingenic-drm-drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,12 @@ static void ingenic_drm_crtc_update_timings(struct ingenic_drm *priv,
vpe = mode->vsync_end - mode->vsync_start;
vds = mode->vtotal - mode->vsync_start;
vde = vds + mode->vdisplay;
vt = vde + mode->vsync_start - mode->vdisplay;
vt = mode->vtotal;

hpe = mode->hsync_end - mode->hsync_start;
hds = mode->htotal - mode->hsync_start;
hde = hds + mode->hdisplay;
ht = hde + mode->hsync_start - mode->hdisplay;
hpe = mode->crtc_hsync_end - mode->crtc_hsync_start;
hds = mode->crtc_htotal - mode->crtc_hsync_start;
hde = hds + mode->crtc_hdisplay;
ht = mode->crtc_htotal;

regmap_write(priv->map, JZ_REG_LCD_VSYNC,
0 << JZ_LCD_VSYNC_VPS_OFFSET |
Expand Down Expand Up @@ -333,13 +333,13 @@ static void ingenic_drm_crtc_atomic_flush(struct drm_crtc *crtc,
struct drm_pending_vblank_event *event = state->event;

if (drm_atomic_crtc_needs_modeset(state)) {
ingenic_drm_crtc_update_timings(priv, &state->mode);
ingenic_drm_crtc_update_timings(priv, &state->adjusted_mode);
priv->update_clk_rate = true;
}

if (priv->update_clk_rate) {
mutex_lock(&priv->clk_mutex);
clk_set_rate(priv->pix_clk, state->adjusted_mode.clock * 1000);
clk_set_rate(priv->pix_clk, state->adjusted_mode.crtc_clock * 1000);
priv->update_clk_rate = false;
mutex_unlock(&priv->clk_mutex);
}
Expand Down Expand Up @@ -624,7 +624,7 @@ static void ingenic_drm_encoder_atomic_mode_set(struct drm_encoder *encoder,
struct drm_display_mode *mode = &crtc_state->adjusted_mode;
struct drm_connector *conn = conn_state->connector;
struct drm_display_info *info = &conn->display_info;
unsigned int cfg;
unsigned int cfg, rgbcfg = 0;

priv->panel_is_sharp = info->bus_flags & DRM_BUS_FLAG_SHARP_SIGNALS;

Expand Down Expand Up @@ -661,6 +661,9 @@ static void ingenic_drm_encoder_atomic_mode_set(struct drm_encoder *encoder,
case MEDIA_BUS_FMT_RGB888_1X24:
cfg |= JZ_LCD_CFG_MODE_GENERIC_24BIT;
break;
case MEDIA_BUS_FMT_GBR888_3X8:
rgbcfg = JZ_LCD_RGBC_ODD_GBR | JZ_LCD_RGBC_EVEN_GBR;
fallthrough;
case MEDIA_BUS_FMT_RGB888_3X8:
cfg |= JZ_LCD_CFG_MODE_8BIT_SERIAL;
break;
Expand All @@ -671,13 +674,15 @@ static void ingenic_drm_encoder_atomic_mode_set(struct drm_encoder *encoder,
}

regmap_write(priv->map, JZ_REG_LCD_CFG, cfg);
regmap_write(priv->map, JZ_REG_LCD_RGBC, rgbcfg);
}

static int ingenic_drm_encoder_atomic_check(struct drm_encoder *encoder,
struct drm_crtc_state *crtc_state,
struct drm_connector_state *conn_state)
{
struct drm_display_info *info = &conn_state->connector->display_info;
struct drm_display_mode *mode = &crtc_state->adjusted_mode;

if (info->num_bus_formats != 1)
return -EINVAL;
Expand All @@ -686,10 +691,23 @@ static int ingenic_drm_encoder_atomic_check(struct drm_encoder *encoder,
return 0;

switch (*info->bus_formats) {
case MEDIA_BUS_FMT_RGB888_3X8:
case MEDIA_BUS_FMT_GBR888_3X8:
/*
* The LCD controller expects timing values in dot-clock ticks,
* which is 3x the timing values in pixels when using a 3x8-bit
* display; but it will count the display area size in pixels
* either way. Go figure.
*/
mode->crtc_clock = mode->clock * 3;
mode->crtc_hsync_start = mode->hsync_start * 3 - mode->hdisplay * 2;
mode->crtc_hsync_end = mode->hsync_end * 3 - mode->hdisplay * 2;
mode->crtc_hdisplay = mode->hdisplay;
mode->crtc_htotal = mode->htotal * 3 - mode->hdisplay * 2;
return 0;
case MEDIA_BUS_FMT_RGB565_1X16:
case MEDIA_BUS_FMT_RGB666_1X18:
case MEDIA_BUS_FMT_RGB888_1X24:
case MEDIA_BUS_FMT_RGB888_3X8:
return 0;
default:
return -EINVAL;
Expand Down
14 changes: 14 additions & 0 deletions drivers/gpu/drm/ingenic/ingenic-drm.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#define JZ_REG_LCD_SA1 0x54
#define JZ_REG_LCD_FID1 0x58
#define JZ_REG_LCD_CMD1 0x5C
#define JZ_REG_LCD_RGBC 0x90
#define JZ_REG_LCD_OSDC 0x100
#define JZ_REG_LCD_OSDCTRL 0x104
#define JZ_REG_LCD_OSDS 0x108
Expand Down Expand Up @@ -138,6 +139,19 @@
#define JZ_LCD_STATE_SOF_IRQ BIT(4)
#define JZ_LCD_STATE_DISABLED BIT(0)

#define JZ_LCD_RGBC_ODD_RGB (0x0 << 4)
#define JZ_LCD_RGBC_ODD_RBG (0x1 << 4)
#define JZ_LCD_RGBC_ODD_GRB (0x2 << 4)
#define JZ_LCD_RGBC_ODD_GBR (0x3 << 4)
#define JZ_LCD_RGBC_ODD_BRG (0x4 << 4)
#define JZ_LCD_RGBC_ODD_BGR (0x5 << 4)
#define JZ_LCD_RGBC_EVEN_RGB (0x0 << 0)
#define JZ_LCD_RGBC_EVEN_RBG (0x1 << 0)
#define JZ_LCD_RGBC_EVEN_GRB (0x2 << 0)
#define JZ_LCD_RGBC_EVEN_GBR (0x3 << 0)
#define JZ_LCD_RGBC_EVEN_BRG (0x4 << 0)
#define JZ_LCD_RGBC_EVEN_BGR (0x5 << 0)

#define JZ_LCD_OSDC_OSDEN BIT(0)
#define JZ_LCD_OSDC_F0EN BIT(3)
#define JZ_LCD_OSDC_F1EN BIT(4)
Expand Down
9 changes: 9 additions & 0 deletions drivers/gpu/drm/panel/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ config DRM_PANEL
menu "Display Panels"
depends on DRM && DRM_PANEL

config DRM_PANEL_ABT_Y030XX067A
tristate "ABT Y030XX067A 320x480 LCD panel"
depends on OF && SPI
select REGMAP_SPI
help
Say Y here to enable support for the Asia Better Technology Ltd.
Y030XX067A 320x480 3.0" panel as found in the YLM RG-280M, RG-300
and RG-99 handheld gaming consoles.

config DRM_PANEL_ARM_VERSATILE
tristate "ARM Versatile panel driver"
depends on OF
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/panel/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# SPDX-License-Identifier: GPL-2.0
obj-$(CONFIG_DRM_PANEL_ABT_Y030XX067A) += panel-abt-y030xx067a.o
obj-$(CONFIG_DRM_PANEL_ARM_VERSATILE) += panel-arm-versatile.o
obj-$(CONFIG_DRM_PANEL_ASUS_Z00T_TM5P5_NT35596) += panel-asus-z00t-tm5p5-n35596.o
obj-$(CONFIG_DRM_PANEL_BOE_HIMAX8279D) += panel-boe-himax8279d.o
Expand Down
Loading