[Intel-gfx] [PATCH v7 04/23] drm/i915/dsi: abstract intel_dsi_tlpx_ns()

Madhav Chauhan madhav.chauhan at intel.com
Sat Oct 20 10:38:29 UTC 2018


On 10/16/2018 6:36 PM, Jani Nikula wrote:
> On Tue, 16 Oct 2018, Madhav Chauhan <madhav.chauhan at intel.com> wrote:
>> On 10/15/2018 7:57 PM, Jani Nikula wrote:
>>> Will be needed in the future. No functional changes.
>> Agree, will be needing this while setting up DSI protocol timeouts for ICL.
>>
>>> Cc: Madhav Chauhan <madhav.chauhan at intel.com>
>>> Cc: Ville Syrjala <ville.syrjala at linux.intel.com>
>>> Signed-off-by: Jani Nikula <jani.nikula at intel.com>
>>> ---
>>>    drivers/gpu/drm/i915/intel_dsi.c     | 13 +++++++++++++
>>>    drivers/gpu/drm/i915/intel_dsi.h     |  1 +
>>>    drivers/gpu/drm/i915/intel_dsi_vbt.c | 16 +---------------
>>>    3 files changed, 15 insertions(+), 15 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/i915/intel_dsi.c b/drivers/gpu/drm/i915/intel_dsi.c
>>> index 4daa1da94047..a32cc1f4b384 100644
>>> --- a/drivers/gpu/drm/i915/intel_dsi.c
>>> +++ b/drivers/gpu/drm/i915/intel_dsi.c
>>> @@ -15,3 +15,16 @@ int intel_dsi_bitrate(const struct intel_dsi *intel_dsi)
>>>    
>>>    	return intel_dsi->pclk * bpp / intel_dsi->lane_count;
>>>    }
>>> +
>>> +int intel_dsi_tlpx_ns(const struct intel_dsi *intel_dsi)
>>> +{
>>> +	switch (intel_dsi->escape_clk_div) {
>>> +	default:
>>> +	case 0:
>>> +		return 50;
>>> +	case 1:
>>> +		return 100;
>>> +	case 2:
>>> +		return 200;
>>> +	}
>>> +}
>> Can we change the return of this function to unsigned int, there is no way
>> that this function can return < 0  as per current implementation??
> I'd rather not. I'm sure I should be able to justify this exhaustively
> with examples, but I think gratuitous use of unsigned types leads to
> issues with integer promotions and signed/unsigned comparisons etc. So
> if it's "just a number", used for arithmetics, I'll pretty much choose
> int every time.
>
> And because you can silently assign negative numbers to unsigned types,
> it's not a good safeguard to ensure positive numbers. Unless you're
> happy with large positive numbers...
>
> Unsigned types are best for register contents, bits, masks, etc.

Agree with issues mentioned, i thought that should be case to case :),
but fine with uniform approach.
Reviewed-by: Madhav Chauhan <madhav.chauhan at intel.com>

Regards,
Madhav

>
>
> BR,
> Jani.
>
>
>> Regards,
>> Madhav
>>
>>> diff --git a/drivers/gpu/drm/i915/intel_dsi.h b/drivers/gpu/drm/i915/intel_dsi.h
>>> index 68f14d8f1e18..0d911a4adfaa 100644
>>> --- a/drivers/gpu/drm/i915/intel_dsi.h
>>> +++ b/drivers/gpu/drm/i915/intel_dsi.h
>>> @@ -131,6 +131,7 @@ static inline struct intel_dsi *enc_to_intel_dsi(struct drm_encoder *encoder)
>>>    
>>>    /* intel_dsi.c */
>>>    int intel_dsi_bitrate(const struct intel_dsi *intel_dsi);
>>> +int intel_dsi_tlpx_ns(const struct intel_dsi *intel_dsi);
>>>    
>>>    /* vlv_dsi.c */
>>>    void vlv_dsi_wait_for_fifo_empty(struct intel_dsi *intel_dsi, enum port port);
>>> diff --git a/drivers/gpu/drm/i915/intel_dsi_vbt.c b/drivers/gpu/drm/i915/intel_dsi_vbt.c
>>> index fdeba8386d53..b0d8548f0462 100644
>>> --- a/drivers/gpu/drm/i915/intel_dsi_vbt.c
>>> +++ b/drivers/gpu/drm/i915/intel_dsi_vbt.c
>>> @@ -512,21 +512,7 @@ static void vlv_dphy_param_init(struct intel_dsi *intel_dsi)
>>>    	u32 lp_to_hs_switch, hs_to_lp_switch;
>>>    	u32 mul;
>>>    
>>> -	switch (intel_dsi->escape_clk_div) {
>>> -	case 0:
>>> -		tlpx_ns = 50;
>>> -		break;
>>> -	case 1:
>>> -		tlpx_ns = 100;
>>> -		break;
>>> -
>>> -	case 2:
>>> -		tlpx_ns = 200;
>>> -		break;
>>> -	default:
>>> -		tlpx_ns = 50;
>>> -		break;
>>> -	}
>>> +	tlpx_ns = intel_dsi_tlpx_ns(intel_dsi);
>>>    
>>>    	switch (intel_dsi->lane_count) {
>>>    	case 1:



More information about the Intel-gfx mailing list