On Fri, 2008-11-07 at 15:31 -0800, Jesse Barnes wrote: 
> [Justify this massive code drop here.]

Don't forget this bit :) 

Looks pretty good.  The only real problem is the licensing notes towards the 
end.

> +/**
> + * drm_idr_get - allocate a new identifier
> + * @dev: DRM device
> + * @ptr: object pointer, used to generate unique ID
> + *
> + * LOCKING:
> + * Caller must hold DRM mode_config lock.
> + *
> + * Create a unique identifier based on @ptr in @dev's identifier space.  Used
> + * for tracking modes, CRTCs and connectors.
> + *
> + * RETURNS:
> + * New unique (relative to other objects in @dev) integer identifier for the
> + * object.
> + */
> +static int drm_mode_object_get(struct drm_device *dev,
> +                            struct drm_mode_object *obj, uint32_t obj_type)
> +{

Disagreement between function name and doc.  Might want to assert the
lock.

> +/**
> + * drm_mode_create - create a new display mode
> + * @dev: DRM device
> + *
> + * LOCKING:
> + * None.
> + *
> + * Create a new drm_display_mode, give it an ID, and return it.
> + *
> + * RETURNS:
> + * Pointer to new mode on success, NULL on error.
> + */
> +struct drm_display_mode *drm_mode_create(struct drm_device *dev)
> +{
> +     struct drm_display_mode *nmode;
> +
> +     nmode = kzalloc(sizeof(struct drm_display_mode), GFP_KERNEL);
> +     if (!nmode)
> +             return NULL;
> +
> +     drm_mode_object_get(dev, &nmode->base, DRM_MODE_OBJECT_MODE);

doc claims no locking but calling drm_mode_object_get with lock unheld.

> +/**
> + * drm_mode_create_dvi_i_properties - create DVI-I specific connector 
> properties
> + * @dev: DRM device
> + *
> + * Called by a driver the first time a DVI-I connector is made.
> + */
> +int drm_mode_create_dvi_i_properties(struct drm_device *dev)
> +{
> +     int i;
> +
> +     if (dev->mode_config.dvi_i_select_subconnector_property)
> +             return 0;
> +
> +     dev->mode_config.dvi_i_select_subconnector_property = 
> drm_property_create(dev, DRM_MODE_PROP_ENUM,
> +                                 "select subconnector", 3);
> +     /* add enum element 0-2 */
> +     for (i = 0; i < 3; i++)
> +             
> drm_property_add_enum(dev->mode_config.dvi_i_select_subconnector_property, i, 
> drm_select_subconnector_enum_list[i].type,
> +                             drm_select_subconnector_enum_list[i].name);
> +
> +     /* This is a property which indicates the most likely thing to be 
> connected. */
> +     dev->mode_config.dvi_i_subconnector_property = drm_property_create(dev, 
> DRM_MODE_PROP_ENUM | DRM_MODE_PROP_IMMUTABLE,
> +                                 "subconnector", 3);
> +     /* add enum element 0-2 */
> +     for (i = 0; i < 3; i++)
> +             
> drm_property_add_enum(dev->mode_config.dvi_i_subconnector_property, i, 
> drm_subconnector_enum_list[i].type,
> +                             drm_subconnector_enum_list[i].name);

Hardcoded array indices so far from the definitions of the array are a
little scary.  Perhaps separate arrays for dvi-i/tv, and ARRAY_SIZE()?

> +/**
> + * drm_crtc_convert_to_umode - convert a modeinfo into a drm_display_mode
> + * @out: drm_display_mode to return to the user
> + * @in: drm_mode_modeinfo to use
> + *
> + * LOCKING:
> + * None.
> + *
> + * Convert a drmo_mode_modeinfo into a drm_display_mode structure to return 
> to
> + * the caller.

typo: drmo_mode_modeinfo

> +/**
> + * drm_mode_getresources - get graphics configuration
> + * @inode: inode from the ioctl
> + * @filp: file * from the ioctl
> + * @cmd: cmd from ioctl
> + * @arg: arg from ioctl
> + *
> + * LOCKING:
> + * Takes mode config lock.
> + *
> + * Construct a set of configuration description structures and return
> + * them to the user, including CRTC, connector and framebuffer configuration.
> + *
> + * Called by the user via ioctl.
> + *
> + * RETURNS:
> + * Zero on success, errno on failure.
> + */
> +int drm_mode_getresources(struct drm_device *dev,
> +                       void *data, struct drm_file *file_priv)
> +{
> +     struct drm_mode_card_res *card_res = data;
> +     struct list_head *lh;
> +     struct drm_framebuffer *fb;
> +     struct drm_connector *connector;
> +     struct drm_crtc *crtc;
> +     struct drm_encoder *encoder;
> +     int ret = 0;
> +     int connector_count = 0;
> +     int crtc_count = 0;
> +     int fb_count = 0;
> +     int encoder_count = 0;
> +     int copied = 0, i;
> +     uint32_t __user *fb_id;
> +     uint32_t __user *crtc_id;
> +     uint32_t __user *connector_id;
> +     uint32_t __user *encoder_id;
> +     struct drm_mode_group *mode_group;
> +
> +     mutex_lock(&dev->mode_config.mutex);
> +
> +     /* for the non-control nodes we need to limit the list of resources by 
> IDs in the
> +        group list for this node */
> +     list_for_each(lh, &file_priv->fbs)
> +             fb_count++;
> +
> +     mode_group = &file_priv->master->minor->mode_group;
> +     if (file_priv->master->minor->type == DRM_MINOR_CONTROL) {
> +
> +             list_for_each(lh, &dev->mode_config.crtc_list)
> +                     crtc_count++;
> +
> +             list_for_each(lh, &dev->mode_config.connector_list)
> +                     connector_count++;
> +
> +             list_for_each(lh, &dev->mode_config.encoder_list)
> +                     encoder_count++;
> +     } else {
> +
> +             crtc_count = mode_group->num_crtcs;
> +             connector_count = mode_group->num_connectors;
> +             encoder_count = mode_group->num_encoders;
> +     }
> +
> +     card_res->max_height = dev->mode_config.max_height;
> +     card_res->min_height = dev->mode_config.min_height;
> +     card_res->max_width = dev->mode_config.max_width;
> +     card_res->min_width = dev->mode_config.min_width;
> +
> +     /* handle this in 4 parts */
> +     /* FBs */
> +     if (card_res->count_fbs >= fb_count) {
> +             copied = 0;
> +             fb_id = (uint32_t *)(unsigned long)card_res->fb_id_ptr;

(uint32_t __user *) to appease sparse

> +int drm_mode_cursor_ioctl(struct drm_device *dev,
> +                     void *data, struct drm_file *file_priv)
> +{
> +     struct drm_mode_cursor *req = data;
> +     struct drm_mode_object *obj;
> +     struct drm_crtc *crtc;
> +     int ret = 0;
> +
> +     DRM_DEBUG("\n");
> +
> +     if (!req->flags) {
> +             DRM_ERROR("no operation set\n");
> +             return -EINVAL;
> +     }
> +
> +     mutex_lock(&dev->mode_config.mutex);
> +     obj = drm_mode_object_find(dev, req->crtc, DRM_MODE_OBJECT_CRTC);
> +     if (!obj) {
> +             DRM_DEBUG("Unknown CRTC ID %d\n", req->crtc);
> +             ret = -EINVAL;
> +             goto out;
> +     }
> +     crtc = obj_to_crtc(obj);
> +
> +     if (req->flags & DRM_MODE_CURSOR_BO) {
> +             /* Turn of the cursor if handle is 0 */

s/of/off/

> +             if (crtc->funcs->cursor_set) {
> +                     ret = crtc->funcs->cursor_set(crtc, file_priv, 
> req->handle, req->width, req->height);
> +             } else {
> +                     DRM_ERROR("crtc does not support cursor\n");
> +                     ret = -EFAULT;

these should be -EINVAL or -ENXIO or something not -EFAULT.  (user
didn't hand you a bad pointer)

> +                     goto out;
> +             }
> +     }
> +
> +     if (req->flags & DRM_MODE_CURSOR_MOVE) {
> +             if (crtc->funcs->cursor_move) {
> +                     ret = crtc->funcs->cursor_move(crtc, req->x, req->y);
> +             } else {
> +                     DRM_ERROR("crtc does not support cursor\n");
> +                     ret = -EFAULT;
> +                     goto out;
> +             }
> +     }
> +out:
> +     mutex_unlock(&dev->mode_config.mutex);
> +     return ret;
> +}

This ioctl seems to be a 1:1 mapping of cursors to crtcs.  As far as I
understand, we have a many:1 mapping of cursors to crtcs possible on
Intel, and it seems relevant for MPX.  I guess that could be a future
ioctl, though.

> +/*
> + *
> + */

/* Least informative comment ever. */

> +static int drm_mode_attachmode(struct drm_device *dev,
> +                            struct drm_connector *connector,
> +                            struct drm_display_mode *mode)
> +{
> +     int ret = 0;
> +
> +     list_add_tail(&mode->head, &connector->user_modes);
> +     return ret;
> +}

> diff --git a/drivers/gpu/drm/drm_crtc_helper.c 
> b/drivers/gpu/drm/drm_crtc_helper.c
> new file mode 100644
> index 0000000..a0f3ffe
> --- /dev/null
> +++ b/drivers/gpu/drm/drm_crtc_helper.c

> +     /* XXX free adjustedmode */
> +     drm_mode_destroy(dev, adjusted_mode);
> +     /* TODO */
> +//   if (scrn->pScreen)
> +//           drm_crtc_set_screen_sub_pixel_order(dev);

// comments

> +bool drm_helper_plugged_event(struct drm_device *dev)
> +{
> +     DRM_DEBUG("\n");
> +
> +     drm_helper_probe_connector_modes(dev, dev->mode_config.max_width,
> +                                      dev->mode_config.max_height);
> +
> +     drm_setup_crtcs(dev);
> +
> +     /* alert the driver fb layer */
> +     dev->mode_config.funcs->fb_changed(dev);
> +
> +//   drm_helper_disable_unused_functions(dev);
> +
> +//   drm_sysfs_hotplug_event(dev);

// comments

> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> new file mode 100644
> index 0000000..b75483f
> --- /dev/null
> +++ b/drivers/gpu/drm/drm_edid.c

> +/**
> + * drm_mode_std - convert standard mode info (width, height, refresh) into 
> mode
> + * @t: standard timing params
> + *
> + * Take the standard timing params (in this case width, aspect, and refresh)
> + * and convert them into a real mode using CVT.
> + *
> + * Punts for now, but should eventually use the FB layer's CVT based mode
> + * generation code.
> + */
> +struct drm_display_mode *drm_mode_std(struct drm_device *dev,
> +                                   struct std_timing *t)
> +{
> +//   struct fb_videomode mode;
> +
> +//   fb_find_mode_cvt(&mode, 0, 0);

// comments

> diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
> new file mode 100644
> index 0000000..4e05e80
> --- /dev/null
> +++ b/drivers/gpu/drm/drm_modes.c
> @@ -0,0 +1,570 @@
> +/*
> + * Copyright © 1997-2003 by The XFree86 Project, Inc.
> + *
> + * 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 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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.
> + *
> + * Except as contained in this notice, the name of the copyright holder(s)
> + * and author(s) shall not be used in advertising or otherwise to promote
> + * the sale, use or other dealings in this Software without prior written
> + * authorization from the copyright holder(s) and author(s).
> + */
> +/*
> + * Copyright © 2007 Dave Airlie
> + */

Is there a license associated with this copyright?

> +/* FIXME: what we don't have a list sort function? */
> +/* list sort from Mark J Roberts ([EMAIL PROTECTED]) */

From what I could see, this would be GPL-licensed, but the header on
this file says XF86.

> +void list_sort(struct list_head *head, int (*cmp)(struct list_head *a, 
> struct list_head *b))
> +{
> +     struct list_head *p, *q, *e, *list, *tail, *oldhead;
> +     int insize, nmerges, psize, qsize, i;
> +
> +     list = head->next;
> +     list_del(head);
> +     insize = 1;
> +     for (;;) {
> +             p = oldhead = list;
> +             list = tail = NULL;
> +             nmerges = 0;
> +
> +             while (p) {
> +                     nmerges++;
> +                     q = p;
> +                     psize = 0;
> +                     for (i = 0; i < insize; i++) {
> +                             psize++;
> +                             q = q->next == oldhead ? NULL : q->next;
> +                             if (!q)
> +                                     break;
> +                     }
> +
> +                     qsize = insize;
> +                     while (psize > 0 || (qsize > 0 && q)) {
> +                             if (!psize) {
> +                                     e = q;
> +                                     q = q->next;
> +                                     qsize--;
> +                                     if (q == oldhead)
> +                                             q = NULL;
> +                             } else if (!qsize || !q) {
> +                                     e = p;
> +                                     p = p->next;
> +                                     psize--;
> +                                     if (p == oldhead)
> +                                             p = NULL;
> +                             } else if (cmp(p, q) <= 0) {
> +                                     e = p;
> +                                     p = p->next;
> +                                     psize--;
> +                                     if (p == oldhead)
> +                                             p = NULL;
> +                             } else {
> +                                     e = q;
> +                                     q = q->next;
> +                                     qsize--;
> +                                     if (q == oldhead)
> +                                             q = NULL;
> +                             }
> +                             if (tail)
> +                                     tail->next = e;
> +                             else
> +                                     list = e;
> +                             e->prev = tail;
> +                             tail = e;
> +                     }
> +                     p = q;
> +             }
> +
> +             tail->next = list;
> +             list->prev = tail;
> +
> +             if (nmerges <= 1)
> +                     break;
> +
> +             insize *= 2;
> +     }
> +
> +     head->next = list;
> +     head->prev = list->prev;
> +     list->prev->next = head;
> +     list->prev = head;
> +}


> --- /dev/null
> +++ b/include/drm/drm_crtc.h
> @@ -0,0 +1,716 @@
> +/*
> + * Copyright © 2006 Keith Packard
> + * Copyright © 2007 Intel Corporation
> + *   Jesse Barnes <[EMAIL PROTECTED]>
> + */

Copyright with no license?

> diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
> new file mode 100644
> index 0000000..e770205
> --- /dev/null
> +++ b/include/drm/drm_crtc_helper.h
> @@ -0,0 +1,96 @@
> +/*
> + * Copyright © 2006 Keith Packard
> + * Copyright © 2007 Intel Corporation
> + *   Jesse Barnes <[EMAIL PROTECTED]>
> + */

License?

> diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h
> new file mode 100644
> index 0000000..dccfba9
> --- /dev/null
> +++ b/include/drm/drm_edid.h
> @@ -0,0 +1,178 @@
> +#ifndef __DRM_EDID_H__
> +#define __DRM_EDID_H__
> +
> +#include <linux/types.h>

Copyright?

-- 
Eric Anholt
[EMAIL PROTECTED]                         [EMAIL PROTECTED]


Attachment: signature.asc
Description: This is a digitally signed message part

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
--
_______________________________________________
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to