diff options
-rw-r--r-- | drivers/gpu/drm/i915/intel_dp.c | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index 1f2420cbe06a..53fc1b3f6770 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c | |||
@@ -161,33 +161,23 @@ static u8 intel_dp_max_lane_count(struct intel_dp *intel_dp) | |||
161 | return min(source_max, sink_max); | 161 | return min(source_max, sink_max); |
162 | } | 162 | } |
163 | 163 | ||
164 | /* | ||
165 | * The units on the numbers in the next two are... bizarre. Examples will | ||
166 | * make it clearer; this one parallels an example in the eDP spec. | ||
167 | * | ||
168 | * intel_dp_max_data_rate for one lane of 2.7GHz evaluates as: | ||
169 | * | ||
170 | * 270000 * 1 * 8 / 10 == 216000 | ||
171 | * | ||
172 | * The actual data capacity of that configuration is 2.16Gbit/s, so the | ||
173 | * units are decakilobits. ->clock in a drm_display_mode is in kilohertz - | ||
174 | * or equivalently, kilopixels per second - so for 1680x1050R it'd be | ||
175 | * 119000. At 18bpp that's 2142000 kilobits per second. | ||
176 | * | ||
177 | * Thus the strange-looking division by 10 in intel_dp_link_required, to | ||
178 | * get the result in decakilobits instead of kilobits. | ||
179 | */ | ||
180 | |||
181 | static int | 164 | static int |
182 | intel_dp_link_required(int pixel_clock, int bpp) | 165 | intel_dp_link_required(int pixel_clock, int bpp) |
183 | { | 166 | { |
184 | return (pixel_clock * bpp + 9) / 10; | 167 | /* pixel_clock is in kHz, divide bpp by 8 for bit to Byte conversion */ |
168 | return DIV_ROUND_UP(pixel_clock * bpp, 8); | ||
185 | } | 169 | } |
186 | 170 | ||
187 | static int | 171 | static int |
188 | intel_dp_max_data_rate(int max_link_clock, int max_lanes) | 172 | intel_dp_max_data_rate(int max_link_clock, int max_lanes) |
189 | { | 173 | { |
190 | return (max_link_clock * max_lanes * 8) / 10; | 174 | /* max_link_clock is the link symbol clock (LS_Clk) in kHz and not the |
175 | * link rate that is generally expressed in Gbps. Since, 8 bits of data | ||
176 | * is transmitted every LS_Clk per lane, there is no need to account for | ||
177 | * the channel encoding that is done in the PHY layer here. | ||
178 | */ | ||
179 | |||
180 | return max_link_clock * max_lanes; | ||
191 | } | 181 | } |
192 | 182 | ||
193 | static int | 183 | static int |
@@ -3573,7 +3563,12 @@ intel_edp_init_dpcd(struct intel_dp *intel_dp) | |||
3573 | if (val == 0) | 3563 | if (val == 0) |
3574 | break; | 3564 | break; |
3575 | 3565 | ||
3576 | /* Value read is in kHz while drm clock is saved in deca-kHz */ | 3566 | /* Value read multiplied by 200kHz gives the per-lane |
3567 | * link rate in kHz. The source rates are, however, | ||
3568 | * stored in terms of LS_Clk kHz. The full conversion | ||
3569 | * back to symbols is | ||
3570 | * (val * 200kHz)*(8/10 ch. encoding)*(1/8 bit to Byte) | ||
3571 | */ | ||
3577 | intel_dp->sink_rates[i] = (val * 200) / 10; | 3572 | intel_dp->sink_rates[i] = (val * 200) / 10; |
3578 | } | 3573 | } |
3579 | intel_dp->num_sink_rates = i; | 3574 | intel_dp->num_sink_rates = i; |