aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2009-06-03 00:42:45 +0100
committerThomas White <taw@bitwiz.org.uk>2009-06-03 00:42:45 +0100
commitfc1aa2d81852798ea8772705cafec88405d3b4f7 (patch)
tree3b4bb08a1377f66337c3a8e7e3a73accab938973
parentda4745334d168390fc9afe7dbe8f729df2aa9afa (diff)
KMS Skeleton Bits
This adds more of the bare bones for KMS, to be fleshed out later. Signed-off-by: Thomas White <taw@bitwiz.org.uk>
-rw-r--r--drivers/mfd/glamo/glamo-display.c199
-rw-r--r--drivers/mfd/glamo/glamo-drm-private.h12
2 files changed, 198 insertions, 13 deletions
diff --git a/drivers/mfd/glamo/glamo-display.c b/drivers/mfd/glamo/glamo-display.c
index b129b8da455..e0c654f2386 100644
--- a/drivers/mfd/glamo/glamo-display.c
+++ b/drivers/mfd/glamo/glamo-display.c
@@ -20,6 +20,34 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
+ *
+ * Based on intel_display.c and intel_crt.c from drivers/gpu/drm/i915
+ * to which the following licence applies:
+ *
+ * Copyright © 2006-2007 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Eric Anholt <eric@anholt.net>
+ *
*/
@@ -106,7 +134,106 @@ static void glamo_crtc_destroy(struct drm_crtc *crtc)
}
-static const struct drm_crtc_helper_funcs glamo_helper_funcs = {
+static enum drm_connector_status
+glamo_connector_detect(struct drm_connector *connector)
+{
+ /* One hopes it hasn't been de-soldered... */
+ return connector_status_connected;
+}
+
+
+static void glamo_connector_destroy(struct drm_connector *connector)
+{
+ drm_sysfs_connector_remove(connector);
+ drm_connector_cleanup(connector);
+ kfree(connector);
+}
+
+
+static int glamo_connector_get_modes(struct drm_connector *connector)
+{
+ return false;
+}
+
+
+static int glamo_connector_set_property(struct drm_connector *connector,
+ struct drm_property *property,
+ uint64_t value)
+{
+ return 0;
+}
+
+
+static int glamo_connector_mode_valid(struct drm_connector *connector,
+ struct drm_display_mode *mode)
+{
+ if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
+ return MODE_NO_DBLESCAN;
+
+ if (mode->clock > 400000 || mode->clock < 25000)
+ return MODE_CLOCK_RANGE;
+
+ return MODE_OK;
+}
+
+
+struct drm_encoder *
+glamo_connector_best_encoder(struct drm_connector *connector)
+{
+ struct glamo_output *glamo_output = to_glamo_output(connector);
+
+ return &glamo_output->enc;
+}
+
+
+static void glamo_encoder_dpms(struct drm_encoder *encoder, int mode)
+{
+}
+
+
+static bool glamo_encoder_mode_fixup(struct drm_encoder *encoder,
+ struct drm_display_mode *mode,
+ struct drm_display_mode *adjusted_mode)
+{
+ return true;
+}
+
+
+void glamo_encoder_prepare(struct drm_encoder *encoder)
+{
+}
+
+
+void glamo_encoder_commit(struct drm_encoder *encoder)
+{
+}
+
+
+static void glamo_encoder_mode_set(struct drm_encoder *encoder,
+ struct drm_display_mode *mode,
+ struct drm_display_mode *adjusted_mode)
+{
+}
+
+
+static void glamo_encoder_destroy(struct drm_encoder *encoder)
+{
+ drm_encoder_cleanup(encoder);
+}
+
+
+/* CRTC functions */
+static const struct drm_crtc_funcs glamo_crtc_funcs = {
+ .cursor_set = glamo_crtc_cursor_set,
+ .cursor_move = glamo_crtc_cursor_move,
+ .gamma_set = glamo_crtc_gamma_set,
+ .set_config = drm_crtc_helper_set_config,
+ .destroy = glamo_crtc_destroy,
+};
+
+
+/* CRTC helper functions */
+static const struct drm_crtc_helper_funcs glamo_crtc_helper_funcs = {
.dpms = glamo_crtc_dpms,
.mode_fixup = glamo_crtc_mode_fixup,
.mode_set = glamo_crtc_mode_set,
@@ -116,12 +243,36 @@ static const struct drm_crtc_helper_funcs glamo_helper_funcs = {
};
-static const struct drm_crtc_funcs glamo_crtc_funcs = {
- .cursor_set = glamo_crtc_cursor_set,
- .cursor_move = glamo_crtc_cursor_move,
- .gamma_set = glamo_crtc_gamma_set,
- .set_config = drm_crtc_helper_set_config,
- .destroy = glamo_crtc_destroy,
+/* Connector functions */
+static const struct drm_connector_funcs glamo_connector_funcs = {
+ .detect = glamo_connector_detect,
+ .fill_modes = drm_helper_probe_single_connector_modes,
+ .destroy = glamo_connector_destroy,
+ .set_property = glamo_connector_set_property,
+};
+
+
+/* Connector helper functions */
+static const struct drm_connector_helper_funcs glamo_connector_helper_funcs = {
+ .mode_valid = glamo_connector_mode_valid,
+ .get_modes = glamo_connector_get_modes,
+ .best_encoder = glamo_connector_best_encoder,
+};
+
+
+/* Encoder functions */
+static const struct drm_encoder_funcs glamo_encoder_funcs = {
+ .destroy = glamo_encoder_destroy,
+};
+
+
+/* Encoder helper functions */
+static const struct drm_encoder_helper_funcs glamo_encoder_helper_funcs = {
+ .dpms = glamo_encoder_dpms,
+ .mode_fixup = glamo_encoder_mode_fixup,
+ .prepare = glamo_encoder_prepare,
+ .commit = glamo_encoder_commit,
+ .mode_set = glamo_encoder_mode_set,
};
@@ -129,16 +280,38 @@ int glamo_display_init(struct drm_device *dev)
{
struct glamodrm_handle *gdrm;
struct glamo_crtc *glamo_crtc;
-
- glamo_crtc = kzalloc(sizeof(struct glamo_crtc)
- + sizeof(struct drm_connector *), GFP_KERNEL);
- if (glamo_crtc == NULL)
- return 1;
+ struct glamo_output *glamo_output;
+ struct drm_connector *connector;
gdrm = dev->dev_private;
+ /* Initialise our CRTC object */
+ glamo_crtc = kzalloc(sizeof(struct glamo_crtc)
+ + sizeof(struct drm_connector *), GFP_KERNEL);
+ if (glamo_crtc == NULL) return 1;
drm_crtc_init(dev, &glamo_crtc->base, &glamo_crtc_funcs);
- drm_crtc_helper_add(&glamo_crtc->base, &glamo_helper_funcs);
+ drm_crtc_helper_add(&glamo_crtc->base, &glamo_crtc_helper_funcs);
+
+ /* Create our "output" object: consists of an output and an encoder */
+ glamo_output = kzalloc(sizeof(struct glamo_output), GFP_KERNEL);
+ if (glamo_output == NULL) return 1;
+ connector = &glamo_output->base;
+
+ /* Initialise the connector */
+ drm_connector_init(dev, &glamo_output->base, &glamo_connector_funcs,
+ DRM_MODE_CONNECTOR_Unknown);
+ drm_sysfs_connector_add(connector);
+ connector->interlace_allowed = 0;
+ connector->doublescan_allowed = 0;
+
+ /* Initialise the encoder */
+ drm_encoder_init(dev, &glamo_output->enc, &glamo_encoder_funcs,
+ DRM_MODE_ENCODER_DAC);
+ drm_mode_connector_attach_encoder(&glamo_output->base,
+ &glamo_output->enc);
+
+ drm_encoder_helper_add(&glamo_output->enc, &glamo_encoder_helper_funcs);
+ drm_connector_helper_add(connector, &glamo_connector_helper_funcs);
return 0;
}
diff --git a/drivers/mfd/glamo/glamo-drm-private.h b/drivers/mfd/glamo/glamo-drm-private.h
index d1c76c23115..835b65bc8cd 100644
--- a/drivers/mfd/glamo/glamo-drm-private.h
+++ b/drivers/mfd/glamo/glamo-drm-private.h
@@ -71,6 +71,18 @@ struct glamo_crtc {
};
+struct glamo_framebuffer {
+ struct drm_framebuffer base;
+ struct drm_gem_object *obj;
+};
+
+
+struct glamo_output {
+ struct drm_connector base;
+ struct drm_encoder enc;
+};
+
+
#define to_glamo_crtc(x) container_of(x, struct glamo_crtc, base)
#define to_glamo_output(x) container_of(x, struct glamo_output, base)
#define enc_to_glamo_output(x) container_of(x, struct glamo_output, enc)