mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-24 03:24:55 +08:00
0d8f371f5a
The omapdrm driver currently takes a config/module arg to figure out the number of crtcs it needs to create. We could create as many crtcs as there are overlay managers in the DSS hardware, but we don't do that because each crtc eats up one DSS overlay, and that reduces the number of planes we can attach to a single crtc. Since the number of crtcs may be lesser than the number of hardware overlay managers, we need to figure out which overlay managers to use for our crtcs. The current approach is to use pipe2chan(), which returns a higher numbered manager for the crtc. The problem with this approach is that it assumes that the overlay managers we choose will connect to the encoders the platform's panels are going to use, this isn't true, an overlay manager connects only to a few outputs/encoders, and choosing any overlay manager for our crtc might lead to a situation where the encoder cannot connect to any of the crtcs we have chosen. For example, an omap5-panda board has just one hdmi output. If num_crtc is set to 1, with the current approach, pipe2chan will pick up the LCD2 overlay manager, which cannot connect to the hdmi encoder at all. The only manager that could have connected to hdmi was the TV overlay manager. Therefore, there is a need to choose our overlay managers keeping in mind the panels we have on that platform. The new approach iterates through all the available panels, creates encoders and connectors for them, and then tries to get a suitable overlay manager to create a crtc which can connect to the encoders. We use the dispc_channel field in omap_dss_output to retrieve the desired overlay manager's channel number, we then check whether the manager had already been assigned to a crtc or not. If it was already assigned to a crtc, we assume that out of all the encoders which intend use this crtc, only one will run at a time. If the overlay manager wan't assigned to a crtc till then, we create a new crtc and link it with the overlay manager. This approach just looks for the best dispc_channel for each encoder. On DSS HW, some encoders can connect to multiple overlay managers. Since we don't try looking for alternate overlay managers, there is a greater possibility that 2 or more encoders end up asking for the same crtc, causing only one encoder to run at a time. Also, this approach isn't the most optimal one, it can do either good or bad depending on the sequence in which the panels/outputs are parsed. The optimal way would be some sort of back tracking approach, where we improve the set of managers we use as we iterate through the list of panels/encoders. That's something left for later. Signed-off-by: Archit Taneja <archit@ti.com> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
189 lines
4.7 KiB
C
189 lines
4.7 KiB
C
/*
|
|
* drivers/gpu/drm/omapdrm/omap_encoder.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 "omap_drv.h"
|
|
|
|
#include "drm_crtc.h"
|
|
#include "drm_crtc_helper.h"
|
|
|
|
#include <linux/list.h>
|
|
|
|
|
|
/*
|
|
* encoder funcs
|
|
*/
|
|
|
|
#define to_omap_encoder(x) container_of(x, struct omap_encoder, base)
|
|
|
|
/* The encoder and connector both map to same dssdev.. the encoder
|
|
* handles the 'active' parts, ie. anything the modifies the state
|
|
* of the hw, and the connector handles the 'read-only' parts, like
|
|
* detecting connection and reading edid.
|
|
*/
|
|
struct omap_encoder {
|
|
struct drm_encoder base;
|
|
struct omap_dss_device *dssdev;
|
|
};
|
|
|
|
struct omap_dss_device *omap_encoder_get_dssdev(struct drm_encoder *encoder)
|
|
{
|
|
struct omap_encoder *omap_encoder = to_omap_encoder(encoder);
|
|
|
|
return omap_encoder->dssdev;
|
|
}
|
|
|
|
static void omap_encoder_destroy(struct drm_encoder *encoder)
|
|
{
|
|
struct omap_encoder *omap_encoder = to_omap_encoder(encoder);
|
|
drm_encoder_cleanup(encoder);
|
|
kfree(omap_encoder);
|
|
}
|
|
|
|
static const struct drm_encoder_funcs omap_encoder_funcs = {
|
|
.destroy = omap_encoder_destroy,
|
|
};
|
|
|
|
/*
|
|
* The CRTC drm_crtc_helper_set_mode() doesn't really give us the right
|
|
* order.. the easiest way to work around this for now is to make all
|
|
* the encoder-helper's no-op's and have the omap_crtc code take care
|
|
* of the sequencing and call us in the right points.
|
|
*
|
|
* Eventually to handle connecting CRTCs to different encoders properly,
|
|
* either the CRTC helpers need to change or we need to replace
|
|
* drm_crtc_helper_set_mode(), but lets wait until atomic-modeset for
|
|
* that.
|
|
*/
|
|
|
|
static void omap_encoder_dpms(struct drm_encoder *encoder, int mode)
|
|
{
|
|
}
|
|
|
|
static bool omap_encoder_mode_fixup(struct drm_encoder *encoder,
|
|
const struct drm_display_mode *mode,
|
|
struct drm_display_mode *adjusted_mode)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
static void omap_encoder_mode_set(struct drm_encoder *encoder,
|
|
struct drm_display_mode *mode,
|
|
struct drm_display_mode *adjusted_mode)
|
|
{
|
|
}
|
|
|
|
static void omap_encoder_prepare(struct drm_encoder *encoder)
|
|
{
|
|
}
|
|
|
|
static void omap_encoder_commit(struct drm_encoder *encoder)
|
|
{
|
|
}
|
|
|
|
static const struct drm_encoder_helper_funcs omap_encoder_helper_funcs = {
|
|
.dpms = omap_encoder_dpms,
|
|
.mode_fixup = omap_encoder_mode_fixup,
|
|
.mode_set = omap_encoder_mode_set,
|
|
.prepare = omap_encoder_prepare,
|
|
.commit = omap_encoder_commit,
|
|
};
|
|
|
|
/*
|
|
* Instead of relying on the helpers for modeset, the omap_crtc code
|
|
* calls these functions in the proper sequence.
|
|
*/
|
|
|
|
int omap_encoder_set_enabled(struct drm_encoder *encoder, bool enabled)
|
|
{
|
|
struct omap_encoder *omap_encoder = to_omap_encoder(encoder);
|
|
struct omap_dss_device *dssdev = omap_encoder->dssdev;
|
|
struct omap_dss_driver *dssdrv = dssdev->driver;
|
|
|
|
if (enabled) {
|
|
return dssdrv->enable(dssdev);
|
|
} else {
|
|
dssdrv->disable(dssdev);
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
int omap_encoder_update(struct drm_encoder *encoder,
|
|
struct omap_overlay_manager *mgr,
|
|
struct omap_video_timings *timings)
|
|
{
|
|
struct drm_device *dev = encoder->dev;
|
|
struct omap_encoder *omap_encoder = to_omap_encoder(encoder);
|
|
struct omap_dss_device *dssdev = omap_encoder->dssdev;
|
|
struct omap_dss_driver *dssdrv = dssdev->driver;
|
|
int ret;
|
|
|
|
dssdev->output->manager = mgr;
|
|
|
|
if (dssdrv->check_timings) {
|
|
ret = dssdrv->check_timings(dssdev, timings);
|
|
} else {
|
|
struct omap_video_timings t = {0};
|
|
|
|
dssdrv->get_timings(dssdev, &t);
|
|
|
|
if (memcmp(timings, &t, sizeof(struct omap_video_timings)))
|
|
ret = -EINVAL;
|
|
else
|
|
ret = 0;
|
|
}
|
|
|
|
if (ret) {
|
|
dev_err(dev->dev, "could not set timings: %d\n", ret);
|
|
return ret;
|
|
}
|
|
|
|
if (dssdrv->set_timings)
|
|
dssdrv->set_timings(dssdev, timings);
|
|
|
|
return 0;
|
|
}
|
|
|
|
/* initialize encoder */
|
|
struct drm_encoder *omap_encoder_init(struct drm_device *dev,
|
|
struct omap_dss_device *dssdev)
|
|
{
|
|
struct drm_encoder *encoder = NULL;
|
|
struct omap_encoder *omap_encoder;
|
|
|
|
omap_encoder = kzalloc(sizeof(*omap_encoder), GFP_KERNEL);
|
|
if (!omap_encoder)
|
|
goto fail;
|
|
|
|
omap_encoder->dssdev = dssdev;
|
|
|
|
encoder = &omap_encoder->base;
|
|
|
|
drm_encoder_init(dev, encoder, &omap_encoder_funcs,
|
|
DRM_MODE_ENCODER_TMDS);
|
|
drm_encoder_helper_add(encoder, &omap_encoder_helper_funcs);
|
|
|
|
return encoder;
|
|
|
|
fail:
|
|
if (encoder)
|
|
omap_encoder_destroy(encoder);
|
|
|
|
return NULL;
|
|
}
|