@@ -1644,7 +1644,7 @@ nv50_sor_dp_watermark_sst(struct nouveau_encoder *outp,
1644
1644
// 0 active symbols. This may cause HW hang. Bug 200379426
1645
1645
//
1646
1646
if ((bEnableDsc ) &&
1647
- ((pixelClockHz * depth ) < (( 8 * minRate * outp -> dp .link_nr * DSC_FACTOR ) / 64 )))
1647
+ ((pixelClockHz * depth ) < div_u64 ( 8 * minRate * outp -> dp .link_nr * DSC_FACTOR , 64 )))
1648
1648
{
1649
1649
return false;
1650
1650
}
@@ -1654,20 +1654,20 @@ nv50_sor_dp_watermark_sst(struct nouveau_encoder *outp,
1654
1654
// For auto mode the watermark calculation does not need to track accumulated error the
1655
1655
// formulas for manual mode will not work. So below calculation was extracted from the DTB.
1656
1656
//
1657
- ratioF = ((u64 )pixelClockHz * depth * PrecisionFactor ) / DSC_FACTOR ;
1657
+ ratioF = div_u64 ((u64 )pixelClockHz * depth * PrecisionFactor , DSC_FACTOR ) ;
1658
1658
1659
- ratioF /= 8 * (u64 ) minRate * outp -> dp .link_nr ;
1659
+ ratioF = div_u64 ( ratioF , 8 * (u64 ) minRate * outp -> dp .link_nr ) ;
1660
1660
1661
1661
if (PrecisionFactor < ratioF ) // Assert if we will end up with a negative number in below
1662
1662
return false;
1663
1663
1664
- watermarkF = ratioF * tuSize * (PrecisionFactor - ratioF ) / PrecisionFactor ;
1665
- waterMark = (unsigned )(watermarkAdjust + ((2 * (depth * PrecisionFactor / ( 8 * numLanesPerLink * DSC_FACTOR )) + watermarkF ) / PrecisionFactor ));
1664
+ watermarkF = div_u64 ( ratioF * tuSize * (PrecisionFactor - ratioF ), PrecisionFactor ) ;
1665
+ waterMark = (unsigned )(watermarkAdjust + (div_u64 (2 * div_u64 (depth * PrecisionFactor , 8 * numLanesPerLink * DSC_FACTOR ) + watermarkF , PrecisionFactor ) ));
1666
1666
1667
1667
//
1668
1668
// Bounds check the watermark
1669
1669
//
1670
- numSymbolsPerLine = (surfaceWidth * depth ) / ( 8 * outp -> dp .link_nr * DSC_FACTOR );
1670
+ numSymbolsPerLine = div_u64 (surfaceWidth * depth , 8 * outp -> dp .link_nr * DSC_FACTOR );
1671
1671
1672
1672
if (WARN_ON (waterMark > 39 || waterMark > numSymbolsPerLine ))
1673
1673
return false;
@@ -1688,11 +1688,13 @@ nv50_sor_dp_watermark_sst(struct nouveau_encoder *outp,
1688
1688
surfaceWidthPerLink = surfaceWidth ;
1689
1689
1690
1690
//Extra bits sent due to pixel steering
1691
- PixelSteeringBits = (surfaceWidthPerLink % numLanesPerLink ) ? (((numLanesPerLink - surfaceWidthPerLink % numLanesPerLink ) * depth ) / DSC_FACTOR ) : 0 ;
1691
+ u32 remain ;
1692
+ div_u64_rem (surfaceWidthPerLink , numLanesPerLink , & remain );
1693
+ PixelSteeringBits = remain ? div_u64 ((numLanesPerLink - remain ) * depth , DSC_FACTOR ) : 0 ;
1692
1694
1693
1695
BlankingBits += PixelSteeringBits ;
1694
- NumBlankingLinkClocks = ( u64 )BlankingBits * PrecisionFactor / (8 * numLanesPerLink );
1695
- MinHBlank = (u32 )(NumBlankingLinkClocks * pixelClockHz / minRate / PrecisionFactor );
1696
+ NumBlankingLinkClocks = div_u64 (( u64 )BlankingBits * PrecisionFactor , (8 * numLanesPerLink ) );
1697
+ MinHBlank = (u32 )(div_u64 ( div_u64 ( NumBlankingLinkClocks * pixelClockHz , minRate ), PrecisionFactor ) );
1696
1698
MinHBlank += 12 ;
1697
1699
1698
1700
if (WARN_ON (MinHBlank > rasterWidth - surfaceWidth ))
@@ -1703,7 +1705,7 @@ nv50_sor_dp_watermark_sst(struct nouveau_encoder *outp,
1703
1705
return false;
1704
1706
1705
1707
1706
- hblank_symbols = (s32 )(((u64 )(rasterWidth - surfaceWidth - MinHBlank ) * minRate ) / pixelClockHz );
1708
+ hblank_symbols = (s32 )(div_u64 ((u64 )(rasterWidth - surfaceWidth - MinHBlank ) * minRate , pixelClockHz ) );
1707
1709
1708
1710
//reduce HBlank Symbols to account for secondary data packet
1709
1711
hblank_symbols -= 1 ; //Stuffer latency to send BS
@@ -1722,7 +1724,7 @@ nv50_sor_dp_watermark_sst(struct nouveau_encoder *outp,
1722
1724
}
1723
1725
else
1724
1726
{
1725
- vblank_symbols = (s32 )((( u64 )(surfaceWidth - 40 ) * minRate ) / pixelClockHz ) - 1 ;
1727
+ vblank_symbols = (s32 )((div_u64 (( u64 )(surfaceWidth - 40 ) * minRate , pixelClockHz )) ) - 1 ;
1726
1728
1727
1729
vblank_symbols -= numLanesPerLink == 1 ? 39 : numLanesPerLink == 2 ? 21 : 12 ;
1728
1730
}
0 commit comments