@@ -474,6 +474,8 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
474
474
DRM_DEBUG_DRIVER ("amdgpu: freesync_module init done %p.\n" ,
475
475
adev -> dm .freesync_module );
476
476
477
+ amdgpu_dm_init_color_mod ();
478
+
477
479
if (amdgpu_dm_initialize_drm_device (adev )) {
478
480
DRM_ERROR (
479
481
"amdgpu: failed to initialize sw for display support.\n" );
@@ -1953,32 +1955,6 @@ static int fill_plane_attributes_from_fb(struct amdgpu_device *adev,
1953
1955
1954
1956
}
1955
1957
1956
- static void fill_gamma_from_crtc_state (const struct drm_crtc_state * crtc_state ,
1957
- struct dc_plane_state * plane_state )
1958
- {
1959
- int i ;
1960
- struct dc_gamma * gamma ;
1961
- struct drm_color_lut * lut =
1962
- (struct drm_color_lut * ) crtc_state -> gamma_lut -> data ;
1963
-
1964
- gamma = dc_create_gamma ();
1965
-
1966
- if (gamma == NULL ) {
1967
- WARN_ON (1 );
1968
- return ;
1969
- }
1970
-
1971
- gamma -> type = GAMMA_RGB_256 ;
1972
- gamma -> num_entries = GAMMA_RGB_256_ENTRIES ;
1973
- for (i = 0 ; i < GAMMA_RGB_256_ENTRIES ; i ++ ) {
1974
- gamma -> entries .red [i ] = dal_fixed31_32_from_int (lut [i ].red );
1975
- gamma -> entries .green [i ] = dal_fixed31_32_from_int (lut [i ].green );
1976
- gamma -> entries .blue [i ] = dal_fixed31_32_from_int (lut [i ].blue );
1977
- }
1978
-
1979
- plane_state -> gamma_correction = gamma ;
1980
- }
1981
-
1982
1958
static int fill_plane_attributes (struct amdgpu_device * adev ,
1983
1959
struct dc_plane_state * dc_plane_state ,
1984
1960
struct drm_plane_state * plane_state ,
@@ -2006,14 +1982,13 @@ static int fill_plane_attributes(struct amdgpu_device *adev,
2006
1982
if (input_tf == NULL )
2007
1983
return - ENOMEM ;
2008
1984
2009
- input_tf -> type = TF_TYPE_PREDEFINED ;
2010
- input_tf -> tf = TRANSFER_FUNCTION_SRGB ;
2011
-
2012
1985
dc_plane_state -> in_transfer_func = input_tf ;
2013
1986
2014
- /* In case of gamma set, update gamma value */
2015
- if (crtc_state -> gamma_lut )
2016
- fill_gamma_from_crtc_state (crtc_state , dc_plane_state );
1987
+ /*
1988
+ * Always set input transfer function, since plane state is refreshed
1989
+ * every time.
1990
+ */
1991
+ ret = amdgpu_dm_set_degamma_lut (crtc_state , dc_plane_state );
2017
1992
2018
1993
return ret ;
2019
1994
}
@@ -3227,6 +3202,7 @@ static int amdgpu_dm_crtc_init(struct amdgpu_display_manager *dm,
3227
3202
acrtc -> base .enabled = false;
3228
3203
3229
3204
dm -> adev -> mode_info .crtcs [crtc_index ] = acrtc ;
3205
+ drm_crtc_enable_color_mgmt (& acrtc -> base , 256 , true, 256 );
3230
3206
drm_mode_crtc_set_gamma_size (& acrtc -> base , 256 );
3231
3207
3232
3208
return 0 ;
@@ -4640,6 +4616,30 @@ static int dm_update_crtcs_state(struct dc *dc,
4640
4616
/* Release extra reference */
4641
4617
if (new_stream )
4642
4618
dc_stream_release (new_stream );
4619
+
4620
+ /*
4621
+ * We want to do dc stream updates that do not require a
4622
+ * full modeset below.
4623
+ */
4624
+ if (!enable || !aconnector || modereset_required (new_crtc_state ))
4625
+ continue ;
4626
+ /*
4627
+ * Given above conditions, the dc state cannot be NULL because:
4628
+ * 1. We're attempting to enable a CRTC. Which has a...
4629
+ * 2. Valid connector attached, and
4630
+ * 3. User does not want to reset it (disable or mark inactive,
4631
+ * which can happen on a CRTC that's already disabled).
4632
+ * => It currently exists.
4633
+ */
4634
+ BUG_ON (dm_new_crtc_state -> stream == NULL );
4635
+
4636
+ /* Color managment settings */
4637
+ if (dm_new_crtc_state -> base .color_mgmt_changed ) {
4638
+ ret = amdgpu_dm_set_regamma_lut (dm_new_crtc_state );
4639
+ if (ret )
4640
+ goto fail ;
4641
+ amdgpu_dm_set_ctm (dm_new_crtc_state );
4642
+ }
4643
4643
}
4644
4644
4645
4645
return ret ;
@@ -4748,7 +4748,6 @@ static int dm_update_planes_state(struct dc *dc,
4748
4748
if (ret )
4749
4749
return ret ;
4750
4750
4751
-
4752
4751
if (!dc_add_plane_to_context (
4753
4752
dc ,
4754
4753
dm_new_crtc_state -> stream ,
0 commit comments