drm/mali-dp: Collate the pending patches in a series
Subsystems (3)
Liviu Dudau
maintainercover drm/mali-dp: Collate the pending patches in a series
Hello,
This is not a topic series, but a collection of patches that I have acked previously on the dri-devel list and I now plan to push to drm-next. I have rebased on the latest drm-next from 20/04 and also cleaned up some comments compared to what has been already pushed into the mailing list.
I'm sending them now to see if there are any more comments to the series, otherwise I will send a pull request to David next week.
Best regards,
Liviu
Arnd Bergmann (1):
drm: mali-dp: remove unused variable
Liviu Dudau (3):
drm: mali-dp: Update the state of all planes before re-enabling active
CRTCs.
drm: mali-dp: Enable power management for the device. drm/mali-dp: Add core_id file to the sysfs interface
Mihail Atanassov (8):
drm: mali-dp: add atomic_print_state for planes
drm: mali-dp: add custom reset hook for planes
drm: mali-dp: add malidp_crtc_state struct
drm: mali-dp: enable gamma support
drm: mali-dp: Add CTM support
drm: mali-dp: Add plane upscaling support
drm: mali-dp: Enable image enhancement when scaling
drm: mali-dp: Check the mclk rate and allow up/down scaling
drivers/gpu/drm/arm/malidp_crtc.c | 342 ++++++++++++++++++++++++++++++++++-- drivers/gpu/drm/arm/malidp_drv.c | 307 +++++++++++++++++++++++++++++--- drivers/gpu/drm/arm/malidp_drv.h | 13 ++ drivers/gpu/drm/arm/malidp_hw.c | 213 ++++++++++++++++++++++ drivers/gpu/drm/arm/malidp_hw.h | 81 +++++++++ drivers/gpu/drm/arm/malidp_planes.c | 110 ++++++++++-- drivers/gpu/drm/arm/malidp_regs.h | 72 +++++++- 7 files changed, 1076 insertions(+), 62 deletions(-)
Signature · 6 lines
2.12.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Liviu Dudau
maintainerPATCH 1/12 drm: mali-dp: Update the state of all planes before re-enabling active CRTCs.
Mali DP needs to have all the planes that are becoming inactive in the new state disabled before re-enabling the active CRTC, otherwise we start streaming out data from old pointers in memory.
--- drivers/gpu/drm/arm/malidp_drv.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/gpu/drm/arm/malidp_drv.c +8 -4
@@ -66,10 +66,12 @@ static void malidp_atomic_commit_hw_done(struct drm_atomic_state *state)struct drm_pending_vblank_event *event;struct drm_device *drm = state->dev;struct malidp_drm *malidp = drm->dev_private; -int ret =malidp_set_and_wait_config_valid (drm); -if (ret) -DRM_DEBUG_DRIVER ("timed out waiting for updated configuration\n" ); +if (malidp->crtc.enabled) { +/* only set config_valid if the CRTC is enabled */ +if (malidp_set_and_wait_config_valid (drm)) +DRM_DEBUG_DRIVER ("timed out waiting for updated configuration\n" ); + } event = malidp->crtc.state->event;if (event) {
@@ -90,9 +92,11 @@ static void malidp_atomic_commit_tail(struct drm_atomic_state *state)struct drm_device *drm = state->dev;drm_atomic_helper_commit_modeset_disables (drm, state); -drm_atomic_helper_commit_modeset_enables (drm, state); +drm_atomic_helper_commit_planes (drm, state,0 ); +drm_atomic_helper_commit_modeset_enables (drm, state); +malidp_atomic_commit_hw_done (state);drm_atomic_helper_wait_for_vblanks (drm, state);
Signature · 6 lines
2.12.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Liviu Dudau
maintainerPATCH 2/12 drm: mali-dp: Enable power management for the device.
In reply to Liviu DudauEnable runtime and system Power Management. Clocks are now managed from malidp_crtc_{enable,disable} functions. Suspend-to-RAM tested as working on Juno.
--- drivers/gpu/drm/arm/malidp_crtc.c | 14 ++++- drivers/gpu/drm/arm/malidp_drv.c | 128 +++++++++++++++++++++++++++++++------- drivers/gpu/drm/arm/malidp_drv.h | 1 + drivers/gpu/drm/arm/malidp_hw.h | 5 ++ 4 files changed, 125 insertions(+), 23 deletions(-)
drivers/gpu/drm/arm/malidp_crtc.c +13 -1
@@ -16,6 +16,7 @@#include <drm/drm_crtc.h> #include <drm/drm_crtc_helper.h> #include <linux/clk.h> +#include <linux/pm_runtime.h> #include <video/videomode.h> #include "malidp_drv.h"
@@ -58,9 +59,14 @@ static void malidp_crtc_enable(struct drm_crtc *crtc)struct malidp_drm *malidp =crtc_to_malidp_device (crtc);struct malidp_hw_device *hwdev = malidp->dev;struct videomode vm; +int err =pm_runtime_get_sync (crtc->dev->dev); -drm_display_mode_to_videomode (&crtc->state->adjusted_mode, &vm); +if (err <0 ) { +DRM_DEBUG_DRIVER ("Failed to enable runtime power management: %d\n" , err); +return ; + } +drm_display_mode_to_videomode (&crtc->state->adjusted_mode, &vm);clk_prepare_enable (hwdev->pxlclk);/* We rely on firmware to set mclk to a sensible level. */
@@ -75,10 +81,16 @@ static void malidp_crtc_disable(struct drm_crtc *crtc) {struct malidp_drm *malidp =crtc_to_malidp_device (crtc);struct malidp_hw_device *hwdev = malidp->dev; +int err;drm_crtc_vblank_off (crtc); hwdev->enter_config_mode (hwdev);clk_disable_unprepare (hwdev->pxlclk); + + err =pm_runtime_put (crtc->dev->dev); +if (err <0 ) { +DRM_DEBUG_DRIVER ("Failed to disable runtime power management: %d\n" , err); + } } static int malidp_crtc_atomic_check(struct drm_crtc *crtc,
drivers/gpu/drm/arm/malidp_drv.c +106 -22
230 lines not on this page · raw message
drivers/gpu/drm/arm/malidp_drv.h +1 -0
@@ -24,6 +24,7 @@ struct malidp_drm {struct drm_crtc crtc;wait_queue_head_t wq;atomic_t config_valid; +struct drm_atomic_state *pm_state; };#define crtc_to_malidp_device (x) container_of(x, struct malidp_drm, crtc)
drivers/gpu/drm/arm/malidp_hw.h +5 -0
@@ -156,6 +156,9 @@ struct malidp_hw_device {u8 min_line_size;u16 max_line_size; +/* track the device PM state */ +bool pm_suspended; +/* size of memory used for rotating layers, up to two banks available */ u32 rotation_memory[2 ]; };
@@ -173,12 +176,14 @@ extern const struct malidp_hw_device malidp_device[MALIDP_MAX_DEVICES];static inline u32 malidp_hw_read (struct malidp_hw_device *hwdev,u32 reg) { +WARN_ON (hwdev->pm_suspended);return readl (hwdev->regs + reg); }static inline void malidp_hw_write (struct malidp_hw_device *hwdev,u32 value,u32 reg) { +WARN_ON (hwdev->pm_suspended);writel (value, hwdev->regs + reg); }
Signature · 6 lines
2.12.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Liviu Dudau
maintainerPATCH 3/12 drm: mali-dp: add atomic_print_state for planes
In reply to Liviu DudauFrom: Mihail Atanassov <[email protected]>
Add function to dump the state of the plane.
--- drivers/gpu/drm/arm/malidp_planes.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/gpu/drm/arm/malidp_planes.c +13 -0
@@ -16,6 +16,7 @@#include <drm/drm_fb_cma_helper.h> #include <drm/drm_gem_cma_helper.h> #include <drm/drm_plane_helper.h> +#include <drm/drm_print.h> #include "malidp_hw.h" #include "malidp_drv.h"
@@ -90,6 +91,17 @@ static void malidp_destroy_plane_state(struct drm_plane *plane,kfree (m_state); } +static void malidp_plane_atomic_print_state (struct drm_printer *p, +const struct drm_plane_state *state) +{ +struct malidp_plane_state *ms =to_malidp_plane_state (state); +struct malidp_plane *mp =to_malidp_plane (state->plane); + +drm_printf (p,"\trotmem_size=%u\n" , ms->rotmem_size); +drm_printf (p,"\tformat_id=%u\n" , ms->format); +drm_printf (p,"\tn_planes=%u\n" , ms->n_planes); +} +static const struct drm_plane_funcs malidp_de_plane_funcs = { .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane,
@@ -98,6 +110,7 @@ static const struct drm_plane_funcs malidp_de_plane_funcs = { .reset = drm_atomic_helper_plane_reset, .atomic_duplicate_state = malidp_duplicate_plane_state, .atomic_destroy_state = malidp_destroy_plane_state, + .atomic_print_state = malidp_plane_atomic_print_state, }; static int malidp_de_plane_check(struct drm_plane *plane,
Signature · 6 lines
2.12.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Liviu Dudau
maintainerPATCH 4/12 drm: mali-dp: remove unused variable
In reply to Liviu DudauFrom: Arnd Bergmann <[email protected]>
The newly introduced function causes a harmless build warning:
drivers/gpu/drm/arm/malidp_planes.c: In function 'malidp_plane_atomic_print_state':drivers/gpu/drm/arm/malidp_planes.c:98:23: error: unused variable 'mp' [-Werror=unused-variable]
The variable serves no purpose here and can be removed.
--- drivers/gpu/drm/arm/malidp_planes.c | 1 - 1 file changed, 1 deletion(-)
drivers/gpu/drm/arm/malidp_planes.c +0 -1
@@ -95,7 +95,6 @@ static void malidp_plane_atomic_print_state(struct drm_printer *p, const struct drm_plane_state *state) {struct malidp_plane_state *ms =to_malidp_plane_state (state); -struct malidp_plane *mp =to_malidp_plane (state->plane);drm_printf (p,"\trotmem_size=%u\n" , ms->rotmem_size);drm_printf (p,"\tformat_id=%u\n" , ms->format);
Signature · 6 lines
2.12.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Liviu Dudau
maintainerPATCH 5/12 drm: mali-dp: add custom reset hook for planes
In reply to Liviu DudauFrom: Mihail Atanassov <[email protected]>
Now that we are using a custom plane state in mali-dp, we need a bespoke reset that takes into account the larger structure.
--- drivers/gpu/drm/arm/malidp_planes.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)
drivers/gpu/drm/arm/malidp_planes.c +22 -1
@@ -61,6 +61,27 @@ static void malidp_de_plane_destroy(struct drm_plane *plane)devm_kfree (plane->dev->dev, mp); } +/* +* Replicate what the default ->reset hook does: free the state pointer and +* allocate a new empty object. We just need enough space to store +* a malidp_plane_state instead of a drm_plane_state. +*/ +static void malidp_plane_reset (struct drm_plane *plane) +{ +struct malidp_plane_state *state =to_malidp_plane_state (plane->state); + +if (state) +__drm_atomic_helper_plane_destroy_state (&state->base); +kfree (state); + plane->state =NULL ; + state =kzalloc (sizeof (*state),GFP_KERNEL ); +if (state) { + state->base.plane = plane; + state->base.rotation =DRM_ROTATE_0 ; + plane->state = &state->base; + } +} +static struct drm_plane_state *malidp_duplicate_plane_state (struct drm_plane *plane) {
@@ -106,7 +127,7 @@ static const struct drm_plane_funcs malidp_de_plane_funcs = { .disable_plane = drm_atomic_helper_disable_plane, .set_property = drm_atomic_helper_plane_set_property, .destroy = malidp_de_plane_destroy, - .reset = drm_atomic_helper_plane_reset, + .reset = malidp_plane_reset, .atomic_duplicate_state = malidp_duplicate_plane_state, .atomic_destroy_state = malidp_destroy_plane_state, .atomic_print_state = malidp_plane_atomic_print_state,
Signature · 6 lines
2.12.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Liviu Dudau
maintainerPATCH 6/12 drm: mali-dp: add malidp_crtc_state struct
In reply to Liviu DudauFrom: Mihail Atanassov <[email protected]>
Add a custom CRTC state struct to enable storing driver's private state. This patch only adds the base drm_crtc_state struct and the atomic functions that handle it.
--- drivers/gpu/drm/arm/malidp_crtc.c | 52 ++++++++++++++++++++++++++++++++++++--- drivers/gpu/drm/arm/malidp_drv.h | 6 +++++ 2 files changed, 55 insertions(+), 3 deletions(-)
drivers/gpu/drm/arm/malidp_crtc.c +49 -3
@@ -178,6 +178,52 @@ static const struct drm_crtc_helper_funcs malidp_crtc_helper_funcs = { .atomic_check = malidp_crtc_atomic_check, }; +static struct drm_crtc_state *malidp_crtc_duplicate_state (struct drm_crtc *crtc) +{ +struct malidp_crtc_state *state; + +if (WARN_ON (!crtc->state)) +return NULL ; + + state =kmalloc (sizeof (*state),GFP_KERNEL ); +if (!state) +return NULL ; + +__drm_atomic_helper_crtc_duplicate_state (crtc, &state->base); + +return &state->base; +} + +static void malidp_crtc_reset (struct drm_crtc *crtc) +{ +struct malidp_crtc_state *state =NULL ; + +if (crtc->state) { + state =to_malidp_crtc_state (crtc->state); +__drm_atomic_helper_crtc_destroy_state (crtc->state); + } + +kfree (state); + state =kzalloc (sizeof (*state),GFP_KERNEL ); +if (state) { + crtc->state = &state->base; + crtc->state->crtc = crtc; + } +} + +static void malidp_crtc_destroy_state (struct drm_crtc *crtc, +struct drm_crtc_state *state) +{ +struct malidp_crtc_state *mali_state =NULL ; + +if (state) { + mali_state =to_malidp_crtc_state (state); +__drm_atomic_helper_crtc_destroy_state (state); + } + +kfree (mali_state); +} +static int malidp_crtc_enable_vblank (struct drm_crtc *crtc) {struct malidp_drm *malidp =crtc_to_malidp_device (crtc);
@@ -201,9 +247,9 @@ static const struct drm_crtc_funcs malidp_crtc_funcs = { .destroy = drm_crtc_cleanup, .set_config = drm_atomic_helper_set_config, .page_flip = drm_atomic_helper_page_flip, - .reset = drm_atomic_helper_crtc_reset, - .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state, - .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state, + .reset = malidp_crtc_reset, + .atomic_duplicate_state = malidp_crtc_duplicate_state, + .atomic_destroy_state = malidp_crtc_destroy_state, .enable_vblank = malidp_crtc_enable_vblank, .disable_vblank = malidp_crtc_disable_vblank, };
drivers/gpu/drm/arm/malidp_drv.h +6 -0
@@ -48,6 +48,12 @@ struct malidp_plane_state {#define to_malidp_plane (x) container_of(x, struct malidp_plane, base)#define to_malidp_plane_state (x) container_of(x, struct malidp_plane_state, base) +struct malidp_crtc_state { +struct drm_crtc_state base; +}; + +#define to_malidp_crtc_state (x) container_of(x, struct malidp_crtc_state, base) +int malidp_de_planes_init (struct drm_device *drm);void malidp_de_planes_destroy (struct drm_device *drm);int malidp_crtc_init (struct drm_device *drm);
Signature · 6 lines
2.12.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Liviu Dudau
maintainerPATCH 7/12 drm: mali-dp: enable gamma support
In reply to Liviu DudauFrom: Mihail Atanassov <[email protected]>
Add gamma via the DRM GAMMA_LUT/GAMMA_LUT_SIZE CRTC properties. The expected LUT size is 4096 in order to produce as accurate a set of segments as possible.
This version uses only the green channel's gamma curve to set the hardware curve on DP550/650. For the sake of simplicity, it uses the same table of coefficients for all 3 curves on DP500.
--- drivers/gpu/drm/arm/malidp_crtc.c | 122 ++++++++++++++++++++++++++++++++++++-- drivers/gpu/drm/arm/malidp_drv.c | 51 ++++++++++++++++ drivers/gpu/drm/arm/malidp_drv.h | 1 + drivers/gpu/drm/arm/malidp_hw.c | 3 + drivers/gpu/drm/arm/malidp_hw.h | 6 ++ drivers/gpu/drm/arm/malidp_regs.h | 22 ++++++- 6 files changed, 196 insertions(+), 9 deletions(-)
drivers/gpu/drm/arm/malidp_crtc.c +116 -6
@@ -93,6 +93,108 @@ static void malidp_crtc_disable(struct drm_crtc *crtc) } } +static const struct gamma_curve_segment { +u16 start; +u16 end; +} segments[MALIDP_COEFFTAB_NUM_COEFFS ] = { +/* sector 0 */ + {0 ,0 }, {1 ,1 }, {2 ,2 }, {3 ,3 }, + {4 ,4 }, {5 ,5 }, {6 ,6 }, {7 ,7 }, + {8 ,8 }, {9 ,9 }, {10 ,10 }, {11 ,11 }, + {12 ,12 }, {13 ,13 }, {14 ,14 }, {15 ,15 }, +/* sector 1 */ + {16 ,19 }, {20 ,23 }, {24 ,27 }, {28 ,31 }, +/* sector 2 */ + {32 ,39 }, {40 ,47 }, {48 ,55 }, {56 ,63 }, +/* sector 3 */ + {64 ,79 }, {80 ,95 }, {96 ,111 }, {112 ,127 }, +/* sector 4 */ + {128 ,159 }, {160 ,191 }, {192 ,223 }, {224 ,255 }, +/* sector 5 */ + {256 ,319 }, {320 ,383 }, {384 ,447 }, {448 ,511 }, +/* sector 6 */ + {512 ,639 }, {640 ,767 }, {768 ,895 }, {896 ,1023 }, + {1024 ,1151 }, {1152 ,1279 }, {1280 ,1407 }, {1408 ,1535 }, + {1536 ,1663 }, {1664 ,1791 }, {1792 ,1919 }, {1920 ,2047 }, + {2048 ,2175 }, {2176 ,2303 }, {2304 ,2431 }, {2432 ,2559 }, + {2560 ,2687 }, {2688 ,2815 }, {2816 ,2943 }, {2944 ,3071 }, + {3072 ,3199 }, {3200 ,3327 }, {3328 ,3455 }, {3456 ,3583 }, + {3584 ,3711 }, {3712 ,3839 }, {3840 ,3967 }, {3968 ,4095 }, +}; + +#define DE_COEFTAB_DATA (a, b) ((((a) & 0xfff) << 16) | (((b) & 0xfff))) + +static void malidp_generate_gamma_table (struct drm_property_blob *lut_blob, +u32 coeffs[MALIDP_COEFFTAB_NUM_COEFFS ]) +{ +struct drm_color_lut *lut = (struct drm_color_lut *)lut_blob->data; +int i; + +for (i =0 ; i <MALIDP_COEFFTAB_NUM_COEFFS ; ++i) { +u32 a, b, delta_in, out_start, out_end; + + delta_in = segments[i].end - segments[i].start; +/* DP has 12-bit internal precision for its LUTs. */ + out_start =drm_color_lut_extract (lut[segments[i].start].green, +12 ); + out_end =drm_color_lut_extract (lut[segments[i].end].green,12 ); + a = (delta_in ==0 ) ?0 : ((out_end - out_start) *256 ) / delta_in; + b = out_start; + coeffs[i] =DE_COEFTAB_DATA (a, b); + } +} + +/* +* Check if there is a new gamma LUT and if it is of an acceptable size. Also, +* reject any LUTs that use distinct red, green, and blue curves. +*/ +static int malidp_crtc_atomic_check_gamma (struct drm_crtc *crtc, +struct drm_crtc_state *state) +{ +struct malidp_crtc_state *mc =to_malidp_crtc_state (state); +struct drm_color_lut *lut; +size_t lut_size; +int i; + +if (!state->color_mgmt_changed || !state->gamma_lut) +return 0 ; + +if (crtc->state->gamma_lut && + (crtc->state->gamma_lut->base.id == state->gamma_lut->base.id)) +return 0 ; + +if (state->gamma_lut->length %sizeof (struct drm_color_lut )) +return -EINVAL ; + + lut_size = state->gamma_lut->length /sizeof (struct drm_color_lut ); +if (lut_size !=MALIDP_GAMMA_LUT_SIZE ) +return -EINVAL ; + + lut = (struct drm_color_lut *)state->gamma_lut->data; +for (i =0 ; i < lut_size; ++i) +if (!((lut[i].red == lut[i].green) && + (lut[i].red == lut[i].blue))) +return -EINVAL ; + +if (!state->mode_changed) { +int ret; + + state->mode_changed = true; +/* +* Kerneldoc for drm_atomic_helper_check_modeset mandates that +* it be invoked when the driver sets ->mode_changed. Since +* changing the gamma LUT doesn't depend on any external +* resources, it is safe to call it only once. +*/ + ret =drm_atomic_helper_check_modeset (crtc->dev, state->state); +if (ret) +return ret; + } + +malidp_generate_gamma_table (state->gamma_lut, mc->gamma_coeffs); +return 0 ; +} +static int malidp_crtc_atomic_check (struct drm_crtc *crtc,struct drm_crtc_state *state) {
@@ -168,7 +270,7 @@ static int malidp_crtc_atomic_check(struct drm_crtc *crtc, } } -return 0 ; +return malidp_crtc_atomic_check_gamma (crtc, state); }static const struct drm_crtc_helper_funcs malidp_crtc_helper_funcs = {
@@ -180,16 +282,19 @@ static const struct drm_crtc_helper_funcs malidp_crtc_helper_funcs = {static struct drm_crtc_state *malidp_crtc_duplicate_state (struct drm_crtc *crtc) { -struct malidp_crtc_state *state; +struct malidp_crtc_state *state, *old_state;if (WARN_ON (!crtc->state))return NULL ; + old_state =to_malidp_crtc_state (crtc->state); state =kmalloc (sizeof (*state),GFP_KERNEL );if (!state)return NULL ;__drm_atomic_helper_crtc_duplicate_state (crtc, &state->base); +memcpy (state->gamma_coeffs, old_state->gamma_coeffs, +sizeof (state->gamma_coeffs));return &state->base; }
@@ -244,6 +349,7 @@ static void malidp_crtc_disable_vblank(struct drm_crtc *crtc) }static const struct drm_crtc_funcs malidp_crtc_funcs = { + .gamma_set = drm_atomic_helper_legacy_gamma_set, .destroy = drm_crtc_cleanup, .set_config = drm_atomic_helper_set_config, .page_flip = drm_atomic_helper_page_flip,
@@ -281,11 +387,15 @@ int malidp_crtc_init(struct drm_device *drm) ret =drm_crtc_init_with_planes (drm, &malidp->crtc, primary,NULL , &malidp_crtc_funcs,NULL ); +if (ret) + goto crtc_cleanup_planes; -if (!ret) { -drm_crtc_helper_add (&malidp->crtc, &malidp_crtc_helper_funcs); -return 0 ; - } +drm_crtc_helper_add (&malidp->crtc, &malidp_crtc_helper_funcs); +drm_mode_crtc_set_gamma_size (&malidp->crtc,MALIDP_GAMMA_LUT_SIZE ); +/* No inverse-gamma and color adjustments yet. */ +drm_crtc_enable_color_mgmt (&malidp->crtc,0 , false,MALIDP_GAMMA_LUT_SIZE ); + +return 0 ; crtc_cleanup_planes:malidp_de_planes_destroy (drm);
drivers/gpu/drm/arm/malidp_drv.c +51 -0
68 lines not on this page · raw message
drivers/gpu/drm/arm/malidp_drv.h +1 -0
@@ -50,6 +50,7 @@ struct malidp_plane_state {struct malidp_crtc_state {struct drm_crtc_state base; +u32 gamma_coeffs[MALIDP_COEFFTAB_NUM_COEFFS ]; };#define to_malidp_crtc_state (x) container_of(x, struct malidp_crtc_state, base)
drivers/gpu/drm/arm/malidp_hw.c +3 -0
@@ -415,6 +415,7 @@ static int malidp650_query_hw(struct malidp_hw_device *hwdev)const struct malidp_hw_device malidp_device[MALIDP_MAX_DEVICES ] = { [MALIDP_500 ] = { .map = { + .coeffs_base =MALIDP500_COEFFS_BASE , .se_base =MALIDP500_SE_BASE , .dc_base =MALIDP500_DC_BASE , .out_depth_base =MALIDP500_OUTPUT_DEPTH ,
@@ -451,6 +452,7 @@ const struct malidp_hw_device malidp_device[MALIDP_MAX_DEVICES] = { }, [MALIDP_550] = { .map = { + .coeffs_base = MALIDP550_COEFFS_BASE, .se_base = MALIDP550_SE_BASE, .dc_base = MALIDP550_DC_BASE, .out_depth_base = MALIDP550_DE_OUTPUT_DEPTH,
@@ -485,6 +487,7 @@ const struct malidp_hw_device malidp_device[MALIDP_MAX_DEVICES] = { }, [MALIDP_650] = { .map = { + .coeffs_base = MALIDP550_COEFFS_BASE, .se_base = MALIDP550_SE_BASE, .dc_base = MALIDP550_DC_BASE, .out_depth_base = MALIDP550_DE_OUTPUT_DEPTH,
drivers/gpu/drm/arm/malidp_hw.h +6 -0
@@ -67,6 +67,8 @@ struct malidp_layer {struct malidp_hw_regmap {/* address offset of the DE register bank */ /* is always 0x0000 */ +/* address offset of the DE coefficients registers */ +const u16 coeffs_base;/* address offset of the SE registers bank */ const u16 se_base;/* address offset of the DC registers bank */
@@ -257,4 +259,8 @@ static inline bool malidp_hw_pitch_valid(struct malidp_hw_device *hwdev,#define MALIDP_BGND_COLOR_G 0x000#define MALIDP_BGND_COLOR_B 0x000 +#define MALIDP_COEFFTAB_NUM_COEFFS 64 + +#define MALIDP_GAMMA_LUT_SIZE 4096 +#endif /* __MALIDP_HW_H__ */
drivers/gpu/drm/arm/malidp_regs.h +19 -3
@@ -63,6 +63,7 @@/* bit masks that are common between products */ #define MALIDP_CFG_VALID (1 << 0) +#define MALIDP_DISP_FUNC_GAMMA (1 << 0)#define MALIDP_DISP_FUNC_ILACED (1 << 8)/* register offsets for IRQ management */
@@ -99,6 +100,11 @@#define MALIDP_PRODUCT_ID (__core_id) ((u32)(__core_id) >> 16) +/* register offsets relative to MALIDP5x0_COEFFS_BASE */ +#define MALIDP_COLOR_ADJ_COEF 0x00000 +#define MALIDP_COEF_TABLE_ADDR 0x00030 +#define MALIDP_COEF_TABLE_DATA 0x00034 +/* register offsets and bits specific to DP500 */ #define MALIDP500_ADDR_SPACE_SIZE 0x01000#define MALIDP500_DC_BASE 0x00000
@@ -120,6 +126,18 @@#define MALIDP500_COLOR_ADJ_COEF 0x00078#define MALIDP500_COEF_TABLE_ADDR 0x000a8#define MALIDP500_COEF_TABLE_DATA 0x000ac + +/* +* The YUV2RGB coefficients on the DP500 are not in the video layer's register +* block. They belong in a separate block above the layer's registers, hence +* the negative offset. +*/ +#define MALIDP500_LV_YUV2RGB ((s16)(-0xB8)) +/* +* To match DP550/650, the start of the coeffs registers is +* at COLORADJ_COEFF0 instead of at YUV_RGB_COEF1. +*/ +#define MALIDP500_COEFFS_BASE 0x00078#define MALIDP500_DE_LV_BASE 0x00100#define MALIDP500_DE_LV_PTR_BASE 0x00124#define MALIDP500_DE_LG1_BASE 0x00200
@@ -145,9 +163,7 @@#define MALIDP550_DE_DISP_SIDEBAND 0x00040#define MALIDP550_DE_BGND_COLOR 0x00044#define MALIDP550_DE_OUTPUT_DEPTH 0x0004c -#define MALIDP550_DE_COLOR_COEF 0x00050 -#define MALIDP550_DE_COEF_TABLE_ADDR 0x00080 -#define MALIDP550_DE_COEF_TABLE_DATA 0x00084 +#define MALIDP550_COEFFS_BASE 0x00050#define MALIDP550_DE_LV1_BASE 0x00100#define MALIDP550_DE_LV1_PTR_BASE 0x00124#define MALIDP550_DE_LV2_BASE 0x00200
Signature · 6 lines
2.12.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Liviu Dudau
maintainerPATCH 8/12 drm: mali-dp: Add CTM support
In reply to Liviu DudauFrom: Mihail Atanassov <[email protected]>
All DPs have a COLORADJ matrix which is applied prior to output gamma. Attach that to the CTM property. Also, ensure the input CTM's coefficients can fit in the DP registers' Q3.12 format.
--- drivers/gpu/drm/arm/malidp_crtc.c | 64 +++++++++++++++++++++++++++++++++++++-- drivers/gpu/drm/arm/malidp_drv.c | 35 ++++++++++++++++++++- drivers/gpu/drm/arm/malidp_drv.h | 1 + drivers/gpu/drm/arm/malidp_hw.h | 1 + drivers/gpu/drm/arm/malidp_regs.h | 1 + 5 files changed, 98 insertions(+), 4 deletions(-)
drivers/gpu/drm/arm/malidp_crtc.c +61 -3
@@ -195,6 +195,58 @@ static int malidp_crtc_atomic_check_gamma(struct drm_crtc *crtc,return 0 ; } +/* +* Check if there is a new CTM and if it contains valid input. Valid here means +* that the number is inside the representable range for a Q3.12 number, +* excluding truncating the fractional part of the input data. +* +* The COLORADJ registers can be changed atomically. +*/ +static int malidp_crtc_atomic_check_ctm (struct drm_crtc *crtc, +struct drm_crtc_state *state) +{ +struct malidp_crtc_state *mc =to_malidp_crtc_state (state); +struct drm_color_ctm *ctm; +int i; + +if (!state->color_mgmt_changed) +return 0 ; + +if (!state->ctm) +return 0 ; + +if (crtc->state->ctm && (crtc->state->ctm->base.id == + state->ctm->base.id)) +return 0 ; + +/* +* The size of the ctm is checked in +* drm_atomic_replace_property_blob_from_id. +*/ + ctm = (struct drm_color_ctm *)state->ctm->data; +for (i =0 ; i <ARRAY_SIZE (ctm->matrix); ++i) { +/* Convert from S31.32 to Q3.12. */ +s64 val = ctm->matrix[i]; +u32 mag = ((((u64 )val) & ~BIT_ULL (63 )) >>20 ) & +GENMASK_ULL (14 ,0 ); + +/* +* Convert to 2s complement and check the destination's top bit +* for overflow. NB: Can't check before converting or it'd +* incorrectly reject the case: +* sign == 1 +* mag == 0x2000 +*/ +if (val &BIT_ULL (63 )) + mag = ~mag +1 ; +if (!!(val &BIT_ULL (63 )) != !!(mag &BIT (14 ))) +return -EINVAL ; + mc->coloradj_coeffs[i] = mag; + } + +return 0 ; +} +static int malidp_crtc_atomic_check (struct drm_crtc *crtc,struct drm_crtc_state *state) {
@@ -204,6 +256,7 @@ static int malidp_crtc_atomic_check(struct drm_crtc *crtc,const struct drm_plane_state *pstate;u32 rot_mem_free, rot_mem_usable;int rotated_planes =0 ; +int ret;/* * check if there is enough rotation memory available for planes
@@ -270,7 +323,10 @@ static int malidp_crtc_atomic_check(struct drm_crtc *crtc, } } -return malidp_crtc_atomic_check_gamma (crtc, state); + ret =malidp_crtc_atomic_check_gamma (crtc, state); + ret = ret ? ret :malidp_crtc_atomic_check_ctm (crtc, state); + +return ret; }static const struct drm_crtc_helper_funcs malidp_crtc_helper_funcs = {
@@ -295,6 +351,8 @@ static struct drm_crtc_state *malidp_crtc_duplicate_state(struct drm_crtc *crtc)__drm_atomic_helper_crtc_duplicate_state (crtc, &state->base);memcpy (state->gamma_coeffs, old_state->gamma_coeffs,sizeof (state->gamma_coeffs)); +memcpy (state->coloradj_coeffs, old_state->coloradj_coeffs, +sizeof (state->coloradj_coeffs));return &state->base; }
@@ -392,8 +450,8 @@ int malidp_crtc_init(struct drm_device *drm)drm_crtc_helper_add (&malidp->crtc, &malidp_crtc_helper_funcs);drm_mode_crtc_set_gamma_size (&malidp->crtc,MALIDP_GAMMA_LUT_SIZE ); -/* No inverse-gamma and color adjustments yet. */ -drm_crtc_enable_color_mgmt (&malidp->crtc,0 , false,MALIDP_GAMMA_LUT_SIZE ); +/* No inverse-gamma: it is per-plane */ +drm_crtc_enable_color_mgmt (&malidp->crtc,0 , true,MALIDP_GAMMA_LUT_SIZE );return 0 ;
drivers/gpu/drm/arm/malidp_drv.c +34 -1
@@ -79,6 +79,37 @@ static void malidp_atomic_commit_update_gamma(struct drm_crtc *crtc, } } +static +void malidp_atomic_commit_update_coloradj (struct drm_crtc *crtc, +struct drm_crtc_state *old_state) +{ +struct malidp_drm *malidp =crtc_to_malidp_device (crtc); +struct malidp_hw_device *hwdev = malidp->dev; +int i; + +if (!crtc->state->color_mgmt_changed) +return ; + +if (!crtc->state->ctm) { +malidp_hw_clearbits (hwdev,MALIDP_DISP_FUNC_CADJ , +MALIDP_DE_DISPLAY_FUNC ); + }else { +struct malidp_crtc_state *mc = +to_malidp_crtc_state (crtc->state); + +if (!old_state->ctm || (crtc->state->ctm->base.id != + old_state->ctm->base.id)) +for (i =0 ; i <MALIDP_COLORADJ_NUM_COEFFS ; ++i) +malidp_hw_write (hwdev, + mc->coloradj_coeffs[i], + hwdev->map.coeffs_base + +MALIDP_COLOR_ADJ_COEF +4 * i); + +malidp_hw_setbits (hwdev,MALIDP_DISP_FUNC_CADJ , +MALIDP_DE_DISPLAY_FUNC ); + } +} +/* * set the "config valid" bit and wait until the hardware acts on it */
@@ -145,8 +176,10 @@ static void malidp_atomic_commit_tail(struct drm_atomic_state *state)drm_atomic_helper_commit_modeset_disables (drm, state); -for_each_crtc_in_state (state, crtc, old_crtc_state, i) +for_each_crtc_in_state (state, crtc, old_crtc_state, i) {malidp_atomic_commit_update_gamma (crtc, old_crtc_state); +malidp_atomic_commit_update_coloradj (crtc, old_crtc_state); + }drm_atomic_helper_commit_planes (drm, state,0 );
drivers/gpu/drm/arm/malidp_drv.h +1 -0
@@ -51,6 +51,7 @@ struct malidp_plane_state {struct malidp_crtc_state {struct drm_crtc_state base;u32 gamma_coeffs[MALIDP_COEFFTAB_NUM_COEFFS ]; +u32 coloradj_coeffs[MALIDP_COLORADJ_NUM_COEFFS ]; };#define to_malidp_crtc_state (x) container_of(x, struct malidp_crtc_state, base)
drivers/gpu/drm/arm/malidp_hw.h +1 -0
@@ -259,6 +259,7 @@ static inline bool malidp_hw_pitch_valid(struct malidp_hw_device *hwdev,#define MALIDP_BGND_COLOR_G 0x000#define MALIDP_BGND_COLOR_B 0x000 +#define MALIDP_COLORADJ_NUM_COEFFS 12#define MALIDP_COEFFTAB_NUM_COEFFS 64#define MALIDP_GAMMA_LUT_SIZE 4096
drivers/gpu/drm/arm/malidp_regs.h +1 -0
@@ -64,6 +64,7 @@/* bit masks that are common between products */ #define MALIDP_CFG_VALID (1 << 0)#define MALIDP_DISP_FUNC_GAMMA (1 << 0) +#define MALIDP_DISP_FUNC_CADJ (1 << 4)#define MALIDP_DISP_FUNC_ILACED (1 << 8)/* register offsets for IRQ management */
Signature · 6 lines
2.12.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Liviu Dudau
maintainerPATCH 9/12 drm/mali-dp: Add core_id file to the sysfs interface
In reply to Liviu DudauAdd a core_id file in the driver's sysfs directory, exposing the hardware CORE ID. This is useful to allow userspace to discover the hardware version used.
--- drivers/gpu/drm/arm/malidp_drv.c | 35 +++++++++++++++++++++++++++++++++++ drivers/gpu/drm/arm/malidp_drv.h | 1 + 2 files changed, 36 insertions(+)
drivers/gpu/drm/arm/malidp_drv.c +35 -0
@@ -371,6 +371,32 @@ static bool malidp_has_sufficient_address_space(const struct resource *res,return true; } +static ssize_t core_id_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct drm_device *drm =dev_get_drvdata (dev); +struct malidp_drm *malidp = drm->dev_private; + +return snprintf (buf,PAGE_SIZE ,"%08x\n" , malidp->core_id); +} + +DEVICE_ATTR_RO (core_id); + +static int malidp_init_sysfs (struct device *dev) +{ +int ret =device_create_file (dev, &dev_attr_core_id); + +if (ret) +DRM_ERROR ("failed to create device file for core_id\n" ); + +return ret; +} + +static void malidp_fini_sysfs (struct device *dev) +{ +device_remove_file (dev, &dev_attr_core_id); +} +#define MAX_OUTPUT_CHANNELS 3static int malidp_runtime_pm_suspend (struct device *dev)
@@ -503,6 +529,8 @@ static int malidp_bind(struct device *dev)DRM_INFO ("found ARM Mali-DP%3x version r%dp%d\n" , version >>16 , (version >>12 ) &0xf , (version >>8 ) &0xf ); + malidp->core_id = version; +/* set the number of lines used for output of RGB data */ ret = of_property_read_u8_array(dev->of_node, "arm,malidp-output-port-lines",
@@ -521,6 +549,10 @@ static int malidp_bind(struct device *dev)if (ret <0 ) goto query_hw_fail; + ret =malidp_init_sysfs (dev); +if (ret) + goto init_fail; +/* Set the CRTC's port so that the encoder component can find it */ malidp->crtc.port =of_graph_get_port_by_id (dev->of_node,0 );
@@ -580,6 +612,8 @@ static int malidp_bind(struct device *dev) bind_fail:of_node_put (malidp->crtc.port); malidp->crtc.port =NULL ; +init_fail: +malidp_fini_sysfs (dev);malidp_fini (drm); query_hw_fail:pm_runtime_put (dev);
@@ -614,6 +648,7 @@ static void malidp_unbind(struct device *dev)component_unbind_all (dev, drm);of_node_put (malidp->crtc.port); malidp->crtc.port =NULL ; +malidp_fini_sysfs (dev);malidp_fini (drm);pm_runtime_put (dev);if (pm_runtime_enabled (dev))
drivers/gpu/drm/arm/malidp_drv.h +1 -0
@@ -25,6 +25,7 @@ struct malidp_drm {wait_queue_head_t wq;atomic_t config_valid;struct drm_atomic_state *pm_state; +u32 core_id; };#define crtc_to_malidp_device (x) container_of(x, struct malidp_drm, crtc)
Signature · 6 lines
2.12.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Liviu Dudau
maintainerPATCH 10/12 drm: mali-dp: Add plane upscaling support
In reply to Liviu DudauFrom: Mihail Atanassov <[email protected]>
Enable the scaling engine for upscaling a single plane using the polyphase scaler. No image enhancement support or downscaling yet*, and composition result scaling is not implemented.
* Downscaling a plane requires mclk > pxlclk.
--- drivers/gpu/drm/arm/malidp_crtc.c | 80 +++++++++++++++++++++ drivers/gpu/drm/arm/malidp_drv.c | 47 ++++++++++++ drivers/gpu/drm/arm/malidp_drv.h | 3 + drivers/gpu/drm/arm/malidp_hw.c | 140 ++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/arm/malidp_hw.h | 45 ++++++++++++ drivers/gpu/drm/arm/malidp_planes.c | 75 ++++++++++++++----- drivers/gpu/drm/arm/malidp_regs.h | 36 ++++++++++ 7 files changed, 409 insertions(+), 17 deletions(-)
drivers/gpu/drm/arm/malidp_crtc.c +80 -0
@@ -247,6 +247,82 @@ static int malidp_crtc_atomic_check_ctm(struct drm_crtc *crtc,return 0 ; } +static int malidp_crtc_atomic_check_scaling (struct drm_crtc *crtc, +struct drm_crtc_state *state) +{ +struct malidp_crtc_state *cs =to_malidp_crtc_state (state); +struct malidp_se_config *s = &cs->scaler_config; +struct drm_plane *plane; +const struct drm_plane_state *pstate; +u32 h_upscale_factor =0 ;/* U16.16 */ +u32 v_upscale_factor =0 ;/* U16.16 */ +u8 scaling = cs->scaled_planes_mask; + +if (!scaling) { + s->scale_enable = false; +return 0 ; + } + +/* The scaling engine can only handle one plane at a time. */ +if (scaling & (scaling -1 )) +return -EINVAL ; + +drm_atomic_crtc_state_for_each_plane_state (plane, pstate, state) { +struct malidp_plane *mp =to_malidp_plane (plane); +u64 crtc_w, crtc_h; +u32 phase; + +if (!(mp->layer->id & scaling)) +continue ; + +/* +* Convert crtc_[w|h] to U32.32, then divide by U16.16 src_[w|h] +* to get the U16.16 result. +*/ + crtc_w = (u64 )pstate->crtc_w <<32 ; + crtc_h = (u64 )pstate->crtc_h <<32 ; + h_upscale_factor = (u32)(crtc_w / pstate->src_w); + v_upscale_factor = (u32)(crtc_h / pstate->src_h); + +/* Downscaling won't work when mclk == pxlclk. */ +if (!(h_upscale_factor >>16 ) || !(v_upscale_factor >>16 )) +return -EINVAL ; + + s->input_w = pstate->src_w >>16 ; + s->input_h = pstate->src_h >>16 ; + s->output_w = pstate->crtc_w; + s->output_h = pstate->crtc_h; + +#define SE_N_PHASE 4 +#define SE_SHIFT_N_PHASE 12 +/* Calculate initial_phase and delta_phase for horizontal. */ + phase = s->input_w; + s->h_init_phase = + ((phase <<SE_N_PHASE ) / s->output_w +1 ) /2 ; + + phase = s->input_w; + phase <<= (SE_SHIFT_N_PHASE +SE_N_PHASE ); + s->h_delta_phase = phase / s->output_w; + +/* Same for vertical. */ + phase = s->input_h; + s->v_init_phase = + ((phase <<SE_N_PHASE ) / s->output_h +1 ) /2 ; + + phase = s->input_h; + phase <<= (SE_SHIFT_N_PHASE +SE_N_PHASE ); + s->v_delta_phase = phase / s->output_h; +#undef SE_N_PHASE +#undef SE_SHIFT_N_PHASE + s->plane_src_id = mp->layer->id; + } + + s->scale_enable = true; + s->hcoeff =malidp_se_select_coeffs (h_upscale_factor); + s->vcoeff =malidp_se_select_coeffs (v_upscale_factor); +return 0 ; +} +static int malidp_crtc_atomic_check (struct drm_crtc *crtc,struct drm_crtc_state *state) {
@@ -325,6 +401,7 @@ static int malidp_crtc_atomic_check(struct drm_crtc *crtc, ret =malidp_crtc_atomic_check_gamma (crtc, state); ret = ret ? ret :malidp_crtc_atomic_check_ctm (crtc, state); + ret = ret ? ret :malidp_crtc_atomic_check_scaling (crtc, state);return ret; }
@@ -353,6 +430,9 @@ static struct drm_crtc_state *malidp_crtc_duplicate_state(struct drm_crtc *crtc) sizeof(state->gamma_coeffs));memcpy (state->coloradj_coeffs, old_state->coloradj_coeffs,sizeof (state->coloradj_coeffs)); +memcpy (&state->scaler_config, &old_state->scaler_config, +sizeof (state->scaler_config)); + state->scaled_planes_mask =0 ;return &state->base; }
drivers/gpu/drm/arm/malidp_drv.c +47 -0
59 lines not on this page · raw message
drivers/gpu/drm/arm/malidp_drv.h +3 -0
@@ -53,6 +53,9 @@ struct malidp_crtc_state {struct drm_crtc_state base;u32 gamma_coeffs[MALIDP_COEFFTAB_NUM_COEFFS ];u32 coloradj_coeffs[MALIDP_COLORADJ_NUM_COEFFS ]; +struct malidp_se_config scaler_config; +/* Bitfield of all the planes that have requested a scaled output. */ +u8 scaled_planes_mask; };#define to_malidp_crtc_state (x) container_of(x, struct malidp_crtc_state, base)
drivers/gpu/drm/arm/malidp_hw.c +140 -0
176 lines not on this page · raw message
drivers/gpu/drm/arm/malidp_hw.h +45 -0
63 lines not on this page · raw message
drivers/gpu/drm/arm/malidp_planes.c +58 -17
124 lines not on this page · raw message
drivers/gpu/drm/arm/malidp_regs.h +36 -0
@@ -106,6 +106,40 @@#define MALIDP_COEF_TABLE_ADDR 0x00030#define MALIDP_COEF_TABLE_DATA 0x00034 +/* Scaling engine registers and masks. */ +#define MALIDP_SE_SCALING_EN (1 << 0) +#define MALIDP_SE_ALPHA_EN (1 << 1) +#define MALIDP_SE_RGBO_IF_EN (1 << 4) +#define MALIDP550_SE_CTL_SEL_MASK 7 +#define MALIDP550_SE_CTL_VCSEL (x) \ + (((x) & MALIDP550_SE_CTL_SEL_MASK) << 20) +#define MALIDP550_SE_CTL_HCSEL (x) \ + (((x) & MALIDP550_SE_CTL_SEL_MASK) << 16) + +/* Blocks with offsets from SE_CONTROL register. */ +#define MALIDP_SE_LAYER_CONTROL 0x14 +#define MALIDP_SE_L0_IN_SIZE 0x00 +#define MALIDP_SE_L0_OUT_SIZE 0x04 +#define MALIDP_SE_SET_V_SIZE (x) (((x) & 0x1fff) << 16) +#define MALIDP_SE_SET_H_SIZE (x) (((x) & 0x1fff) << 0) +#define MALIDP_SE_SCALING_CONTROL 0x24 +#define MALIDP_SE_H_INIT_PH 0x00 +#define MALIDP_SE_H_DELTA_PH 0x04 +#define MALIDP_SE_V_INIT_PH 0x08 +#define MALIDP_SE_V_DELTA_PH 0x0c +#define MALIDP_SE_COEFFTAB_ADDR 0x10 +#define MALIDP_SE_COEFFTAB_ADDR_MASK 0x7f +#define MALIDP_SE_V_COEFFTAB (1 << 8) +#define MALIDP_SE_H_COEFFTAB (1 << 9) +#define MALIDP_SE_SET_V_COEFFTAB_ADDR (x) \ + (MALIDP_SE_V_COEFFTAB | ((x) & MALIDP_SE_COEFFTAB_ADDR_MASK)) +#define MALIDP_SE_SET_H_COEFFTAB_ADDR (x) \ + (MALIDP_SE_H_COEFFTAB | ((x) & MALIDP_SE_COEFFTAB_ADDR_MASK)) +#define MALIDP_SE_COEFFTAB_DATA 0x14 +#define MALIDP_SE_COEFFTAB_DATA_MASK 0x3fff +#define MALIDP_SE_SET_COEFFTAB_DATA (x) \ + ((x) & MALIDP_SE_COEFFTAB_DATA_MASK) +/* register offsets and bits specific to DP500 */ #define MALIDP500_ADDR_SPACE_SIZE 0x01000#define MALIDP500_DC_BASE 0x00000
@@ -146,6 +180,7 @@#define MALIDP500_DE_LG2_BASE 0x00300#define MALIDP500_DE_LG2_PTR_BASE 0x0031c#define MALIDP500_SE_BASE 0x00c00 +#define MALIDP500_SE_CONTROL 0x00c0c#define MALIDP500_SE_PTR_BASE 0x00e0c#define MALIDP500_DC_IRQ_BASE 0x00f00#define MALIDP500_CONFIG_VALID 0x00f00
@@ -175,6 +210,7 @@#define MALIDP550_DE_LS_PTR_BASE 0x0042c#define MALIDP550_DE_PERF_BASE 0x00500#define MALIDP550_SE_BASE 0x08000 +#define MALIDP550_SE_CONTROL 0x08010#define MALIDP550_DC_BASE 0x0c000#define MALIDP550_DC_CONTROL 0x0c010#define MALIDP550_DC_CONFIG_REQ (1 << 16)
Signature · 6 lines
2.12.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Liviu Dudau
maintainerPATCH 11/12 drm: mali-dp: Enable image enhancement when scaling
In reply to Liviu DudauFrom: Mihail Atanassov <[email protected]>
Apply image enhacement when we are upscaling by a factor of 2 or more in either direction.
--- drivers/gpu/drm/arm/malidp_crtc.c | 7 ++++++- drivers/gpu/drm/arm/malidp_drv.c | 3 +++ drivers/gpu/drm/arm/malidp_hw.h | 20 ++++++++++++++++++++ drivers/gpu/drm/arm/malidp_regs.h | 13 +++++++++++++ 4 files changed, 42 insertions(+), 1 deletion(-)
drivers/gpu/drm/arm/malidp_crtc.c +6 -1
@@ -288,6 +288,9 @@ static int malidp_crtc_atomic_check_scaling(struct drm_crtc *crtc,if (!(h_upscale_factor >>16 ) || !(v_upscale_factor >>16 ))return -EINVAL ; + s->enhancer_enable = ((h_upscale_factor >>16 ) >=2 || + (v_upscale_factor >>16 ) >=2 ); + s->input_w = pstate->src_w >>16 ; s->input_h = pstate->src_h >>16 ; s->output_w = pstate->crtc_w;
@@ -530,9 +533,11 @@ int malidp_crtc_init(struct drm_device *drm)drm_crtc_helper_add (&malidp->crtc, &malidp_crtc_helper_funcs);drm_mode_crtc_set_gamma_size (&malidp->crtc,MALIDP_GAMMA_LUT_SIZE ); -/* No inverse-gamma: it is per-plane */ +/* No inverse-gamma: it is per-plane. */ drm_crtc_enable_color_mgmt (&malidp->crtc,0 , true,MALIDP_GAMMA_LUT_SIZE ); +malidp_se_set_enh_coeffs (malidp->dev); +return 0 ; crtc_cleanup_planes:
drivers/gpu/drm/arm/malidp_drv.c +3 -0
@@ -138,6 +138,9 @@ static void malidp_atomic_commit_se_config(struct drm_crtc *crtc, val =malidp_hw_read (hwdev, se_control); val |=MALIDP_SE_SCALING_EN |MALIDP_SE_ALPHA_EN ; + val &= ~MALIDP_SE_ENH (MALIDP_SE_ENH_MASK ); + val |= s->enhancer_enable ?MALIDP_SE_ENH (3 ) :0 ; + val |=MALIDP_SE_RGBO_IF_EN ;malidp_hw_write (hwdev, val, se_control);
drivers/gpu/drm/arm/malidp_hw.h +20 -0
@@ -71,6 +71,7 @@ enum malidp_scaling_coeff_set {struct malidp_se_config {u8 scale_enable :1 ; +u8 enhancer_enable :1 ;u8 hcoeff :3 ;u8 vcoeff :3 ;u8 plane_src_id;
@@ -295,6 +296,25 @@ malidp_se_select_coeffs(u32 upscale_factor)#undef FP_0_50000#undef FP_0_66667#undef FP_1_00000 + +static inline void malidp_se_set_enh_coeffs (struct malidp_hw_device *hwdev) +{ +static const s32 enhancer_coeffs[] = { +-8 ,-8 ,-8 ,-8 ,128 ,-8 ,-8 ,-8 ,-8 + }; +u32 val =MALIDP_SE_SET_ENH_LIMIT_LOW (MALIDP_SE_ENH_LOW_LEVEL ) | +MALIDP_SE_SET_ENH_LIMIT_HIGH (MALIDP_SE_ENH_HIGH_LEVEL ); +u32 image_enh = hwdev->map.se_base + + ((hwdev->map.features &MALIDP_REGMAP_HAS_CLEARIRQ ) ? +0x10 :0xC ) +MALIDP_SE_IMAGE_ENH ; +u32 enh_coeffs = image_enh +MALIDP_SE_ENH_COEFF0 ; +int i; + +malidp_hw_write (hwdev, val, image_enh); +for (i =0 ; i <ARRAY_SIZE (enhancer_coeffs); ++i) +malidp_hw_write (hwdev, enhancer_coeffs[i], enh_coeffs + i *4 ); +} +/* * background color components are defined as 12bits values, * they will be shifted right when stored on hardware that
drivers/gpu/drm/arm/malidp_regs.h +13 -0
@@ -109,6 +109,8 @@/* Scaling engine registers and masks. */ #define MALIDP_SE_SCALING_EN (1 << 0)#define MALIDP_SE_ALPHA_EN (1 << 1) +#define MALIDP_SE_ENH_MASK 3 +#define MALIDP_SE_ENH (x) (((x) & MALIDP_SE_ENH_MASK) << 2)#define MALIDP_SE_RGBO_IF_EN (1 << 4)#define MALIDP550_SE_CTL_SEL_MASK 7#define MALIDP550_SE_CTL_VCSEL (x) \
@@ -139,6 +141,17 @@#define MALIDP_SE_COEFFTAB_DATA_MASK 0x3fff#define MALIDP_SE_SET_COEFFTAB_DATA (x) \ ((x) & MALIDP_SE_COEFFTAB_DATA_MASK) +/* Enhance coeffents reigster offset */ +#define MALIDP_SE_IMAGE_ENH 0x3C +/* ENH_LIMITS offset 0x0 */ +#define MALIDP_SE_ENH_LOW_LEVEL 24 +#define MALIDP_SE_ENH_HIGH_LEVEL 63 +#define MALIDP_SE_ENH_LIMIT_MASK 0xfff +#define MALIDP_SE_SET_ENH_LIMIT_LOW (x) \ + ((x) & MALIDP_SE_ENH_LIMIT_MASK) +#define MALIDP_SE_SET_ENH_LIMIT_HIGH (x) \ + (((x) & MALIDP_SE_ENH_LIMIT_MASK) << 16) +#define MALIDP_SE_ENH_COEFF0 0x04/* register offsets and bits specific to DP500 */ #define MALIDP500_ADDR_SPACE_SIZE 0x01000
Signature · 6 lines
2.12.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Liviu Dudau
maintainerPATCH 12/12 drm: mali-dp: Check the mclk rate and allow up/down scaling
In reply to Liviu DudauFrom: Mihail Atanassov <[email protected]>
When downscaling, mclk needs to be sufficiently higher than pxlclk in order to be able to fetch the higher-resolution data and produce output pixels. When not scaling, or when upscaling, mclk can be equal to pxlclk. Since the driver doesn't control mclk, just ensure that the requirement is satisfied with the current clock rate.
--- drivers/gpu/drm/arm/malidp_crtc.c | 23 ++++++------- drivers/gpu/drm/arm/malidp_hw.c | 70 +++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/arm/malidp_hw.h | 4 +++ 3 files changed, 85 insertions(+), 12 deletions(-)
drivers/gpu/drm/arm/malidp_crtc.c +11 -12
@@ -36,13 +36,6 @@ static bool malidp_crtc_mode_fixup(struct drm_crtc *crtc,long rate, req_rate = mode->crtc_clock *1000 ;if (req_rate) { - rate =clk_round_rate (hwdev->mclk, req_rate); -if (rate < req_rate) { -DRM_DEBUG_DRIVER ("mclk clock unable to reach %d kHz\n" , - mode->crtc_clock); -return false; - } - rate =clk_round_rate (hwdev->pxlclk, req_rate);if (rate != req_rate) { DRM_DEBUG_DRIVER("pxlclk doesn't support %ld Hz\n",
@@ -250,17 +243,21 @@ static int malidp_crtc_atomic_check_ctm(struct drm_crtc *crtc,static int malidp_crtc_atomic_check_scaling (struct drm_crtc *crtc,struct drm_crtc_state *state) { +struct malidp_drm *malidp =crtc_to_malidp_device (crtc); +struct malidp_hw_device *hwdev = malidp->dev;struct malidp_crtc_state *cs =to_malidp_crtc_state (state);struct malidp_se_config *s = &cs->scaler_config;struct drm_plane *plane; +struct videomode vm;const struct drm_plane_state *pstate;u32 h_upscale_factor =0 ;/* U16.16 */ u32 v_upscale_factor =0 ;/* U16.16 */ u8 scaling = cs->scaled_planes_mask; +int ret;if (!scaling) { s->scale_enable = false; -return 0 ; + goto mclk_calc; }/* The scaling engine can only handle one plane at a time. */
@@ -284,10 +281,6 @@ static int malidp_crtc_atomic_check_scaling(struct drm_crtc *crtc, h_upscale_factor = (u32)(crtc_w / pstate->src_w); v_upscale_factor = (u32)(crtc_h / pstate->src_h); -/* Downscaling won't work when mclk == pxlclk. */ -if (!(h_upscale_factor >>16 ) || !(v_upscale_factor >>16 )) -return -EINVAL ; - s->enhancer_enable = ((h_upscale_factor >>16 ) >=2 || (v_upscale_factor >>16 ) >=2 );
@@ -323,6 +316,12 @@ static int malidp_crtc_atomic_check_scaling(struct drm_crtc *crtc, s->scale_enable = true; s->hcoeff =malidp_se_select_coeffs (h_upscale_factor); s->vcoeff =malidp_se_select_coeffs (v_upscale_factor); + +mclk_calc: +drm_display_mode_to_videomode (&state->adjusted_mode, &vm); + ret = hwdev->se_calc_mclk (hwdev, s, &vm); +if (ret <0 ) +return -EINVAL ;return 0 ; }
drivers/gpu/drm/arm/malidp_hw.c +70 -0
106 lines not on this page · raw message
drivers/gpu/drm/arm/malidp_hw.h +4 -0
@@ -177,6 +177,10 @@ struct malidp_hw_device {struct malidp_se_config *se_config, struct malidp_se_config *old_config); +long (*se_calc_mclk)(struct malidp_hw_device *hwdev, +struct malidp_se_config *se_config, +struct videomode *vm); +u8 features;u8 min_line_size;
Signature · 6 lines
2.12.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel