drm: rcar-du: lvds: Avoid duplication of clock clamp code
Replace the duplicate code by a single central function. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
This commit is contained in:
@@ -89,12 +89,8 @@ static int rcar_du_encoder_atomic_check(struct drm_encoder *encoder,
|
|||||||
/* The flat panel mode is fixed, just copy it to the adjusted mode. */
|
/* The flat panel mode is fixed, just copy it to the adjusted mode. */
|
||||||
drm_mode_copy(adjusted_mode, panel_mode);
|
drm_mode_copy(adjusted_mode, panel_mode);
|
||||||
|
|
||||||
/* The internal LVDS encoder has a clock frequency operating range of
|
|
||||||
* 30MHz to 150MHz. Clamp the clock accordingly.
|
|
||||||
*/
|
|
||||||
if (renc->lvds)
|
if (renc->lvds)
|
||||||
adjusted_mode->clock = clamp(adjusted_mode->clock,
|
rcar_du_lvdsenc_atomic_check(renc->lvds, adjusted_mode);
|
||||||
30000, 150000);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,12 +71,9 @@ static int rcar_du_hdmienc_atomic_check(struct drm_encoder *encoder,
|
|||||||
struct drm_display_mode *adjusted_mode = &crtc_state->adjusted_mode;
|
struct drm_display_mode *adjusted_mode = &crtc_state->adjusted_mode;
|
||||||
const struct drm_display_mode *mode = &crtc_state->mode;
|
const struct drm_display_mode *mode = &crtc_state->mode;
|
||||||
|
|
||||||
/* The internal LVDS encoder has a clock frequency operating range of
|
|
||||||
* 30MHz to 150MHz. Clamp the clock accordingly.
|
|
||||||
*/
|
|
||||||
if (hdmienc->renc->lvds)
|
if (hdmienc->renc->lvds)
|
||||||
adjusted_mode->clock = clamp(adjusted_mode->clock,
|
rcar_du_lvdsenc_atomic_check(hdmienc->renc->lvds,
|
||||||
30000, 150000);
|
adjusted_mode);
|
||||||
|
|
||||||
if (sfuncs->mode_fixup == NULL)
|
if (sfuncs->mode_fixup == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -140,6 +140,15 @@ int rcar_du_lvdsenc_enable(struct rcar_du_lvdsenc *lvds, struct drm_crtc *crtc,
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rcar_du_lvdsenc_atomic_check(struct rcar_du_lvdsenc *lvds,
|
||||||
|
struct drm_display_mode *mode)
|
||||||
|
{
|
||||||
|
/* The internal LVDS encoder has a clock frequency operating range of
|
||||||
|
* 30MHz to 150MHz. Clamp the clock accordingly.
|
||||||
|
*/
|
||||||
|
mode->clock = clamp(mode->clock, 30000, 150000);
|
||||||
|
}
|
||||||
|
|
||||||
static int rcar_du_lvdsenc_get_resources(struct rcar_du_lvdsenc *lvds,
|
static int rcar_du_lvdsenc_get_resources(struct rcar_du_lvdsenc *lvds,
|
||||||
struct platform_device *pdev)
|
struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ enum rcar_lvds_input {
|
|||||||
int rcar_du_lvdsenc_init(struct rcar_du_device *rcdu);
|
int rcar_du_lvdsenc_init(struct rcar_du_device *rcdu);
|
||||||
int rcar_du_lvdsenc_enable(struct rcar_du_lvdsenc *lvds,
|
int rcar_du_lvdsenc_enable(struct rcar_du_lvdsenc *lvds,
|
||||||
struct drm_crtc *crtc, bool enable);
|
struct drm_crtc *crtc, bool enable);
|
||||||
|
void rcar_du_lvdsenc_atomic_check(struct rcar_du_lvdsenc *lvds,
|
||||||
|
struct drm_display_mode *mode);
|
||||||
#else
|
#else
|
||||||
static inline int rcar_du_lvdsenc_init(struct rcar_du_device *rcdu)
|
static inline int rcar_du_lvdsenc_init(struct rcar_du_device *rcdu)
|
||||||
{
|
{
|
||||||
@@ -40,6 +42,10 @@ static inline int rcar_du_lvdsenc_enable(struct rcar_du_lvdsenc *lvds,
|
|||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
static inline void rcar_du_lvdsenc_atomic_check(struct rcar_du_lvdsenc *lvds,
|
||||||
|
struct drm_display_mode *mode)
|
||||||
|
{
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* __RCAR_DU_LVDSENC_H__ */
|
#endif /* __RCAR_DU_LVDSENC_H__ */
|
||||||
|
|||||||
Reference in New Issue
Block a user