Skip to content

Commit a78f1b6

Browse files
ckborahjnikula
authored andcommitted
drm/i915/color: Add framework to program CSC
Add framework to program CSC. It enables copying of matrix from UAPI to intel plane state. Also add helper functions which will eventually program values to hardware. Add a crtc state variable to track plane color change. v2: - Add crtc_state->plane_color_changed - Improve comments (Suraj) - s/intel_plane_*_color/intel_plane_color_* (Suraj) v3: - align parameters with open braces (Suraj) - Improve commit message (Suraj) v4: - Re-arrange variable declaration (Suraj) Reviewed-by: Suraj Kandpal <suraj.kandpal@intel.com> Signed-off-by: Chaitanya Kumar Borah <chaitanya.kumar.borah@intel.com> Signed-off-by: Uma Shankar <uma.shankar@intel.com> Link: https://patch.msgid.link/20251203085211.3663374-6-uma.shankar@intel.com Signed-off-by: Jani Nikula <jani.nikula@intel.com>
1 parent ef10531 commit a78f1b6

4 files changed

Lines changed: 77 additions & 1 deletion

File tree

drivers/gpu/drm/i915/display/intel_color.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ struct intel_color_funcs {
8787
* Read config other than LUTs and CSCs, before them. Optional.
8888
*/
8989
void (*get_config)(struct intel_crtc_state *crtc_state);
90+
91+
/* Plane CSC*/
92+
void (*load_plane_csc_matrix)(struct intel_dsb *dsb,
93+
const struct intel_plane_state *plane_state);
9094
};
9195

9296
#define CTM_COEFF_SIGN (1ULL << 63)
@@ -3963,6 +3967,23 @@ static const struct intel_color_funcs ilk_color_funcs = {
39633967
.get_config = ilk_get_config,
39643968
};
39653969

3970+
static void
3971+
intel_color_load_plane_csc_matrix(struct intel_dsb *dsb,
3972+
const struct intel_plane_state *plane_state)
3973+
{
3974+
struct intel_display *display = to_intel_display(plane_state);
3975+
3976+
if (display->funcs.color->load_plane_csc_matrix)
3977+
display->funcs.color->load_plane_csc_matrix(dsb, plane_state);
3978+
}
3979+
3980+
void intel_color_plane_program_pipeline(struct intel_dsb *dsb,
3981+
const struct intel_plane_state *plane_state)
3982+
{
3983+
if (plane_state->hw.ctm)
3984+
intel_color_load_plane_csc_matrix(dsb, plane_state);
3985+
}
3986+
39663987
void intel_color_crtc_init(struct intel_crtc *crtc)
39673988
{
39683989
struct intel_display *display = to_intel_display(crtc);

drivers/gpu/drm/i915/display/intel_color.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ struct intel_crtc_state;
1313
struct intel_crtc;
1414
struct intel_display;
1515
struct intel_dsb;
16+
struct intel_plane_state;
1617
struct drm_property_blob;
1718

1819
void intel_color_init_hooks(struct intel_display *display);
@@ -40,5 +41,6 @@ bool intel_color_lut_equal(const struct intel_crtc_state *crtc_state,
4041
const struct drm_property_blob *blob2,
4142
bool is_pre_csc_lut);
4243
void intel_color_assert_luts(const struct intel_crtc_state *crtc_state);
43-
44+
void intel_color_plane_program_pipeline(struct intel_dsb *dsb,
45+
const struct intel_plane_state *plane_state);
4446
#endif /* __INTEL_COLOR_H__ */

drivers/gpu/drm/i915/display/intel_display_types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,7 @@ struct intel_plane_state {
646646
enum drm_color_encoding color_encoding;
647647
enum drm_color_range color_range;
648648
enum drm_scaling_filter scaling_filter;
649+
struct drm_property_blob *ctm;
649650
} hw;
650651

651652
struct i915_vma *ggtt_vma;
@@ -1391,6 +1392,9 @@ struct intel_crtc_state {
13911392
u8 silence_period_sym_clocks;
13921393
u8 lfps_half_cycle_num_of_syms;
13931394
} alpm_state;
1395+
1396+
/* to track changes in plane color blocks */
1397+
bool plane_color_changed;
13941398
};
13951399

13961400
enum intel_pipe_crc_source {

drivers/gpu/drm/i915/display/intel_plane.c

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#include "i9xx_plane_regs.h"
5050
#include "intel_cdclk.h"
5151
#include "intel_cursor.h"
52+
#include "intel_colorop.h"
5253
#include "intel_display_rps.h"
5354
#include "intel_display_trace.h"
5455
#include "intel_display_types.h"
@@ -336,6 +337,52 @@ intel_plane_copy_uapi_plane_damage(struct intel_plane_state *new_plane_state,
336337
*damage = drm_plane_state_src(&new_uapi_plane_state->uapi);
337338
}
338339

340+
static bool
341+
intel_plane_colorop_replace_blob(struct intel_plane_state *plane_state,
342+
struct intel_colorop *intel_colorop,
343+
struct drm_property_blob *blob)
344+
{
345+
if (intel_colorop->id == INTEL_PLANE_CB_CSC)
346+
return drm_property_replace_blob(&plane_state->hw.ctm, blob);
347+
348+
return false;
349+
}
350+
351+
static void
352+
intel_plane_color_copy_uapi_to_hw_state(struct intel_plane_state *plane_state,
353+
const struct intel_plane_state *from_plane_state,
354+
struct intel_crtc *crtc)
355+
{
356+
struct drm_colorop *iter_colorop, *colorop;
357+
struct drm_colorop_state *new_colorop_state;
358+
struct drm_atomic_state *state = plane_state->uapi.state;
359+
struct intel_colorop *intel_colorop;
360+
struct drm_property_blob *blob;
361+
struct intel_atomic_state *intel_atomic_state = to_intel_atomic_state(state);
362+
struct intel_crtc_state *new_crtc_state = intel_atomic_state ?
363+
intel_atomic_get_new_crtc_state(intel_atomic_state, crtc) : NULL;
364+
bool changed = false;
365+
int i = 0;
366+
367+
iter_colorop = plane_state->uapi.color_pipeline;
368+
369+
while (iter_colorop) {
370+
for_each_new_colorop_in_state(state, colorop, new_colorop_state, i) {
371+
if (new_colorop_state->colorop == iter_colorop) {
372+
blob = new_colorop_state->bypass ? NULL : new_colorop_state->data;
373+
intel_colorop = to_intel_colorop(colorop);
374+
changed |= intel_plane_colorop_replace_blob(plane_state,
375+
intel_colorop,
376+
blob);
377+
}
378+
}
379+
iter_colorop = iter_colorop->next;
380+
}
381+
382+
if (new_crtc_state && changed)
383+
new_crtc_state->plane_color_changed = true;
384+
}
385+
339386
void intel_plane_copy_uapi_to_hw_state(struct intel_plane_state *plane_state,
340387
const struct intel_plane_state *from_plane_state,
341388
struct intel_crtc *crtc)
@@ -364,6 +411,8 @@ void intel_plane_copy_uapi_to_hw_state(struct intel_plane_state *plane_state,
364411

365412
plane_state->uapi.src = drm_plane_state_src(&from_plane_state->uapi);
366413
plane_state->uapi.dst = drm_plane_state_dest(&from_plane_state->uapi);
414+
415+
intel_plane_color_copy_uapi_to_hw_state(plane_state, from_plane_state, crtc);
367416
}
368417

369418
void intel_plane_copy_hw_state(struct intel_plane_state *plane_state,

0 commit comments

Comments
 (0)