Release 4.15 drivers/gpu/drm/sti/sti_crtc.c
  
  
  
/*
 * Copyright (C) STMicroelectronics SA 2014
 * Authors: Benjamin Gaignard <benjamin.gaignard@st.com>
 *          Fabien Dessenne <fabien.dessenne@st.com>
 *          for STMicroelectronics.
 * License terms:  GNU General Public License (GPL), version 2
 */
#include <linux/clk.h>
#include <drm/drmP.h>
#include <drm/drm_atomic.h>
#include <drm/drm_atomic_helper.h>
#include <drm/drm_crtc_helper.h>
#include <drm/drm_plane_helper.h>
#include "sti_compositor.h"
#include "sti_crtc.h"
#include "sti_drv.h"
#include "sti_vid.h"
#include "sti_vtg.h"
static void sti_crtc_atomic_enable(struct drm_crtc *crtc,
				   struct drm_crtc_state *old_state)
{
	struct sti_mixer *mixer = to_sti_mixer(crtc);
	DRM_DEBUG_DRIVER("\n");
	mixer->status = STI_MIXER_READY;
	drm_crtc_vblank_on(crtc);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Benjamin Gaignard | 27 | 64.29% | 3 | 60.00% | 
| Vincent Abriou | 9 | 21.43% | 1 | 20.00% | 
| Laurent Pinchart | 6 | 14.29% | 1 | 20.00% | 
| Total | 42 | 100.00% | 5 | 100.00% | 
static void sti_crtc_atomic_disable(struct drm_crtc *crtc,
				    struct drm_crtc_state *old_state)
{
	struct sti_mixer *mixer = to_sti_mixer(crtc);
	DRM_DEBUG_DRIVER("\n");
	mixer->status = STI_MIXER_DISABLING;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Benjamin Gaignard | 25 | 67.57% | 2 | 50.00% | 
| Vincent Abriou | 6 | 16.22% | 1 | 25.00% | 
| Laurent Pinchart | 6 | 16.22% | 1 | 25.00% | 
| Total | 37 | 100.00% | 4 | 100.00% | 
static int
sti_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode)
{
	struct sti_mixer *mixer = to_sti_mixer(crtc);
	struct device *dev = mixer->dev;
	struct sti_compositor *compo = dev_get_drvdata(dev);
	struct clk *compo_clk, *pix_clk;
	int rate = mode->clock * 1000;
	DRM_DEBUG_KMS("CRTC:%d (%s) mode:%d (%s)\n",
		      crtc->base.id, sti_mixer_to_str(mixer),
		      mode->base.id, mode->name);
	DRM_DEBUG_KMS("%d %d %d %d %d %d %d %d %d %d 0x%x 0x%x\n",
		      mode->vrefresh, mode->clock,
		      mode->hdisplay,
		      mode->hsync_start, mode->hsync_end,
		      mode->htotal,
		      mode->vdisplay,
		      mode->vsync_start, mode->vsync_end,
		      mode->vtotal, mode->type, mode->flags);
	if (mixer->id == STI_MIXER_MAIN) {
		compo_clk = compo->clk_compo_main;
		pix_clk = compo->clk_pix_main;
	} else {
		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;
	}
	/* Set rate and prepare/enable pixel clock */
	if (clk_set_rate(pix_clk, rate) < 0) {
		DRM_ERROR("Cannot set rate (%dHz) for pix clk\n", rate);
		goto pix_error;
	}
	if (clk_prepare_enable(pix_clk)) {
		DRM_ERROR("Failed to prepare/enable pix clk\n");
		goto pix_error;
	}
	sti_vtg_set_config(compo->vtg[mixer->id], &crtc->mode);
	if (sti_mixer_active_video_area(mixer, &crtc->mode)) {
		DRM_ERROR("Can't set active video area\n");
		goto mixer_error;
	}
	return 0;
mixer_error:
	clk_disable_unprepare(pix_clk);
pix_error:
	clk_disable_unprepare(compo_clk);
compo_error:
	return -EINVAL;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Benjamin Gaignard | 292 | 97.66% | 3 | 50.00% | 
| Fabien Dessenne | 5 | 1.67% | 1 | 16.67% | 
| Vincent Abriou | 2 | 0.67% | 2 | 33.33% | 
| Total | 299 | 100.00% | 6 | 100.00% | 
static void sti_crtc_disable(struct drm_crtc *crtc)
{
	struct sti_mixer *mixer = to_sti_mixer(crtc);
	struct device *dev = mixer->dev;
	struct sti_compositor *compo = dev_get_drvdata(dev);
	DRM_DEBUG_KMS("CRTC:%d (%s)\n", crtc->base.id, sti_mixer_to_str(mixer));
	/* Disable Background */
	sti_mixer_set_background_status(mixer, false);
	drm_crtc_vblank_off(crtc);
	/* Disable pixel clock and compo IP clocks */
	if (mixer->id == STI_MIXER_MAIN) {
		clk_disable_unprepare(compo->clk_pix_main);
		clk_disable_unprepare(compo->clk_compo_main);
	} else {
		clk_disable_unprepare(compo->clk_pix_aux);
		clk_disable_unprepare(compo->clk_compo_aux);
	}
	mixer->status = STI_MIXER_DISABLED;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Benjamin Gaignard | 114 | 97.44% | 2 | 50.00% | 
| Vincent Abriou | 3 | 2.56% | 2 | 50.00% | 
| Total | 117 | 100.00% | 4 | 100.00% | 
static void
sti_crtc_mode_set_nofb(struct drm_crtc *crtc)
{
	sti_crtc_mode_set(crtc, &crtc->state->adjusted_mode);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Benjamin Gaignard | 21 | 91.30% | 3 | 75.00% | 
| Vincent Abriou | 2 | 8.70% | 1 | 25.00% | 
| Total | 23 | 100.00% | 4 | 100.00% | 
static void sti_crtc_atomic_flush(struct drm_crtc *crtc,
				  struct drm_crtc_state *old_crtc_state)
{
	struct drm_device *drm_dev = crtc->dev;
	struct sti_mixer *mixer = to_sti_mixer(crtc);
	struct sti_compositor *compo = dev_get_drvdata(mixer->dev);
	struct drm_plane *p;
	struct drm_pending_vblank_event *event;
	unsigned long flags;
	DRM_DEBUG_DRIVER("\n");
	/* perform plane actions */
	list_for_each_entry(p, &drm_dev->mode_config.plane_list, head) {
		struct sti_plane *plane = to_sti_plane(p);
		switch (plane->status) {
		case STI_PLANE_UPDATED:
			/* ignore update for other CRTC */
			if (p->state->crtc != crtc)
				continue;
			/* update planes tag as updated */
			DRM_DEBUG_DRIVER("update plane %s\n",
					 sti_plane_to_str(plane));
			if (sti_mixer_set_plane_depth(mixer, plane)) {
				DRM_ERROR("Cannot set plane %s depth\n",
					  sti_plane_to_str(plane));
				break;
			}
			if (sti_mixer_set_plane_status(mixer, plane, true)) {
				DRM_ERROR("Cannot enable plane %s at mixer\n",
					  sti_plane_to_str(plane));
				break;
			}
			/* if plane is HQVDP_0 then commit the vid[0] */
			if (plane->desc == STI_HQVDP_0)
				sti_vid_commit(compo->vid[0], p->state);
			plane->status = STI_PLANE_READY;
			break;
		case STI_PLANE_DISABLING:
			/* disabling sequence for planes tag as disabling */
			DRM_DEBUG_DRIVER("disable plane %s from mixer\n",
					 sti_plane_to_str(plane));
			if (sti_mixer_set_plane_status(mixer, plane, false)) {
				DRM_ERROR("Cannot disable plane %s at mixer\n",
					  sti_plane_to_str(plane));
				continue;
			}
			if (plane->desc == STI_CURSOR)
				/* tag plane status for disabled */
				plane->status = STI_PLANE_DISABLED;
			else
				/* tag plane status for flushing */
				plane->status = STI_PLANE_FLUSHING;
			/* if plane is HQVDP_0 then disable the vid[0] */
			if (plane->desc == STI_HQVDP_0)
				sti_vid_disable(compo->vid[0]);
			break;
		default:
			/* Other status case are not handled */
			break;
		}
	}
	event = crtc->state->event;
	if (event) {
		crtc->state->event = NULL;
		spin_lock_irqsave(&crtc->dev->event_lock, flags);
		if (drm_crtc_vblank_get(crtc) == 0)
			drm_crtc_arm_vblank_event(crtc, event);
		else
			drm_crtc_send_vblank_event(crtc, event);
		spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
	}
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Vincent Abriou | 247 | 70.37% | 2 | 33.33% | 
| Fabien Dessenne | 91 | 25.93% | 2 | 33.33% | 
| Benjamin Gaignard | 8 | 2.28% | 1 | 16.67% | 
| Maarten Lankhorst | 5 | 1.42% | 1 | 16.67% | 
| Total | 351 | 100.00% | 6 | 100.00% | 
static const struct drm_crtc_helper_funcs sti_crtc_helper_funcs = {
	.mode_set_nofb = sti_crtc_mode_set_nofb,
	.atomic_flush = sti_crtc_atomic_flush,
	.atomic_enable = sti_crtc_atomic_enable,
	.atomic_disable = sti_crtc_atomic_disable,
};
static void sti_crtc_destroy(struct drm_crtc *crtc)
{
	DRM_DEBUG_KMS("\n");
	drm_crtc_cleanup(crtc);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Benjamin Gaignard | 20 | 95.24% | 1 | 50.00% | 
| Vincent Abriou | 1 | 4.76% | 1 | 50.00% | 
| Total | 21 | 100.00% | 2 | 100.00% | 
static int sti_crtc_set_property(struct drm_crtc *crtc,
				 struct drm_property *property,
				 uint64_t val)
{
	DRM_DEBUG_KMS("\n");
	return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Benjamin Gaignard | 26 | 96.30% | 1 | 50.00% | 
| Vincent Abriou | 1 | 3.70% | 1 | 50.00% | 
| Total | 27 | 100.00% | 2 | 100.00% | 
int sti_crtc_vblank_cb(struct notifier_block *nb,
		       unsigned long event, void *data)
{
	struct sti_compositor *compo;
	struct drm_crtc *crtc = data;
	struct sti_mixer *mixer;
	struct sti_private *priv;
	unsigned int pipe;
	priv = crtc->dev->dev_private;
	pipe = drm_crtc_index(crtc);
	compo = container_of(nb, struct sti_compositor, vtg_vblank_nb[pipe]);
	mixer = compo->mixer[pipe];
	if ((event != VTG_TOP_FIELD_EVENT) &&
	    (event != VTG_BOTTOM_FIELD_EVENT)) {
		DRM_ERROR("unknown event: %lu\n", event);
		return -EINVAL;
	}
	drm_crtc_handle_vblank(crtc);
	if (mixer->status == STI_MIXER_DISABLING) {
		struct drm_plane *p;
		/* Disable mixer only if all overlay planes (GDP and VDP)
                 * are disabled */
		list_for_each_entry(p, &crtc->dev->mode_config.plane_list,
				    head) {
			struct sti_plane *plane = to_sti_plane(p);
			if ((plane->desc & STI_PLANE_TYPE_MASK) <= STI_VDP)
				if (plane->status != STI_PLANE_DISABLED)
					return 0;
		}
		sti_crtc_disable(crtc);
	}
	return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Benjamin Gaignard | 73 | 40.11% | 1 | 20.00% | 
| Vincent Abriou | 65 | 35.71% | 2 | 40.00% | 
| Thierry Reding | 29 | 15.93% | 1 | 20.00% | 
| Fabien Dessenne | 15 | 8.24% | 1 | 20.00% | 
| Total | 182 | 100.00% | 5 | 100.00% | 
int sti_crtc_enable_vblank(struct drm_device *dev, unsigned int pipe)
{
	struct sti_private *dev_priv = dev->dev_private;
	struct sti_compositor *compo = dev_priv->compo;
	struct notifier_block *vtg_vblank_nb = &compo->vtg_vblank_nb[pipe];
	struct drm_crtc *crtc = &compo->mixer[pipe]->drm_crtc;
	struct sti_vtg *vtg = compo->vtg[pipe];
	DRM_DEBUG_DRIVER("\n");
	if (sti_vtg_register_client(vtg, vtg_vblank_nb, crtc)) {
		DRM_ERROR("Cannot register VTG notifier\n");
		return -EINVAL;
	}
	return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Benjamin Gaignard | 61 | 59.80% | 1 | 14.29% | 
| Thierry Reding | 18 | 17.65% | 2 | 28.57% | 
| Fabien Dessenne | 16 | 15.69% | 2 | 28.57% | 
| Vincent Abriou | 7 | 6.86% | 2 | 28.57% | 
| Total | 102 | 100.00% | 7 | 100.00% | 
void sti_crtc_disable_vblank(struct drm_device *drm_dev, unsigned int pipe)
{
	struct sti_private *priv = drm_dev->dev_private;
	struct sti_compositor *compo = priv->compo;
	struct notifier_block *vtg_vblank_nb = &compo->vtg_vblank_nb[pipe];
	struct sti_vtg *vtg = compo->vtg[pipe];
	DRM_DEBUG_DRIVER("\n");
	if (sti_vtg_unregister_client(vtg, vtg_vblank_nb))
		DRM_DEBUG_DRIVER("Warning: cannot unregister VTG notifier\n");
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Benjamin Gaignard | 54 | 71.05% | 1 | 14.29% | 
| Fabien Dessenne | 15 | 19.74% | 2 | 28.57% | 
| Vincent Abriou | 4 | 5.26% | 2 | 28.57% | 
| Thierry Reding | 3 | 3.95% | 2 | 28.57% | 
| Total | 76 | 100.00% | 7 | 100.00% | 
static int sti_crtc_late_register(struct drm_crtc *crtc)
{
	struct sti_mixer *mixer = to_sti_mixer(crtc);
	struct sti_compositor *compo = dev_get_drvdata(mixer->dev);
	if (drm_crtc_index(crtc) == 0)
		return sti_compositor_debugfs_init(compo, crtc->dev->primary);
	return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Benjamin Gaignard | 56 | 98.25% | 1 | 50.00% | 
| Vincent Abriou | 1 | 1.75% | 1 | 50.00% | 
| Total | 57 | 100.00% | 2 | 100.00% | 
static const struct drm_crtc_funcs sti_crtc_funcs = {
	.set_config = drm_atomic_helper_set_config,
	.page_flip = drm_atomic_helper_page_flip,
	.destroy = sti_crtc_destroy,
	.set_property = sti_crtc_set_property,
	.reset = drm_atomic_helper_crtc_reset,
	.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
	.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
	.late_register = sti_crtc_late_register,
};
bool sti_crtc_is_main(struct drm_crtc *crtc)
{
	struct sti_mixer *mixer = to_sti_mixer(crtc);
	if (mixer->id == STI_MIXER_MAIN)
		return true;
	return false;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Benjamin Gaignard | 33 | 97.06% | 1 | 50.00% | 
| Vincent Abriou | 1 | 2.94% | 1 | 50.00% | 
| Total | 34 | 100.00% | 2 | 100.00% | 
int sti_crtc_init(struct drm_device *drm_dev, struct sti_mixer *mixer,
		  struct drm_plane *primary, struct drm_plane *cursor)
{
	struct drm_crtc *crtc = &mixer->drm_crtc;
	int res;
	res = drm_crtc_init_with_planes(drm_dev, crtc, primary, cursor,
					&sti_crtc_funcs, NULL);
	if (res) {
		DRM_ERROR("Can't initialze CRTC\n");
		return -EINVAL;
	}
	drm_crtc_helper_add(crtc, &sti_crtc_helper_funcs);
	DRM_DEBUG_DRIVER("drm CRTC:%d mapped to %s\n",
			 crtc->base.id, sti_mixer_to_str(mixer));
	return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Benjamin Gaignard | 94 | 95.92% | 1 | 25.00% | 
| Ville Syrjälä | 2 | 2.04% | 1 | 25.00% | 
| Vincent Abriou | 2 | 2.04% | 2 | 50.00% | 
| Total | 98 | 100.00% | 4 | 100.00% | 
Overall Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Benjamin Gaignard | 989 | 62.75% | 8 | 33.33% | 
| Vincent Abriou | 361 | 22.91% | 4 | 16.67% | 
| Fabien Dessenne | 142 | 9.01% | 4 | 16.67% | 
| Thierry Reding | 50 | 3.17% | 2 | 8.33% | 
| Laurent Pinchart | 22 | 1.40% | 2 | 8.33% | 
| Maarten Lankhorst | 5 | 0.32% | 1 | 4.17% | 
| Ville Syrjälä | 4 | 0.25% | 2 | 8.33% | 
| Daniel Vetter | 3 | 0.19% | 1 | 4.17% | 
| Total | 1576 | 100.00% | 24 | 100.00% | 
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.