mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Luca Tettamanti <kronos.it@gmail.com>
To: Jesse Barnes <jesse.barnes@intel.com>
Cc: linux-kernel@vger.kernel.org,
	James Simmons <jsimmons@pentafluge.infradead.org>,
	Dave Airlie <airlied@gmail.com>,
	"Antonino A. Daplas" <adaplas@gmail.com>,
	dri-devel@lists.sourceforge.net
Subject: Re: [PATCH 2/3] drm modesetting core
Date: Fri, 18 May 2007 01:41:35 +0200	[thread overview]
Message-ID: <20070517234135.GA18012@dreamland.darkstar.lan> (raw)
In-Reply-To: <200705171537.46639.jesse.barnes@intel.com>

Il Thu, May 17, 2007 at 03:37:45PM -0700, Jesse Barnes ha scritto: 
> This patch adds the core of the new DRM based modesetting system.

A couple of comments on drm_fb since I'm somewhat familiar with fb code:

> new file mode 100644
> index 0000000..0d06792
> --- /dev/null
> +++ b/linux-core/drm_edid.c
> @@ -0,0 +1,467 @@
> +/*
> + * Copyright (c) 2007 Intel Corporation
> + *   Jesse Barnes <jesse.barnes@intel.com>
> + *
> + * DDC probing routines (drm_ddc_read & drm_do_probe_ddc_edid) 
> originally from
> + * FB layer.

Hum, why are you duplicating them here? fbmon.c has the
infrastructure for parsing and even fixing known-broken EDIDs.

> + *   Copyright (C) 2006 Dennis Munsie <dmunsie@cecropia.com>
> + */
> +#include <linux/i2c.h>
> +#include <linux/i2c-algo-bit.h>
> +#include "drmP.h"
> +#include "drm_edid.h"
> +
> +/* Valid EDID header has these bytes */
> +static u8 edid_header[] = { 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
> 0x00 };
> +
> +/**
> + * edid_valid - sanity check EDID data
> + * @edid: EDID data
> + *
> + * Sanity check the EDID block by looking at the header, the version 
> number
> + * and the checksum.  Return 0 if the EDID doesn't check out, or 1 if 
> it's
> + * valid.
> + */
> +static bool edid_valid(struct edid *edid)
> +{
> +	int i;
> +	u8 csum = 0;
> +	u8 *raw_edid = (u8 *)edid;
> +
> +	if (memcmp(edid->header, edid_header, sizeof(edid_header)))
> +		goto bad;
> +	if (edid->version != 1)
> +		goto bad;
> +	if (edid->revision <= 0 || edid->revision > 3)
> +		goto bad;
> +
> +	for (i = 0; i < EDID_LENGTH; i++)
> +		csum += raw_edid[i];
> +	if (csum)
> +		goto bad;
> +
> +	return 1;
> +
> +bad:
> +	return 0;
> +}

This is basically edid_check_header + edid_checksum.

> +
> +/**
> + * 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)
> +{

get_std_timing?

> +/**
> + * drm_mode_detailed - create a new mode from an EDID detailed timing 
> section
> + * @timing: EDID detailed timing info
> + * @preferred: is this a preferred mode?
> + *
> + * An EDID detailed timing block contains enough info for us to create 
> and
> + * return a new struct drm_display_mode.  The @preferred flag will be 
> set
> + * if this is the display's preferred timing, and we'll use it to 
> indicate
> + * to the other layers that this mode is desired.
> + */
> +struct drm_display_mode *drm_mode_detailed(drm_device_t *dev,
> +					   struct detailed_timing *timing)
> +{

get_detailed_timing?

If you  can't use 'struct fb_videomode' we may refactor code around a common
data structure instead of a copy&paste.

> +static unsigned char *drm_do_probe_ddc_edid(struct i2c_adapter 
> *adapter)
[...]
> +static unsigned char *drm_ddc_read(struct i2c_adapter *adapter)
[...]

Copy and paste from fb_dcc.c; furthermore a fix in drm_ddc_read hasn't
been backported to the original code.

> diff --git a/linux-core/drm_fb.c b/linux-core/drm_fb.c
> new file mode 100644
> index 0000000..ef05341
> --- /dev/null
> +++ b/linux-core/drm_fb.c
> @@ -0,0 +1,201 @@
> +/*
> + * Copyright © 2007 David Airlie
> + *
> + * 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:
> + *     David Airlie
> + */
> +    /*
> +     *  Modularization
> +     */
> +
> +#include <linux/module.h>
> +#include <linux/kernel.h>
> +#include <linux/errno.h>
> +#include <linux/string.h>
> +#include <linux/mm.h>
> +#include <linux/tty.h>
> +#include <linux/slab.h>
> +#include <linux/delay.h>
> +#include <linux/fb.h>
> +#include <linux/init.h>
> +
> +#include "drmP.h"
> +struct drmfb_par {
> +	struct drm_device *dev;
> +	struct drm_framebuffer *fb;
> +};
> +
> +static int drmfb_setcolreg(unsigned regno, unsigned red, unsigned 
> green,
> +			   unsigned blue, unsigned transp,
> +			   struct fb_info *info)
> +{
> +	struct drmfb_par *par = info->par;
> +	struct drm_framebuffer *fb = par->fb;
> +	if (regno > 17)
> +		return 1;
> +
> +	if (regno < 16) {
> +		switch (fb->depth) {
> +		case 15:
> +			fb->pseudo_palette[regno] = ((red & 0xf800) >>  1) |
> +				((green & 0xf800) >>  6) |
> +				((blue & 0xf800) >> 11);
> +			break;
> +		case 16:
> +			fb->pseudo_palette[regno] = (red & 0xf800) |
> +				((green & 0xfc00) >>  5) |
> +				((blue  & 0xf800) >> 11);
> +			break;
> +		case 24:
> +		case 32:
> +			fb->pseudo_palette[regno] = ((red & 0xff00) << 8) |
> +				(green & 0xff00) |
> +				((blue  & 0xff00) >> 8);
> +			break;
> +		}
> +	}
> +
> +	return 0;
> +}
> +
> +/* this will let fbcon do the mode init */
> +static int drmfb_set_par(struct fb_info *info)
> +{
> +	struct drmfb_par *par = info->par;
> +	struct drm_device *dev = par->dev;
> +
> +	drm_set_desired_modes(dev);
> +	return 0;
> +}
> +
> +static struct fb_ops drmfb_ops = {
> +	.owner = THIS_MODULE,
> +	//	.fb_open = drmfb_open,
> +	//	.fb_read = drmfb_read,
> +	//	.fb_write = drmfb_write,
> +	//	.fb_release = drmfb_release,
> +	//	.fb_ioctl = drmfb_ioctl,
> +	.fb_set_par = drmfb_set_par,
> +	.fb_setcolreg = drmfb_setcolreg,
> +	.fb_fillrect = cfb_fillrect,
> +	.fb_copyarea = cfb_copyarea,
> +	.fb_imageblit = cfb_imageblit,
> +};
> +
> +int drmfb_probe(struct drm_device *dev, struct drm_framebuffer *fb)
> +{
> +	struct fb_info *info;
> +	struct drmfb_par *par;
> +	struct device *device = &dev->pdev->dev; 
> +	struct fb_var_screeninfo *var_info;
> +	unsigned long base, size;
> +	int ret;
> +
> +	info = framebuffer_alloc(sizeof(struct drmfb_par), device);
> +	if (!info){
> +		return -EINVAL;
> +	}

-ENOMEM? Plus, spurious brackets.

> +	if (register_framebuffer(info) < 0)
> +		return -EINVAL;

You leak the fb_info structure on error path.

> +
> +	printk(KERN_INFO "fb%d: %s frame buffer device\n", info->node,
> +	       info->fix.id);
> +	return 0;
> +}
> +EXPORT_SYMBOL(drmfb_probe);


Luca
-- 
Software is like sex; it's better when it's free.
Linus Torvalds

  parent reply	other threads:[~2007-05-17 23:41 UTC|newest]

Thread overview: 100+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-17 21:23 [RFC] enhancing the kernel's graphics subsystem Jesse Barnes
2007-05-17 22:32 ` [PATCH 1/3] allow console unregistration Jesse Barnes
2007-05-17 22:47   ` Jesse Barnes
2007-05-17 23:23   ` Antonino A. Daplas
2007-05-18  0:56     ` Jesse Barnes
2007-05-22 21:43     ` [PATCH 1/2] " Jesse Barnes
2007-05-23  0:49       ` Antonino A. Daplas
2007-05-22 21:44     ` [PATCH 2/2] make fbcon unregister when unloaded Jesse Barnes
2007-05-22 22:05       ` Randy Dunlap
2007-05-22 22:14         ` Jesse Barnes
2007-05-23  0:47           ` Antonino A. Daplas
2007-05-30  0:00   ` [PATCH 1/3] allow console unregistration Antonino A. Daplas
2007-05-30  6:26     ` Geert Uytterhoeven
2007-05-17 22:37 ` [PATCH 2/3] drm modesetting core Jesse Barnes
2007-05-17 22:48   ` Jesse Barnes
2007-05-17 23:41   ` Luca Tettamanti [this message]
2007-05-18  1:04     ` Jesse Barnes
2007-05-18 19:33       ` Luca Tettamanti
2007-05-18 21:06         ` Jesse Barnes
2007-05-17 22:40 ` [PATCH 3/3] Intel support for DRM modesetting Jesse Barnes
2007-05-17 22:48   ` Jesse Barnes
2007-05-20 17:42 ` [RFC] enhancing the kernel's graphics subsystem Jon Smirl
2007-05-20 23:10   ` Jesse Barnes
2007-05-21  0:47     ` Jon Smirl
2007-05-21  1:29       ` Jeff Garzik
2007-05-21 15:34         ` Jon Smirl
2007-05-21 16:15           ` Arjan van de Ven
2007-05-21 15:09       ` Jesse Barnes
2007-05-21 16:01         ` Jon Smirl
2007-05-21 16:14           ` Jesse Barnes
2007-05-21 16:34             ` Jesse Barnes
2007-05-21 17:05               ` Jon Smirl
2007-05-21 17:14                 ` Dave Airlie
2007-05-21 17:29                   ` Jon Smirl
2007-05-21 17:42                   ` Jon Smirl
2007-05-21 17:47                     ` Dave Airlie
2007-05-21 18:04                       ` Jon Smirl
2007-05-21 18:44                         ` Dave Airlie
2007-05-21 19:10                           ` Jon Smirl
2007-05-21 19:20                             ` Dave Airlie
2007-05-21 23:24                             ` Jeff Garzik
2007-05-22  0:08                               ` Jon Smirl
2007-05-22  0:20                     ` Benjamin Herrenschmidt
2007-05-21 23:21                   ` Jeff Garzik
2007-05-22  0:35                     ` Alan Cox
2007-05-22  0:33                       ` Jeff Garzik
2007-05-22  0:45                       ` Jon Smirl
2007-05-22  0:56                         ` Jon Smirl
2007-05-22  8:21                           ` Dave Airlie
2007-05-22  8:07                     ` Dave Airlie
2007-05-22  8:16                       ` Jeff Garzik
2007-05-22  8:27                         ` Dave Airlie
2007-05-22 16:06                         ` Jon Smirl
2007-05-22 16:19                           ` Alan Cox
2007-05-22 16:34                           ` Jeff Garzik
2007-05-22  0:15                   ` Benjamin Herrenschmidt
2007-05-21 17:32                 ` Jesse Barnes
2007-05-21 23:18                 ` Jeff Garzik
2007-05-22  0:26                   ` Jon Smirl
2007-05-22  1:56                     ` Jesse Barnes
2007-05-22 14:27                       ` Jon Smirl
2007-05-22 14:35                         ` Dave Airlie
2007-05-22 15:13                           ` Jon Smirl
2007-05-22 17:25                             ` Dave Airlie
2007-05-22 19:58                               ` Jon Smirl
2007-05-28 20:12                                 ` Pavel Machek
2007-05-28 20:57                                   ` Jon Smirl
2007-05-29 14:26                                     ` Pavel Machek
2007-05-29 16:51                                       ` Jon Smirl
2007-05-22 14:54                         ` Alan Cox
2007-05-22 15:16                           ` Jon Smirl
2007-05-22 15:46                             ` Jesse Barnes
2007-05-22 16:02                               ` Jon Smirl
2007-05-22 16:14                                 ` Alan Cox
2007-05-22 16:15                                 ` Jesse Barnes
2007-05-22 16:32                                   ` Jon Smirl
2007-05-22 16:35                                     ` Jeff Garzik
2007-05-22 16:51                                     ` Jesse Barnes
2007-05-22 15:59                             ` Matthew Garrett
2007-05-21 16:16           ` Dave Airlie
2007-05-21  8:27   ` Dave Airlie
2007-05-21  9:09     ` Helge Hafting
2007-05-21  9:27       ` Dave Airlie
2007-05-21  9:44         ` Helge Hafting
2007-05-21 15:57           ` Jesse Barnes
2007-05-21 16:07             ` Jon Smirl
2007-05-21 16:27               ` Dave Airlie
2007-05-21 16:50                 ` Xavier Bestel
2007-05-22  0:09 ` Benjamin Herrenschmidt
2007-05-22  0:51   ` Keith Packard
2007-05-22  2:48     ` Benjamin Herrenschmidt
2007-05-22 15:39   ` Jesse Barnes
2007-05-22 23:26     ` Benjamin Herrenschmidt
2007-05-22 23:36       ` Jesse Barnes
2007-05-23  0:40         ` Antonino A. Daplas
2007-05-23 12:19       ` Helge Hafting
2007-05-22 16:29   ` Philipp Klaus Krause
2007-05-22 16:57     ` Jesse Barnes
2007-05-22 18:18     ` Dave Airlie
2007-05-22  2:56 ` l l

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070517234135.GA18012@dreamland.darkstar.lan \
    --to=kronos.it@gmail.com \
    --cc=adaplas@gmail.com \
    --cc=airlied@gmail.com \
    --cc=dri-devel@lists.sourceforge.net \
    --cc=jesse.barnes@intel.com \
    --cc=jsimmons@pentafluge.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®