Commit 583fa4e0 authored by Dave Airlie's avatar Dave Airlie

Merge branch 'sti-drm-next-2016-06-30' of...

Merge branch 'sti-drm-next-2016-06-30' of http://git.linaro.org/people/benjamin.gaignard/kernel into drm-next

This pull request include 3 minors fix and one feature evolution
around ASoC hdmi codec support.

* 'sti-drm-next-2016-06-30' of http://git.linaro.org/people/benjamin.gaignard/kernel:
  drm: sti: Add ASoC generic hdmi codec support.
  drm/sti: adjust delay for AWG
  drm: sti: fix clocking issues in crtc
  drm/sti: Use 64-bit timestamps
parents 2a346706 2c348e50
...@@ -7,5 +7,6 @@ config DRM_STI ...@@ -7,5 +7,6 @@ config DRM_STI
select DRM_KMS_CMA_HELPER select DRM_KMS_CMA_HELPER
select DRM_PANEL select DRM_PANEL
select FW_LOADER select FW_LOADER
select SND_SOC_HDMI_CODEC if SND_SOC
help help
Choose this option to enable DRM on STM stiH41x chipset Choose this option to enable DRM on STM stiH41x chipset
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include "sti_awg_utils.h" #include "sti_awg_utils.h"
#define AWG_DELAY (-5)
#define AWG_OPCODE_OFFSET 10 #define AWG_OPCODE_OFFSET 10
#define AWG_MAX_ARG 0x3ff #define AWG_MAX_ARG 0x3ff
...@@ -125,7 +127,7 @@ static int awg_generate_line_signal( ...@@ -125,7 +127,7 @@ static int awg_generate_line_signal(
val = timing->blanking_level; val = timing->blanking_level;
ret |= awg_generate_instr(RPLSET, val, 0, 0, fwparams); ret |= awg_generate_instr(RPLSET, val, 0, 0, fwparams);
val = timing->trailing_pixels - 1; val = timing->trailing_pixels - 1 + AWG_DELAY;
ret |= awg_generate_instr(SKIP, val, 0, 0, fwparams); ret |= awg_generate_instr(SKIP, val, 0, 0, fwparams);
} }
......
...@@ -23,22 +23,11 @@ ...@@ -23,22 +23,11 @@
static void sti_crtc_enable(struct drm_crtc *crtc) static void sti_crtc_enable(struct drm_crtc *crtc)
{ {
struct sti_mixer *mixer = to_sti_mixer(crtc); struct sti_mixer *mixer = to_sti_mixer(crtc);
struct device *dev = mixer->dev;
struct sti_compositor *compo = dev_get_drvdata(dev);
DRM_DEBUG_DRIVER("\n"); DRM_DEBUG_DRIVER("\n");
mixer->status = STI_MIXER_READY; mixer->status = STI_MIXER_READY;
/* Prepare and enable the compo IP clock */
if (mixer->id == STI_MIXER_MAIN) {
if (clk_prepare_enable(compo->clk_compo_main))
DRM_INFO("Failed to prepare/enable compo_main clk\n");
} else {
if (clk_prepare_enable(compo->clk_compo_aux))
DRM_INFO("Failed to prepare/enable compo_aux clk\n");
}
drm_crtc_vblank_on(crtc); drm_crtc_vblank_on(crtc);
} }
...@@ -57,9 +46,8 @@ sti_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode) ...@@ -57,9 +46,8 @@ sti_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode)
struct sti_mixer *mixer = to_sti_mixer(crtc); struct sti_mixer *mixer = to_sti_mixer(crtc);
struct device *dev = mixer->dev; struct device *dev = mixer->dev;
struct sti_compositor *compo = dev_get_drvdata(dev); struct sti_compositor *compo = dev_get_drvdata(dev);
struct clk *clk; struct clk *compo_clk, *pix_clk;
int rate = mode->clock * 1000; int rate = mode->clock * 1000;
int res;
DRM_DEBUG_KMS("CRTC:%d (%s) mode:%d (%s)\n", DRM_DEBUG_KMS("CRTC:%d (%s) mode:%d (%s)\n",
crtc->base.id, sti_mixer_to_str(mixer), crtc->base.id, sti_mixer_to_str(mixer),
...@@ -74,32 +62,46 @@ sti_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode) ...@@ -74,32 +62,46 @@ sti_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode)
mode->vsync_start, mode->vsync_end, mode->vsync_start, mode->vsync_end,
mode->vtotal, mode->type, mode->flags); mode->vtotal, mode->type, mode->flags);
/* Set rate and prepare/enable pixel clock */ if (mixer->id == STI_MIXER_MAIN) {
if (mixer->id == STI_MIXER_MAIN) compo_clk = compo->clk_compo_main;
clk = compo->clk_pix_main; pix_clk = compo->clk_pix_main;
else } else {
clk = compo->clk_pix_aux; compo_clk = compo->clk_compo_aux;
pix_clk = compo->clk_pix_aux;
}
/* Prepare and enable the compo IP clock */
if (clk_prepare_enable(compo_clk)) {
DRM_INFO("Failed to prepare/enable compositor clk\n");
goto compo_error;
}
res = clk_set_rate(clk, rate); /* Set rate and prepare/enable pixel clock */
if (res < 0) { if (clk_set_rate(pix_clk, rate) < 0) {
DRM_ERROR("Cannot set rate (%dHz) for pix clk\n", rate); DRM_ERROR("Cannot set rate (%dHz) for pix clk\n", rate);
return -EINVAL; goto pix_error;
} }
if (clk_prepare_enable(clk)) { if (clk_prepare_enable(pix_clk)) {
DRM_ERROR("Failed to prepare/enable pix clk\n"); DRM_ERROR("Failed to prepare/enable pix clk\n");
return -EINVAL; goto pix_error;
} }
sti_vtg_set_config(mixer->id == STI_MIXER_MAIN ? sti_vtg_set_config(mixer->id == STI_MIXER_MAIN ?
compo->vtg_main : compo->vtg_aux, &crtc->mode); compo->vtg_main : compo->vtg_aux, &crtc->mode);
res = sti_mixer_active_video_area(mixer, &crtc->mode); if (sti_mixer_active_video_area(mixer, &crtc->mode)) {
if (res) {
DRM_ERROR("Can't set active video area\n"); DRM_ERROR("Can't set active video area\n");
return -EINVAL; goto mixer_error;
} }
return res; return 0;
mixer_error:
clk_disable_unprepare(pix_clk);
pix_error:
clk_disable_unprepare(compo_clk);
compo_error:
return -EINVAL;
} }
static void sti_crtc_disable(struct drm_crtc *crtc) static void sti_crtc_disable(struct drm_crtc *crtc)
...@@ -130,7 +132,6 @@ static void sti_crtc_disable(struct drm_crtc *crtc) ...@@ -130,7 +132,6 @@ static void sti_crtc_disable(struct drm_crtc *crtc)
static void static void
sti_crtc_mode_set_nofb(struct drm_crtc *crtc) sti_crtc_mode_set_nofb(struct drm_crtc *crtc)
{ {
sti_crtc_enable(crtc);
sti_crtc_mode_set(crtc, &crtc->state->adjusted_mode); sti_crtc_mode_set(crtc, &crtc->state->adjusted_mode);
} }
...@@ -221,9 +222,7 @@ static void sti_crtc_atomic_flush(struct drm_crtc *crtc, ...@@ -221,9 +222,7 @@ static void sti_crtc_atomic_flush(struct drm_crtc *crtc,
static const struct drm_crtc_helper_funcs sti_crtc_helper_funcs = { static const struct drm_crtc_helper_funcs sti_crtc_helper_funcs = {
.enable = sti_crtc_enable, .enable = sti_crtc_enable,
.disable = sti_crtc_disabling, .disable = sti_crtc_disabling,
.mode_set = drm_helper_crtc_mode_set,
.mode_set_nofb = sti_crtc_mode_set_nofb, .mode_set_nofb = sti_crtc_mode_set_nofb,
.mode_set_base = drm_helper_crtc_mode_set_base,
.atomic_begin = sti_crtc_atomic_begin, .atomic_begin = sti_crtc_atomic_begin,
.atomic_flush = sti_crtc_atomic_flush, .atomic_flush = sti_crtc_atomic_flush,
}; };
......
This diff is collapsed.
...@@ -23,6 +23,13 @@ struct hdmi_phy_ops { ...@@ -23,6 +23,13 @@ struct hdmi_phy_ops {
void (*stop)(struct sti_hdmi *hdmi); void (*stop)(struct sti_hdmi *hdmi);
}; };
struct hdmi_audio_params {
bool enabled;
unsigned int sample_width;
unsigned int sample_rate;
struct hdmi_audio_infoframe cea;
};
/* values for the framing mode property */ /* values for the framing mode property */
enum sti_hdmi_modes { enum sti_hdmi_modes {
HDMI_MODE_HDMI, HDMI_MODE_HDMI,
...@@ -67,6 +74,9 @@ static const struct drm_prop_enum_list colorspace_mode_names[] = { ...@@ -67,6 +74,9 @@ static const struct drm_prop_enum_list colorspace_mode_names[] = {
* @ddc_adapt: i2c ddc adapter * @ddc_adapt: i2c ddc adapter
* @colorspace: current colorspace selected * @colorspace: current colorspace selected
* @hdmi_mode: select framing for HDMI or DVI * @hdmi_mode: select framing for HDMI or DVI
* @audio_pdev: ASoC hdmi-codec platform device
* @audio: hdmi audio parameters.
* @drm_connector: hdmi connector
*/ */
struct sti_hdmi { struct sti_hdmi {
struct device dev; struct device dev;
...@@ -89,6 +99,9 @@ struct sti_hdmi { ...@@ -89,6 +99,9 @@ struct sti_hdmi {
struct i2c_adapter *ddc_adapt; struct i2c_adapter *ddc_adapt;
enum hdmi_colorspace colorspace; enum hdmi_colorspace colorspace;
enum sti_hdmi_modes hdmi_mode; enum sti_hdmi_modes hdmi_mode;
struct platform_device *audio_pdev;
struct hdmi_audio_params audio;
struct drm_connector *drm_connector;
}; };
u32 hdmi_read(struct sti_hdmi *hdmi, int offset); u32 hdmi_read(struct sti_hdmi *hdmi, int offset);
......
...@@ -45,25 +45,15 @@ const char *sti_plane_to_str(struct sti_plane *plane) ...@@ -45,25 +45,15 @@ const char *sti_plane_to_str(struct sti_plane *plane)
#define STI_FPS_INTERVAL_MS 3000 #define STI_FPS_INTERVAL_MS 3000
static int sti_plane_timespec_ms_diff(struct timespec lhs, struct timespec rhs)
{
struct timespec tmp_ts = timespec_sub(lhs, rhs);
u64 tmp_ns = (u64)timespec_to_ns(&tmp_ts);
do_div(tmp_ns, NSEC_PER_MSEC);
return (u32)tmp_ns;
}
void sti_plane_update_fps(struct sti_plane *plane, void sti_plane_update_fps(struct sti_plane *plane,
bool new_frame, bool new_frame,
bool new_field) bool new_field)
{ {
struct timespec now; ktime_t now;
struct sti_fps_info *fps; struct sti_fps_info *fps;
int fpks, fipks, ms_since_last, num_frames, num_fields; int fpks, fipks, ms_since_last, num_frames, num_fields;
getrawmonotonic(&now); now = ktime_get();
/* Compute number of frame updates */ /* Compute number of frame updates */
fps = &plane->fps_info; fps = &plane->fps_info;
...@@ -76,7 +66,7 @@ void sti_plane_update_fps(struct sti_plane *plane, ...@@ -76,7 +66,7 @@ void sti_plane_update_fps(struct sti_plane *plane,
return; return;
fps->curr_frame_counter++; fps->curr_frame_counter++;
ms_since_last = sti_plane_timespec_ms_diff(now, fps->last_timestamp); ms_since_last = ktime_to_ms(ktime_sub(now, fps->last_timestamp));
num_frames = fps->curr_frame_counter - fps->last_frame_counter; num_frames = fps->curr_frame_counter - fps->last_frame_counter;
if (num_frames <= 0 || ms_since_last < STI_FPS_INTERVAL_MS) if (num_frames <= 0 || ms_since_last < STI_FPS_INTERVAL_MS)
......
...@@ -55,7 +55,7 @@ struct sti_fps_info { ...@@ -55,7 +55,7 @@ struct sti_fps_info {
unsigned int last_frame_counter; unsigned int last_frame_counter;
unsigned int curr_field_counter; unsigned int curr_field_counter;
unsigned int last_field_counter; unsigned int last_field_counter;
struct timespec last_timestamp; ktime_t last_timestamp;
char fps_str[FPS_LENGTH]; char fps_str[FPS_LENGTH];
char fips_str[FPS_LENGTH]; char fips_str[FPS_LENGTH];
}; };
......
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
#define HDMI_DELAY (5) #define HDMI_DELAY (5)
/* Delay introduced by the DVO in nb of pixel */ /* Delay introduced by the DVO in nb of pixel */
#define DVO_DELAY (2) #define DVO_DELAY (7)
/* delay introduced by the Arbitrary Waveform Generator in nb of pixels */ /* delay introduced by the Arbitrary Waveform Generator in nb of pixels */
#define AWG_DELAY_HD (-9) #define AWG_DELAY_HD (-9)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment