cregit-Linux how code gets into the kernel

Release 4.11 drivers/gpu/drm/omapdrm/omap_crtc.c

/*
 * drivers/gpu/drm/omapdrm/omap_crtc.c
 *
 * Copyright (C) 2011 Texas Instruments
 * Author: Rob Clark <rob@ti.com>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 as published by
 * the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <drm/drm_atomic.h>
#include <drm/drm_atomic_helper.h>
#include <drm/drm_crtc.h>
#include <drm/drm_crtc_helper.h>
#include <drm/drm_mode.h>
#include <drm/drm_plane_helper.h>

#include "omap_drv.h"


#define to_omap_crtc(x) container_of(x, struct omap_crtc, base)


struct omap_crtc {
	
struct drm_crtc base;

	
const char *name;
	
enum omap_channel channel;

	
struct videomode vm;

	
bool ignore_digit_sync_lost;

	
bool enabled;
	
bool pending;
	
wait_queue_head_t pending_wait;
	
struct drm_pending_vblank_event *event;
};

/* -----------------------------------------------------------------------------
 * Helper Functions
 */


struct videomode *omap_crtc_timings(struct drm_crtc *crtc) { struct omap_crtc *omap_crtc = to_omap_crtc(crtc); return &omap_crtc->vm; }

Contributors

PersonTokensPropCommitsCommitProp
Laurent Pinchart2692.86%133.33%
Peter Ujfalusi27.14%266.67%
Total28100.00%3100.00%


enum omap_channel omap_crtc_channel(struct drm_crtc *crtc) { struct omap_crtc *omap_crtc = to_omap_crtc(crtc); return omap_crtc->channel; }

Contributors

PersonTokensPropCommitsCommitProp
Laurent Pinchart26100.00%1100.00%
Total26100.00%1100.00%


static bool omap_crtc_is_pending(struct drm_crtc *crtc) { struct omap_crtc *omap_crtc = to_omap_crtc(crtc); unsigned long flags; bool pending; spin_lock_irqsave(&crtc->dev->event_lock, flags); pending = omap_crtc->pending; spin_unlock_irqrestore(&crtc->dev->event_lock, flags); return pending; }

Contributors

PersonTokensPropCommitsCommitProp
Laurent Pinchart61100.00%1100.00%
Total61100.00%1100.00%


int omap_crtc_wait_pending(struct drm_crtc *crtc) { struct omap_crtc *omap_crtc = to_omap_crtc(crtc); /* * Timeout is set to a "sufficiently" high value, which should cover * a single frame refresh even on slower displays. */ return wait_event_timeout(omap_crtc->pending_wait, !omap_crtc_is_pending(crtc), msecs_to_jiffies(250)); }

Contributors

PersonTokensPropCommitsCommitProp
Tomi Valkeinen3690.00%266.67%
Laurent Pinchart410.00%133.33%
Total40100.00%3100.00%

/* ----------------------------------------------------------------------------- * DSS Manager Functions */ /* * Manager-ops, callbacks from output when they need to configure * the upstream part of the video pipe. * * Most of these we can ignore until we add support for command-mode * panels.. for video-mode the crtc-helpers already do an adequate * job of sequencing the setup of the video pipe in the proper order */ /* ovl-mgr-id -> crtc */ static struct omap_crtc *omap_crtcs[8]; static struct omap_dss_device *omap_crtc_output[8]; /* we can probably ignore these until we support command-mode panels: */
static int omap_crtc_dss_connect(enum omap_channel channel, struct omap_dss_device *dst) { if (omap_crtc_output[channel]) return -EINVAL; if ((dispc_mgr_get_supported_outputs(channel) & dst->id) == 0) return -EINVAL; omap_crtc_output[channel] = dst; dst->dispc_channel_connected = true; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Tomi Valkeinen6098.36%685.71%
Laurent Pinchart11.64%114.29%
Total61100.00%7100.00%


static void omap_crtc_dss_disconnect(enum omap_channel channel, struct omap_dss_device *dst) { omap_crtc_output[channel] = NULL; dst->dispc_channel_connected = false; }

Contributors

PersonTokensPropCommitsCommitProp
Tomi Valkeinen2796.43%583.33%
Laurent Pinchart13.57%116.67%
Total28100.00%6100.00%


static void omap_crtc_dss_start_update(enum omap_channel channel) { }

Contributors

PersonTokensPropCommitsCommitProp
Rob Clark555.56%133.33%
Tomi Valkeinen333.33%133.33%
Laurent Pinchart111.11%133.33%
Total9100.00%3100.00%

/* Called only from the encoder enable/disable and suspend/resume handlers. */
static void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable) { struct drm_device *dev = crtc->dev; struct omap_crtc *omap_crtc = to_omap_crtc(crtc); enum omap_channel channel = omap_crtc->channel; struct omap_irq_wait *wait; u32 framedone_irq, vsync_irq; int ret; if (WARN_ON(omap_crtc->enabled == enable)) return; if (omap_crtc_output[channel]->output_type == OMAP_DISPLAY_TYPE_HDMI) { dispc_mgr_enable(channel, enable); omap_crtc->enabled = enable; return; } if (omap_crtc->channel == OMAP_DSS_CHANNEL_DIGIT) { /* * Digit output produces some sync lost interrupts during the * first frame when enabling, so we need to ignore those. */ omap_crtc->ignore_digit_sync_lost = true; } framedone_irq = dispc_mgr_get_framedone_irq(channel); vsync_irq = dispc_mgr_get_vsync_irq(channel); if (enable) { wait = omap_irq_wait_init(dev, vsync_irq, 1); } else { /* * When we disable the digit output, we need to wait for * FRAMEDONE to know that DISPC has finished with the output. * * OMAP2/3 does not have FRAMEDONE irq for digit output, and in * that case we need to use vsync interrupt, and wait for both * even and odd frames. */ if (framedone_irq) wait = omap_irq_wait_init(dev, framedone_irq, 1); else wait = omap_irq_wait_init(dev, vsync_irq, 2); } dispc_mgr_enable(channel, enable); omap_crtc->enabled = enable; ret = omap_irq_wait(dev, wait, msecs_to_jiffies(100)); if (ret) { dev_err(dev->dev, "%s: timeout waiting for %s\n", omap_crtc->name, enable ? "enable" : "disable"); } if (omap_crtc->channel == OMAP_DSS_CHANNEL_DIGIT) { omap_crtc->ignore_digit_sync_lost = false; /* make sure the irq handler sees the value above */ mb(); } }

Contributors

PersonTokensPropCommitsCommitProp
Laurent Pinchart18375.00%337.50%
Tomi Valkeinen6125.00%562.50%
Total244100.00%8100.00%


static int omap_crtc_dss_enable(enum omap_channel channel) { struct omap_crtc *omap_crtc = omap_crtcs[channel]; struct omap_overlay_manager_info info; memset(&info, 0, sizeof(info)); info.default_color = 0x00000000; info.trans_key = 0x00000000; info.trans_key_type = OMAP_DSS_COLOR_KEY_GFX_DST; info.trans_enabled = false; dispc_mgr_setup(omap_crtc->channel, &info); dispc_mgr_set_timings(omap_crtc->channel, &omap_crtc->vm); omap_crtc_set_enabled(&omap_crtc->base, true); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Laurent Pinchart4344.79%342.86%
Tomi Valkeinen4344.79%228.57%
Rob Clark99.38%114.29%
Peter Ujfalusi11.04%114.29%
Total96100.00%7100.00%


static void omap_crtc_dss_disable(enum omap_channel channel) { struct omap_crtc *omap_crtc = omap_crtcs[channel]; omap_crtc_set_enabled(&omap_crtc->base, false); }

Contributors

PersonTokensPropCommitsCommitProp
Tomi Valkeinen2480.00%240.00%
Rob Clark413.33%120.00%
Laurent Pinchart26.67%240.00%
Total30100.00%5100.00%


static void omap_crtc_dss_set_timings(enum omap_channel channel, const struct videomode *vm) { struct omap_crtc *omap_crtc = omap_crtcs[channel]; DBG("%s", omap_crtc->name); omap_crtc->vm = *vm; }

Contributors

PersonTokensPropCommitsCommitProp
Rob Clark3071.43%116.67%
Tomi Valkeinen716.67%233.33%
Peter Ujfalusi49.52%233.33%
Laurent Pinchart12.38%116.67%
Total42100.00%6100.00%


static void omap_crtc_dss_set_lcd_config(enum omap_channel channel, const struct dss_lcd_mgr_config *config) { struct omap_crtc *omap_crtc = omap_crtcs[channel]; DBG("%s", omap_crtc->name); dispc_mgr_set_lcd_config(omap_crtc->channel, config); }

Contributors

PersonTokensPropCommitsCommitProp
Rob Clark3681.82%125.00%
Tomi Valkeinen715.91%250.00%
Laurent Pinchart12.27%125.00%
Total44100.00%4100.00%


static int omap_crtc_dss_register_framedone( enum omap_channel channel, void (*handler)(void *), void *data) { return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Rob Clark2385.19%133.33%
Tomi Valkeinen311.11%133.33%
Laurent Pinchart13.70%133.33%
Total27100.00%3100.00%


static void omap_crtc_dss_unregister_framedone( enum omap_channel channel, void (*handler)(void *), void *data) { }

Contributors

PersonTokensPropCommitsCommitProp
Rob Clark1982.61%133.33%
Tomi Valkeinen313.04%133.33%
Laurent Pinchart14.35%133.33%
Total23100.00%3100.00%

static const struct dss_mgr_ops mgr_ops = { .connect = omap_crtc_dss_connect, .disconnect = omap_crtc_dss_disconnect, .start_update = omap_crtc_dss_start_update, .enable = omap_crtc_dss_enable, .disable = omap_crtc_dss_disable, .set_timings = omap_crtc_dss_set_timings, .set_lcd_config = omap_crtc_dss_set_lcd_config, .register_framedone_handler = omap_crtc_dss_register_framedone, .unregister_framedone_handler = omap_crtc_dss_unregister_framedone, }; /* ----------------------------------------------------------------------------- * Setup, Flush and Page Flip */
void omap_crtc_error_irq(struct drm_crtc *crtc, uint32_t irqstatus) { struct omap_crtc *omap_crtc = to_omap_crtc(crtc); if (omap_crtc->ignore_digit_sync_lost) { irqstatus &= ~DISPC_IRQ_SYNC_LOST_DIGIT; if (!irqstatus) return; } DRM_ERROR_RATELIMITED("%s: errors: %08x\n", omap_crtc->name, irqstatus); }

Contributors

PersonTokensPropCommitsCommitProp
Rob Clark2241.51%233.33%
Tomi Valkeinen1833.96%233.33%
Laurent Pinchart1324.53%233.33%
Total53100.00%6100.00%


void omap_crtc_vblank_irq(struct drm_crtc *crtc) { struct omap_crtc *omap_crtc = to_omap_crtc(crtc); bool pending; spin_lock(&crtc->dev->event_lock); /* * If the dispc is busy we're racing the flush operation. Try again on * the next vblank interrupt. */ if (dispc_mgr_go_busy(omap_crtc->channel)) { spin_unlock(&crtc->dev->event_lock); return; } /* Send the vblank event if one has been requested. */ if (omap_crtc->event) { drm_crtc_send_vblank_event(crtc, omap_crtc->event); omap_crtc->event = NULL; } pending = omap_crtc->pending; omap_crtc->pending = false; spin_unlock(&crtc->dev->event_lock); if (pending) drm_crtc_vblank_put(crtc); /* Wake up omap_atomic_complete. */ wake_up(&omap_crtc->pending_wait); DBG("%s: apply done", omap_crtc->name); }

Contributors

PersonTokensPropCommitsCommitProp
Laurent Pinchart8666.67%457.14%
Rob Clark2922.48%228.57%
Tomi Valkeinen1410.85%114.29%
Total129100.00%7100.00%

/* ----------------------------------------------------------------------------- * CRTC Functions */
static void omap_crtc_destroy(struct drm_crtc *crtc) { struct omap_crtc *omap_crtc = to_omap_crtc(crtc); DBG("%s", omap_crtc->name); drm_crtc_cleanup(crtc); kfree(omap_crtc); }

Contributors

PersonTokensPropCommitsCommitProp
Rob Clark2152.50%150.00%
Laurent Pinchart1947.50%150.00%
Total40100.00%2100.00%


static void omap_crtc_enable(struct drm_crtc *crtc) { struct omap_crtc *omap_crtc = to_omap_crtc(crtc); int ret; DBG("%s", omap_crtc->name); spin_lock_irq(&crtc->dev->event_lock); drm_crtc_vblank_on(crtc); ret = drm_crtc_vblank_get(crtc); WARN_ON(ret != 0); WARN_ON(omap_crtc->pending); omap_crtc->pending = true; spin_unlock_irq(&crtc->dev->event_lock); }

Contributors

PersonTokensPropCommitsCommitProp
Laurent Pinchart5261.18%562.50%
Rob Clark1618.82%112.50%
Tomi Valkeinen1517.65%112.50%
Archit Taneja22.35%112.50%
Total85100.00%8100.00%


static void omap_crtc_disable(struct drm_crtc *crtc) { struct omap_crtc *omap_crtc = to_omap_crtc(crtc); DBG("%s", omap_crtc->name); drm_crtc_vblank_off(crtc); }

Contributors

PersonTokensPropCommitsCommitProp
Laurent Pinchart3497.14%266.67%
Rob Clark12.86%133.33%
Total35100.00%3100.00%


static void omap_crtc_mode_set_nofb(struct drm_crtc *crtc) { struct omap_crtc *omap_crtc = to_omap_crtc(crtc); struct drm_display_mode *mode = &crtc->state->adjusted_mode; DBG("%s: set mode: %d:\"%s\" %d %d %d %d %d %d %d %d %d %d 0x%x 0x%x", omap_crtc->name, mode->base.id, mode->name, 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); drm_display_mode_to_videomode(mode, &omap_crtc->vm); omap_crtc->vm.flags |= DISPLAY_FLAGS_DE_HIGH | DISPLAY_FLAGS_PIXDATA_POSEDGE | DISPLAY_FLAGS_SYNC_NEGEDGE; }

Contributors

PersonTokensPropCommitsCommitProp
Laurent Pinchart8972.95%228.57%
Rob Clark1713.93%342.86%
Peter Ujfalusi1613.11%228.57%
Total122100.00%7100.00%


static int omap_crtc_atomic_check(struct drm_crtc *crtc, struct drm_crtc_state *state) { if (state->color_mgmt_changed && state->gamma_lut) { uint length = state->gamma_lut->length / sizeof(struct drm_color_lut); if (length < 2) return -EINVAL; } return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Jyri Sarha56100.00%1100.00%
Total56100.00%1100.00%


static void omap_crtc_atomic_begin(struct drm_crtc *crtc, struct drm_crtc_state *old_crtc_state) { }

Contributors

PersonTokensPropCommitsCommitProp
Laurent Pinchart960.00%133.33%
Daniel Vetter533.33%133.33%
Tomi Valkeinen16.67%133.33%
Total15100.00%3100.00%


static void omap_crtc_atomic_flush(struct drm_crtc *crtc, struct drm_crtc_state *old_crtc_state) { struct omap_crtc *omap_crtc = to_omap_crtc(crtc); int ret; if (crtc->state->color_mgmt_changed) { struct drm_color_lut *lut = NULL; uint length = 0; if (crtc->state->gamma_lut) { lut = (struct drm_color_lut *) crtc->state->gamma_lut->data; length = crtc->state->gamma_lut->length / sizeof(*lut); } dispc_mgr_set_gamma(omap_crtc->channel, lut, length); } /* Only flush the CRTC if it is currently enabled. */ if (!omap_crtc->enabled) return; DBG("%s: GO", omap_crtc->name); ret = drm_crtc_vblank_get(crtc); WARN_ON(ret != 0); spin_lock_irq(&crtc->dev->event_lock); dispc_mgr_go(omap_crtc->channel); WARN_ON(omap_crtc->pending); omap_crtc->pending = true; if (crtc->state->event) omap_crtc->event = crtc->state->event; spin_unlock_irq(&crtc->dev->event_lock); }

Contributors

PersonTokensPropCommitsCommitProp
Jyri Sarha7538.86%216.67%
Laurent Pinchart6734.72%650.00%
Tomi Valkeinen3920.21%216.67%
Rob Clark73.63%18.33%
Daniel Vetter52.59%18.33%
Total193100.00%12100.00%


static bool omap_crtc_is_plane_prop(struct drm_crtc *crtc, struct drm_property *property) { struct drm_device *dev = crtc->dev; struct omap_drm_private *priv = dev->dev_private; return property == priv->zorder_prop || property == crtc->primary->rotation_property; }

Contributors

PersonTokensPropCommitsCommitProp
Tomi Valkeinen3571.43%150.00%
Ville Syrjälä1428.57%150.00%
Total49100.00%2100.00%


static int omap_crtc_atomic_set_property(struct drm_crtc *crtc, struct drm_crtc_state *state, struct drm_property *property, uint64_t val) { if (omap_crtc_is_plane_prop(crtc, property)) { struct drm_plane_state *plane_state; struct drm_plane *plane = crtc->primary; /* * Delegate property set to the primary plane. Get the plane * state and set the property directly. */ plane_state = drm_atomic_get_plane_state(state->state, plane); if (IS_ERR(plane_state)) return PTR_ERR(plane_state); return drm_atomic_plane_set_property(plane, plane_state, property, val); } return -EINVAL; }

Contributors

PersonTokensPropCommitsCommitProp
Laurent Pinchart5561.11%228.57%
Tomi Valkeinen2628.89%228.57%
Jyri Sarha77.78%114.29%
Rob Clark11.11%114.29%
Ville Syrjälä11.11%114.29%
Total90100.00%7100.00%


static int omap_crtc_atomic_get_property(struct drm_crtc *crtc, const struct drm_crtc_state *state, struct drm_property *property, uint64_t *val) { if (omap_crtc_is_plane_prop(crtc, property)) { /* * Delegate property get to the primary plane. The * drm_atomic_plane_get_property() function isn't exported, but * can be called through drm_object_property_get_value() as that * will call drm_atomic_get_property() for atomic drivers. */ return drm_object_property_get_value(&crtc->primary->base, property, val); } return -EINVAL; }

Contributors

PersonTokensPropCommitsCommitProp
Laurent Pinchart3866.67%240.00%
Tomi Valkeinen1831.58%240.00%
Ville Syrjälä11.75%120.00%
Total57100.00%5100.00%

static const struct drm_crtc_funcs omap_crtc_funcs = { .reset = drm_atomic_helper_crtc_reset, .set_config = drm_atomic_helper_set_config, .destroy = omap_crtc_destroy, .page_flip = drm_atomic_helper_page_flip, .gamma_set = drm_atomic_helper_legacy_gamma_set, .set_property = drm_atomic_helper_crtc_set_property, .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state, .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state, .atomic_set_property = omap_crtc_atomic_set_property, .atomic_get_property = omap_crtc_atomic_get_property, }; static const struct drm_crtc_helper_funcs omap_crtc_helper_funcs = { .mode_set_nofb = omap_crtc_mode_set_nofb, .disable = omap_crtc_disable, .enable = omap_crtc_enable, .atomic_check = omap_crtc_atomic_check, .atomic_begin = omap_crtc_atomic_begin, .atomic_flush = omap_crtc_atomic_flush, }; /* ----------------------------------------------------------------------------- * Init and Cleanup */ static const char *channel_names[] = { [OMAP_DSS_CHANNEL_LCD] = "lcd", [OMAP_DSS_CHANNEL_DIGIT] = "tv", [OMAP_DSS_CHANNEL_LCD2] = "lcd2", [OMAP_DSS_CHANNEL_LCD3] = "lcd3", };
void omap_crtc_pre_init(void) { dss_install_mgr_ops(&mgr_ops); }

Contributors

PersonTokensPropCommitsCommitProp
Tomi Valkeinen13100.00%1100.00%
Total13100.00%1100.00%


void omap_crtc_pre_uninit(void) { dss_uninstall_mgr_ops(); }

Contributors

PersonTokensPropCommitsCommitProp
Archit Taneja10100.00%1100.00%
Total10100.00%1100.00%

/* initialize crtc */
struct drm_crtc *omap_crtc_init(struct drm_device *dev, struct drm_plane *plane, enum omap_channel channel, int id) { struct drm_crtc *crtc = NULL; struct omap_crtc *omap_crtc; int ret; DBG("%s", channel_names[channel]); omap_crtc = kzalloc(sizeof(*omap_crtc), GFP_KERNEL); if (!omap_crtc) return NULL; crtc = &omap_crtc->base; init_waitqueue_head(&omap_crtc->pending_wait); omap_crtc->channel = channel; omap_crtc->name = channel_names[channel]; ret = drm_crtc_init_with_planes(dev, crtc, plane, NULL, &omap_crtc_funcs, NULL); if (ret < 0) { kfree(omap_crtc); return NULL; } drm_crtc_helper_add(crtc, &omap_crtc_helper_funcs); /* The dispc API adapts to what ever size, but the HW supports * 256 element gamma table for LCDs and 1024 element table for * OMAP_DSS_CHANNEL_DIGIT. X server assumes 256 element gamma * tables so lets use that. Size of HW gamma table can be * extracted with dispc_mgr_gamma_size(). If it returns 0 * gamma table is not supprted. */ if (dispc_mgr_gamma_size(channel)) { uint gamma_lut_size = 256; drm_crtc_enable_color_mgmt(crtc, 0, false, gamma_lut_size); drm_mode_crtc_set_gamma_size(crtc, gamma_lut_size); } omap_plane_install_properties(crtc->primary, &crtc->base); omap_crtcs[channel] = omap_crtc; return crtc; }

Contributors

PersonTokensPropCommitsCommitProp
Rob Clark10553.30%436.36%
Laurent Pinchart3618.27%218.18%
Jyri Sarha3316.75%19.09%
Archit Taneja136.60%19.09%
Tomi Valkeinen84.06%218.18%
Ville Syrjälä21.02%19.09%
Total197100.00%11100.00%


Overall Contributors

PersonTokensPropCommitsCommitProp
Laurent Pinchart97044.48%2338.98%
Tomi Valkeinen49722.79%1728.81%
Rob Clark44720.50%610.17%
Jyri Sarha1818.30%35.08%
Archit Taneja311.42%46.78%
Peter Ujfalusi251.15%23.39%
Ville Syrjälä180.83%23.39%
Daniel Vetter120.55%23.39%
Total2181100.00%59100.00%
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.