Commit e2af48c6 authored by Ville Syrjälä's avatar Ville Syrjälä
Browse files

drm/i915: Store struct intel_crtc * in {pipe,plane}_to_crtc_mapping[]



A lot of users of the {pipe,plane}_to_crtc_mapping[] will end up
casting the result to intel_crtc, so let's just store the intel_crtc
pointer in the first place.

Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1477946245-14134-7-git-send-email-ville.syrjala@linux.intel.com


Reviewed-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
parent efc2611e
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -4065,8 +4065,7 @@ static void hsw_trans_edp_pipe_A_crc_wa(struct drm_i915_private *dev_priv,
					bool enable)
{
	struct drm_device *dev = &dev_priv->drm;
	struct intel_crtc *crtc =
		to_intel_crtc(dev_priv->pipe_to_crtc_mapping[PIPE_A]);
	struct intel_crtc *crtc = dev_priv->pipe_to_crtc_mapping[PIPE_A];
	struct intel_crtc_state *pipe_config;
	struct drm_atomic_state *state;
	int ret = 0;
@@ -4134,8 +4133,7 @@ static int pipe_crc_set_source(struct drm_i915_private *dev_priv,
{
	struct drm_device *dev = &dev_priv->drm;
	struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe];
	struct intel_crtc *crtc =
			to_intel_crtc(intel_get_crtc_for_pipe(dev, pipe));
	struct intel_crtc *crtc = intel_get_crtc_for_pipe(dev, pipe);
	enum intel_display_power_domain power_domain;
	u32 val = 0; /* shut up gcc */
	int ret;
@@ -4206,8 +4204,7 @@ static int pipe_crc_set_source(struct drm_i915_private *dev_priv,
	/* real source -> none transition */
	if (source == INTEL_PIPE_CRC_SOURCE_NONE) {
		struct intel_pipe_crc_entry *entries;
		struct intel_crtc *crtc =
			to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]);
		struct intel_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];

		DRM_DEBUG_DRIVER("stopping CRCs for pipe %c\n",
				 pipe_name(pipe));
+2 −2
Original line number Diff line number Diff line
@@ -1935,8 +1935,8 @@ struct drm_i915_private {

	/* Kernel Modesetting */

	struct drm_crtc *plane_to_crtc_mapping[I915_MAX_PIPES];
	struct drm_crtc *pipe_to_crtc_mapping[I915_MAX_PIPES];
	struct intel_crtc *plane_to_crtc_mapping[I915_MAX_PIPES];
	struct intel_crtc *pipe_to_crtc_mapping[I915_MAX_PIPES];
	wait_queue_head_t pending_flip_queue;

#ifdef CONFIG_DEBUG_FS
+5 −7
Original line number Diff line number Diff line
@@ -725,8 +725,7 @@ static u32 i915_get_vblank_counter(struct drm_device *dev, unsigned int pipe)
	struct drm_i915_private *dev_priv = to_i915(dev);
	i915_reg_t high_frame, low_frame;
	u32 high1, high2, low, pixel, vbl_start, hsync_start, htotal;
	struct intel_crtc *intel_crtc =
		to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]);
	struct intel_crtc *intel_crtc = dev_priv->pipe_to_crtc_mapping[pipe];
	const struct drm_display_mode *mode = &intel_crtc->base.hwmode;

	htotal = mode->crtc_htotal;
@@ -831,8 +830,7 @@ static int i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
				    const struct drm_display_mode *mode)
{
	struct drm_i915_private *dev_priv = to_i915(dev);
	struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
	struct intel_crtc *intel_crtc = dev_priv->pipe_to_crtc_mapping[pipe];
	int position;
	int vbl_start, vbl_end, hsync_start, htotal, vtotal;
	bool in_vbl = true;
@@ -967,7 +965,7 @@ static int i915_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
			      struct timeval *vblank_time,
			      unsigned flags)
{
	struct drm_crtc *crtc;
	struct intel_crtc *crtc;

	if (pipe >= INTEL_INFO(dev)->num_pipes) {
		DRM_ERROR("Invalid crtc %u\n", pipe);
@@ -981,7 +979,7 @@ static int i915_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
		return -EINVAL;
	}

	if (!crtc->hwmode.crtc_clock) {
	if (!crtc->base.hwmode.crtc_clock) {
		DRM_DEBUG_KMS("crtc %u is disabled\n", pipe);
		return -EBUSY;
	}
@@ -989,7 +987,7 @@ static int i915_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
	/* Helper routine in DRM core does all the work: */
	return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error,
						     vblank_time, flags,
						     &crtc->hwmode);
						     &crtc->base.hwmode);
}

static void ironlake_rps_change_irq_handler(struct drm_i915_private *dev_priv)
+32 −36
Original line number Diff line number Diff line
@@ -1030,10 +1030,9 @@ bool intel_crtc_active(struct intel_crtc *crtc)
enum transcoder intel_pipe_to_cpu_transcoder(struct drm_i915_private *dev_priv,
					     enum pipe pipe)
{
	struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
	struct intel_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];

	return intel_crtc->config->cpu_transcoder;
	return crtc->config->cpu_transcoder;
}

static bool pipe_dsl_stopped(struct drm_device *dev, enum pipe pipe)
@@ -1786,8 +1785,7 @@ void vlv_wait_port_ready(struct drm_i915_private *dev_priv,
static void ironlake_enable_pch_transcoder(struct drm_i915_private *dev_priv,
					   enum pipe pipe)
{
	struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
	struct intel_crtc *intel_crtc = dev_priv->pipe_to_crtc_mapping[pipe];
	i915_reg_t reg;
	uint32_t val, pipeconf_val;

@@ -7073,7 +7071,7 @@ static int ironlake_check_fdi_lanes(struct drm_device *dev, enum pipe pipe,
		if (pipe_config->fdi_lanes <= 2)
			return 0;

		other_crtc = to_intel_crtc(intel_get_crtc_for_pipe(dev, PIPE_C));
		other_crtc = intel_get_crtc_for_pipe(dev, PIPE_C);
		other_crtc_state =
			intel_atomic_get_crtc_state(state, other_crtc);
		if (IS_ERR(other_crtc_state))
@@ -7092,7 +7090,7 @@ static int ironlake_check_fdi_lanes(struct drm_device *dev, enum pipe pipe,
			return -EINVAL;
		}

		other_crtc = to_intel_crtc(intel_get_crtc_for_pipe(dev, PIPE_B));
		other_crtc = intel_get_crtc_for_pipe(dev, PIPE_B);
		other_crtc_state =
			intel_atomic_get_crtc_state(state, other_crtc);
		if (IS_ERR(other_crtc_state))
@@ -8107,8 +8105,7 @@ static void chv_prepare_pll(struct intel_crtc *crtc,
int vlv_force_pll_on(struct drm_device *dev, enum pipe pipe,
		     const struct dpll *dpll)
{
	struct intel_crtc *crtc =
		to_intel_crtc(intel_get_crtc_for_pipe(dev, pipe));
	struct intel_crtc *crtc = intel_get_crtc_for_pipe(dev, pipe);
	struct intel_crtc_state *pipe_config;

	pipe_config = kzalloc(sizeof(*pipe_config), GFP_KERNEL);
@@ -11663,8 +11660,7 @@ static bool pageflip_finished(struct intel_crtc *crtc,
void intel_finish_page_flip_cs(struct drm_i915_private *dev_priv, int pipe)
{
	struct drm_device *dev = &dev_priv->drm;
	struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
	struct intel_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];
	struct intel_flip_work *work;
	unsigned long flags;

@@ -11677,12 +11673,12 @@ void intel_finish_page_flip_cs(struct drm_i915_private *dev_priv, int pipe)
	 * lost pageflips) so needs the full irqsave spinlocks.
	 */
	spin_lock_irqsave(&dev->event_lock, flags);
	work = intel_crtc->flip_work;
	work = crtc->flip_work;

	if (work != NULL &&
	    !is_mmio_work(work) &&
	    pageflip_finished(intel_crtc, work))
		page_flip_completed(intel_crtc);
	    pageflip_finished(crtc, work))
		page_flip_completed(crtc);

	spin_unlock_irqrestore(&dev->event_lock, flags);
}
@@ -11690,8 +11686,7 @@ void intel_finish_page_flip_cs(struct drm_i915_private *dev_priv, int pipe)
void intel_finish_page_flip_mmio(struct drm_i915_private *dev_priv, int pipe)
{
	struct drm_device *dev = &dev_priv->drm;
	struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
	struct intel_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];
	struct intel_flip_work *work;
	unsigned long flags;

@@ -11704,12 +11699,12 @@ void intel_finish_page_flip_mmio(struct drm_i915_private *dev_priv, int pipe)
	 * lost pageflips) so needs the full irqsave spinlocks.
	 */
	spin_lock_irqsave(&dev->event_lock, flags);
	work = intel_crtc->flip_work;
	work = crtc->flip_work;

	if (work != NULL &&
	    is_mmio_work(work) &&
	    pageflip_finished(intel_crtc, work))
		page_flip_completed(intel_crtc);
	    pageflip_finished(crtc, work))
		page_flip_completed(crtc);

	spin_unlock_irqrestore(&dev->event_lock, flags);
}
@@ -12121,8 +12116,7 @@ static bool __pageflip_stall_check_cs(struct drm_i915_private *dev_priv,
void intel_check_page_flip(struct drm_i915_private *dev_priv, int pipe)
{
	struct drm_device *dev = &dev_priv->drm;
	struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
	struct intel_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];
	struct intel_flip_work *work;

	WARN_ON(!in_interrupt());
@@ -12131,19 +12125,19 @@ void intel_check_page_flip(struct drm_i915_private *dev_priv, int pipe)
		return;

	spin_lock(&dev->event_lock);
	work = intel_crtc->flip_work;
	work = crtc->flip_work;

	if (work != NULL && !is_mmio_work(work) &&
	    __pageflip_stall_check_cs(dev_priv, intel_crtc, work)) {
	    __pageflip_stall_check_cs(dev_priv, crtc, work)) {
		WARN_ONCE(1,
			  "Kicking stuck page flip: queued at %d, now %d\n",
			work->flip_queued_vblank, intel_crtc_get_vblank_counter(intel_crtc));
		page_flip_completed(intel_crtc);
			work->flip_queued_vblank, intel_crtc_get_vblank_counter(crtc));
		page_flip_completed(crtc);
		work = NULL;
	}

	if (work != NULL && !is_mmio_work(work) &&
	    intel_crtc_get_vblank_counter(intel_crtc) - work->flip_queued_vblank > 1)
	    intel_crtc_get_vblank_counter(crtc) - work->flip_queued_vblank > 1)
		intel_queue_rps_boost_for_request(work->flip_queued_req);
	spin_unlock(&dev->event_lock);
}
@@ -14181,22 +14175,22 @@ static void intel_atomic_wait_for_vblanks(struct drm_device *dev,
		return;

	for_each_pipe(dev_priv, pipe) {
		struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];
		struct intel_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];

		if (!((1 << pipe) & crtc_mask))
			continue;

		ret = drm_crtc_vblank_get(crtc);
		ret = drm_crtc_vblank_get(&crtc->base);
		if (WARN_ON(ret != 0)) {
			crtc_mask &= ~(1 << pipe);
			continue;
		}

		last_vblank_count[pipe] = drm_crtc_vblank_count(crtc);
		last_vblank_count[pipe] = drm_crtc_vblank_count(&crtc->base);
	}

	for_each_pipe(dev_priv, pipe) {
		struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];
		struct intel_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];
		long lret;

		if (!((1 << pipe) & crtc_mask))
@@ -14204,12 +14198,12 @@ static void intel_atomic_wait_for_vblanks(struct drm_device *dev,

		lret = wait_event_timeout(dev->vblank[pipe].queue,
				last_vblank_count[pipe] !=
					drm_crtc_vblank_count(crtc),
					drm_crtc_vblank_count(&crtc->base),
				msecs_to_jiffies(50));

		WARN(!lret, "pipe %c vblank wait timed out\n", pipe_name(pipe));

		drm_crtc_vblank_put(crtc);
		drm_crtc_vblank_put(&crtc->base);
	}
}

@@ -15317,8 +15311,8 @@ static int intel_crtc_init(struct drm_device *dev, enum pipe pipe)

	BUG_ON(pipe >= ARRAY_SIZE(dev_priv->plane_to_crtc_mapping) ||
	       dev_priv->plane_to_crtc_mapping[intel_crtc->plane] != NULL);
	dev_priv->plane_to_crtc_mapping[intel_crtc->plane] = &intel_crtc->base;
	dev_priv->pipe_to_crtc_mapping[intel_crtc->pipe] = &intel_crtc->base;
	dev_priv->plane_to_crtc_mapping[intel_crtc->plane] = intel_crtc;
	dev_priv->pipe_to_crtc_mapping[intel_crtc->pipe] = intel_crtc;

	drm_crtc_helper_add(&intel_crtc->base, &intel_helper_funcs);

@@ -16871,7 +16865,8 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)
		pipe = 0;

		if (encoder->get_hw_state(encoder, &pipe)) {
			crtc = to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]);
			crtc = dev_priv->pipe_to_crtc_mapping[pipe];

			encoder->base.crtc = &crtc->base;
			crtc->config->output_types |= 1 << encoder->type;
			encoder->get_config(encoder, crtc->config);
@@ -16972,7 +16967,8 @@ intel_modeset_setup_hw_state(struct drm_device *dev)
	}

	for_each_pipe(dev_priv, pipe) {
		crtc = to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]);
		crtc = dev_priv->pipe_to_crtc_mapping[pipe];

		intel_sanitize_crtc(crtc);
		intel_dump_pipe_config(crtc, crtc->config,
				       "[setup_hw_state]");
+3 −4
Original line number Diff line number Diff line
@@ -1028,14 +1028,14 @@ vlv_pipe_to_channel(enum pipe pipe)
	}
}

static inline struct drm_crtc *
static inline struct intel_crtc *
intel_get_crtc_for_pipe(struct drm_device *dev, int pipe)
{
	struct drm_i915_private *dev_priv = to_i915(dev);
	return dev_priv->pipe_to_crtc_mapping[pipe];
}

static inline struct drm_crtc *
static inline struct intel_crtc *
intel_get_crtc_for_plane(struct drm_device *dev, int plane)
{
	struct drm_i915_private *dev_priv = to_i915(dev);
@@ -1251,8 +1251,7 @@ intel_wait_for_vblank(struct drm_device *dev, int pipe)
static inline void
intel_wait_for_vblank_if_active(struct drm_device *dev, int pipe)
{
	const struct intel_crtc *crtc =
		to_intel_crtc(intel_get_crtc_for_pipe(dev, pipe));
	const struct intel_crtc *crtc = intel_get_crtc_for_pipe(dev, pipe);

	if (crtc->active)
		intel_wait_for_vblank(dev, pipe);
Loading