* Re: [PATCH 02/10] arm: at91: move platfarm_data to include/linux/platform_data/atmel.h
From: Dmitry Torokhov @ 2012-11-10 8:42 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <509A5219.2080408@pengutronix.de>
On Wed, Nov 07, 2012 at 01:20:41PM +0100, Marc Kleine-Budde wrote:
> On 11/07/2012 12:22 PM, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> > Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
> > Cc: linux-ide@vger.kernel.org
> > Cc: linux-input@vger.kernel.org
> > Cc: linux-mmc@vger.kernel.org
> > Cc: linux-can@vger.kernel.org
> > Cc: netdev@vger.kernel.org
> > Cc: linux-pcmcia@lists.infradead.org
> > Cc: rtc-linux@googlegroups.com
> > Cc: spi-devel-general@lists.sourceforge.net
> > Cc: linux-serial@vger.kernel.org
> > Cc: linux-usb@vger.kernel.org
> > Cc: linux-fbdev@vger.kernel.org
> > ---
> > HI all,
> >
> > If it's ok with everyone this will go via at91
> > with the patch serie than clean up the include/mach
>
> Fine with me.
>
> > For preparation to switch to arm multiarch kernel
>
> Acked-by: Marc Kleine-Budde <mkl@pengutronix.de> (for the CAN related changes)
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
for input piece.
--
Dmitry
^ permalink raw reply
* Re: tty, vt: lockdep warnings (Patch v3)
From: Sasha Levin @ 2012-11-09 19:42 UTC (permalink / raw)
To: Hugh Dickins
Cc: Alan Cox, Bjørn Mork, Sasha Levin, Dave Jones, Daniel Vetter,
Greg Kroah-Hartman, Jiri Slaby, linux-kernel, linux-fbdev,
florianSchandinat
In-Reply-To: <alpine.LNX.2.00.1211091133310.3733@eggly.anvils>
On 11/09/2012 02:34 PM, Hugh Dickins wrote:
> On Thu, 8 Nov 2012, Alan Cox wrote:
>> commit f35b3fbf24c4e4debb6a7a864b09854ccc2a22e7
>> Author: Alan Cox <alan@linux.intel.com>
>> Date: Wed Nov 7 16:35:08 2012 +0000
>>
>> fb: Rework locking to fix lock ordering on takeover
>>
>> Adjust the console layer to allow a take over call where the caller already
>> holds the locks. Make the fb layer lock in order.
>>
>> This s partly a band aid, the fb layer is terminally confused about the
>> locking rules it uses for its notifiers it seems.
>>
>> Signed-off-by: Alan Cox <alan@linux.intel.com>
>
> This version works for me too - thanks.
> Hugh
I was planning to test it last night, but new code in mm/ failed horribly and
was BUG()ing all over the place, so I didn't get any significant testing
of this patch done.
Will update...
Thanks,
Sasha
^ permalink raw reply
* Re: tty, vt: lockdep warnings (Patch v3)
From: Hugh Dickins @ 2012-11-09 19:34 UTC (permalink / raw)
To: Alan Cox
Cc: Bjørn Mork, Sasha Levin, Dave Jones, Sasha Levin,
Daniel Vetter, Greg Kroah-Hartman, Jiri Slaby, linux-kernel,
linux-fbdev, florianSchandinat
In-Reply-To: <20121108143408.77033416@pyramind.ukuu.org.uk>
[-- Attachment #1: Type: TEXT/PLAIN, Size: 8994 bytes --]
On Thu, 8 Nov 2012, Alan Cox wrote:
> commit f35b3fbf24c4e4debb6a7a864b09854ccc2a22e7
> Author: Alan Cox <alan@linux.intel.com>
> Date: Wed Nov 7 16:35:08 2012 +0000
>
> fb: Rework locking to fix lock ordering on takeover
>
> Adjust the console layer to allow a take over call where the caller already
> holds the locks. Make the fb layer lock in order.
>
> This s partly a band aid, the fb layer is terminally confused about the
> locking rules it uses for its notifiers it seems.
>
> Signed-off-by: Alan Cox <alan@linux.intel.com>
This version works for me too - thanks.
Hugh
>
> diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
> index f87d7e8..77bf205 100644
> --- a/drivers/tty/vt/vt.c
> +++ b/drivers/tty/vt/vt.c
> @@ -2984,7 +2984,7 @@ int __init vty_init(const struct file_operations *console_fops)
>
> static struct class *vtconsole_class;
>
> -static int bind_con_driver(const struct consw *csw, int first, int last,
> +static int do_bind_con_driver(const struct consw *csw, int first, int last,
> int deflt)
> {
> struct module *owner = csw->owner;
> @@ -2995,7 +2995,7 @@ static int bind_con_driver(const struct consw *csw, int first, int last,
> if (!try_module_get(owner))
> return -ENODEV;
>
> - console_lock();
> + WARN_CONSOLE_UNLOCKED();
>
> /* check if driver is registered */
> for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
> @@ -3080,11 +3080,22 @@ static int bind_con_driver(const struct consw *csw, int first, int last,
>
> retval = 0;
> err:
> - console_unlock();
> module_put(owner);
> return retval;
> };
>
> +
> +static int bind_con_driver(const struct consw *csw, int first, int last,
> + int deflt)
> +{
> + int ret;
> +
> + console_lock();
> + ret = do_bind_con_driver(csw, first, last, deflt);
> + console_unlock();
> + return ret;
> +}
> +
> #ifdef CONFIG_VT_HW_CONSOLE_BINDING
> static int con_is_graphics(const struct consw *csw, int first, int last)
> {
> @@ -3196,9 +3207,9 @@ int unbind_con_driver(const struct consw *csw, int first, int last, int deflt)
> if (!con_is_bound(csw))
> con_driver->flag &= ~CON_DRIVER_FLAG_INIT;
>
> - console_unlock();
> /* ignore return value, binding should not fail */
> - bind_con_driver(defcsw, first, last, deflt);
> + do_bind_con_driver(defcsw, first, last, deflt);
> + console_unlock();
> err:
> module_put(owner);
> return retval;
> @@ -3489,28 +3500,18 @@ int con_debug_leave(void)
> }
> EXPORT_SYMBOL_GPL(con_debug_leave);
>
> -/**
> - * register_con_driver - register console driver to console layer
> - * @csw: console driver
> - * @first: the first console to take over, minimum value is 0
> - * @last: the last console to take over, maximum value is MAX_NR_CONSOLES -1
> - *
> - * DESCRIPTION: This function registers a console driver which can later
> - * bind to a range of consoles specified by @first and @last. It will
> - * also initialize the console driver by calling con_startup().
> - */
> -int register_con_driver(const struct consw *csw, int first, int last)
> +static int do_register_con_driver(const struct consw *csw, int first, int last)
> {
> struct module *owner = csw->owner;
> struct con_driver *con_driver;
> const char *desc;
> int i, retval = 0;
>
> + WARN_CONSOLE_UNLOCKED();
> +
> if (!try_module_get(owner))
> return -ENODEV;
>
> - console_lock();
> -
> for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
> con_driver = ®istered_con_driver[i];
>
> @@ -3563,10 +3564,29 @@ int register_con_driver(const struct consw *csw, int first, int last)
> }
>
> err:
> - console_unlock();
> module_put(owner);
> return retval;
> }
> +
> +/**
> + * register_con_driver - register console driver to console layer
> + * @csw: console driver
> + * @first: the first console to take over, minimum value is 0
> + * @last: the last console to take over, maximum value is MAX_NR_CONSOLES -1
> + *
> + * DESCRIPTION: This function registers a console driver which can later
> + * bind to a range of consoles specified by @first and @last. It will
> + * also initialize the console driver by calling con_startup().
> + */
> +int register_con_driver(const struct consw *csw, int first, int last)
> +{
> + int retval;
> +
> + console_lock();
> + retval = do_register_con_driver(csw, first, last);
> + console_unlock();
> + return retval;
> +}
> EXPORT_SYMBOL(register_con_driver);
>
> /**
> @@ -3622,6 +3642,29 @@ EXPORT_SYMBOL(unregister_con_driver);
> *
> * take_over_console is basically a register followed by unbind
> */
> +int do_take_over_console(const struct consw *csw, int first, int last, int deflt)
> +{
> + int err;
> +
> + err = do_register_con_driver(csw, first, last);
> + /* if we get an busy error we still want to bind the console driver
> + * and return success, as we may have unbound the console driver
> + * but not unregistered it.
> + */
> + if (err == -EBUSY)
> + err = 0;
> + if (!err)
> + do_bind_con_driver(csw, first, last, deflt);
> +
> + return err;
> +}
> +/*
> + * If we support more console drivers, this function is used
> + * when a driver wants to take over some existing consoles
> + * and become default driver for newly opened ones.
> + *
> + * take_over_console is basically a register followed by unbind
> + */
> int take_over_console(const struct consw *csw, int first, int last, int deflt)
> {
> int err;
> diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
> index fdefa8f..c75f8ce 100644
> --- a/drivers/video/console/fbcon.c
> +++ b/drivers/video/console/fbcon.c
> @@ -529,6 +529,34 @@ static int search_for_mapped_con(void)
> return retval;
> }
>
> +static int do_fbcon_takeover(int show_logo)
> +{
> + int err, i;
> +
> + if (!num_registered_fb)
> + return -ENODEV;
> +
> + if (!show_logo)
> + logo_shown = FBCON_LOGO_DONTSHOW;
> +
> + for (i = first_fb_vc; i <= last_fb_vc; i++)
> + con2fb_map[i] = info_idx;
> +
> + err = do_take_over_console(&fb_con, first_fb_vc, last_fb_vc,
> + fbcon_is_default);
> +
> + if (err) {
> + for (i = first_fb_vc; i <= last_fb_vc; i++) {
> + con2fb_map[i] = -1;
> + }
> + info_idx = -1;
> + } else {
> + fbcon_has_console_bind = 1;
> + }
> +
> + return err;
> +}
> +
> static int fbcon_takeover(int show_logo)
> {
> int err, i;
> @@ -3115,7 +3143,7 @@ static int fbcon_fb_registered(struct fb_info *info)
> }
>
> if (info_idx != -1)
> - ret = fbcon_takeover(1);
> + ret = do_fbcon_takeover(1);
> } else {
> for (i = first_fb_vc; i <= last_fb_vc; i++) {
> if (con2fb_map_boot[i] == idx)
> diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
> index 3ff0105..564ebe9 100644
> --- a/drivers/video/fbmem.c
> +++ b/drivers/video/fbmem.c
> @@ -1650,7 +1650,9 @@ static int do_register_framebuffer(struct fb_info *fb_info)
> event.info = fb_info;
> if (!lock_fb_info(fb_info))
> return -ENODEV;
> + console_lock();
> fb_notifier_call_chain(FB_EVENT_FB_REGISTERED, &event);
> + console_unlock();
> unlock_fb_info(fb_info);
> return 0;
> }
> @@ -1853,11 +1855,8 @@ int fb_new_modelist(struct fb_info *info)
> err = 1;
>
> if (!list_empty(&info->modelist)) {
> - if (!lock_fb_info(info))
> - return -ENODEV;
> event.info = info;
> err = fb_notifier_call_chain(FB_EVENT_NEW_MODELIST, &event);
> - unlock_fb_info(info);
> }
>
> return err;
> diff --git a/drivers/video/fbsysfs.c b/drivers/video/fbsysfs.c
> index a55e366..ef476b0 100644
> --- a/drivers/video/fbsysfs.c
> +++ b/drivers/video/fbsysfs.c
> @@ -177,6 +177,8 @@ static ssize_t store_modes(struct device *device,
> if (i * sizeof(struct fb_videomode) != count)
> return -EINVAL;
>
> + if (!lock_fb_info(fb_info))
> + return -ENODEV;
> console_lock();
> list_splice(&fb_info->modelist, &old_list);
> fb_videomode_to_modelist((const struct fb_videomode *)buf, i,
> @@ -188,6 +190,7 @@ static ssize_t store_modes(struct device *device,
> fb_destroy_modelist(&old_list);
>
> console_unlock();
> + unlock_fb_info(fb_info);
>
> return 0;
> }
> diff --git a/include/linux/console.h b/include/linux/console.h
> index dedb082..4ef4307 100644
> --- a/include/linux/console.h
> +++ b/include/linux/console.h
> @@ -78,6 +78,7 @@ int con_is_bound(const struct consw *csw);
> int register_con_driver(const struct consw *csw, int first, int last);
> int unregister_con_driver(const struct consw *csw);
> int take_over_console(const struct consw *sw, int first, int last, int deflt);
> +int do_take_over_console(const struct consw *sw, int first, int last, int deflt);
> void give_up_console(const struct consw *sw);
> #ifdef CONFIG_HW_CONSOLE
> int con_debug_enter(struct vc_data *vc);
>
^ permalink raw reply
* Re: [PATCH v7 5/8] fbmon: add videomode helpers
From: Steffen Trumtrar @ 2012-11-09 19:31 UTC (permalink / raw)
To: Manjunathappa, Prakash
Cc: linux-fbdev@vger.kernel.org, devicetree-discuss@lists.ozlabs.org,
dri-devel@lists.freedesktop.org, Valkeinen, Tomi,
Laurent Pinchart, kernel@pengutronix.de, Guennady Liakhovetski,
linux-media@vger.kernel.org
In-Reply-To: <A73F36158E33644199EB82C5EC81C7BC3E9E614A@DBDE01.ent.ti.com>
Hi!
On Fri, Nov 09, 2012 at 04:54:16PM +0000, Manjunathappa, Prakash wrote:
> Hi Steffen,
>
> On Fri, Nov 09, 2012 at 02:55:45, Steffen Trumtrar wrote:
> > Hi!
> >
> > On Wed, Oct 31, 2012 at 03:30:03PM +0000, Manjunathappa, Prakash wrote:
> > > Hi Steffen,
> > >
> > > On Wed, Oct 31, 2012 at 14:58:05, Steffen Trumtrar wrote:
> > > > +#if IS_ENABLED(CONFIG_VIDEOMODE)
> > > > +int videomode_to_fb_videomode(struct videomode *vm, struct fb_videomode *fbmode)
> > > > +{
> > > > + fbmode->xres = vm->hactive;
> > > > + fbmode->left_margin = vm->hback_porch;
> > > > + fbmode->right_margin = vm->hfront_porch;
> > > > + fbmode->hsync_len = vm->hsync_len;
> > > > +
> > > > + fbmode->yres = vm->vactive;
> > > > + fbmode->upper_margin = vm->vback_porch;
> > > > + fbmode->lower_margin = vm->vfront_porch;
> > > > + fbmode->vsync_len = vm->vsync_len;
> > > > +
> > > > + fbmode->pixclock = KHZ2PICOS(vm->pixelclock / 1000);
> > > > +
> > > > + fbmode->sync = 0;
> > > > + fbmode->vmode = 0;
> > > > + if (vm->hah)
> > > > + fbmode->sync |= FB_SYNC_HOR_HIGH_ACT;
> > > > + if (vm->vah)
> > > > + fbmode->sync |= FB_SYNC_VERT_HIGH_ACT;
> > > > + if (vm->interlaced)
> > > > + fbmode->vmode |= FB_VMODE_INTERLACED;
> > > > + if (vm->doublescan)
> > > > + fbmode->vmode |= FB_VMODE_DOUBLE;
> > > > +
> > >
> > > "pixelclk-inverted" property of the panel is not percolated fb_videomode.
> > > Please let me know if I am missing something.
> > >
> >
> > The next version is almost finished. Only thing I'm missing is this.
> > And I actually do not know which flag would represent an inverted pixelclock
> > in fb_videomode. Does anybody have any idea what I have to do here?
> >
> > if (vm->pixelclk_pol)
> > fbmode->sync = ???
> >
> > That's as far as I have come and I don't see a flag that seems right.
> > Is this even a valid property of fb_videomode?
> >
>
> Thanks for considering it, I see IMX addresses it as proprietary FB_SYNC_ flag.
> FB_SYNC_CLK_INVERT: arch/arm/plat-mxc/include/mach/mx3fb.h
>
No problem. So, it seems this flag has to be set in some imx-specific
videomode_to_fb_videomode function. It is included in the
struct videomode, so that should be no problem. But it will not be
part of this series.
Regards,
Steffen
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply
* RE: [PATCH v7 5/8] fbmon: add videomode helpers
From: Manjunathappa, Prakash @ 2012-11-09 16:54 UTC (permalink / raw)
To: Steffen Trumtrar
Cc: linux-fbdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
Valkeinen, Tomi, Laurent Pinchart,
kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org,
Guennady Liakhovetski,
linux-media-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
In-Reply-To: <20121108212545.GA32605-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
Hi Steffen,
On Fri, Nov 09, 2012 at 02:55:45, Steffen Trumtrar wrote:
> Hi!
>
> On Wed, Oct 31, 2012 at 03:30:03PM +0000, Manjunathappa, Prakash wrote:
> > Hi Steffen,
> >
> > On Wed, Oct 31, 2012 at 14:58:05, Steffen Trumtrar wrote:
> > > +#if IS_ENABLED(CONFIG_VIDEOMODE)
> > > +int videomode_to_fb_videomode(struct videomode *vm, struct fb_videomode *fbmode)
> > > +{
> > > + fbmode->xres = vm->hactive;
> > > + fbmode->left_margin = vm->hback_porch;
> > > + fbmode->right_margin = vm->hfront_porch;
> > > + fbmode->hsync_len = vm->hsync_len;
> > > +
> > > + fbmode->yres = vm->vactive;
> > > + fbmode->upper_margin = vm->vback_porch;
> > > + fbmode->lower_margin = vm->vfront_porch;
> > > + fbmode->vsync_len = vm->vsync_len;
> > > +
> > > + fbmode->pixclock = KHZ2PICOS(vm->pixelclock / 1000);
> > > +
> > > + fbmode->sync = 0;
> > > + fbmode->vmode = 0;
> > > + if (vm->hah)
> > > + fbmode->sync |= FB_SYNC_HOR_HIGH_ACT;
> > > + if (vm->vah)
> > > + fbmode->sync |= FB_SYNC_VERT_HIGH_ACT;
> > > + if (vm->interlaced)
> > > + fbmode->vmode |= FB_VMODE_INTERLACED;
> > > + if (vm->doublescan)
> > > + fbmode->vmode |= FB_VMODE_DOUBLE;
> > > +
> >
> > "pixelclk-inverted" property of the panel is not percolated fb_videomode.
> > Please let me know if I am missing something.
> >
>
> The next version is almost finished. Only thing I'm missing is this.
> And I actually do not know which flag would represent an inverted pixelclock
> in fb_videomode. Does anybody have any idea what I have to do here?
>
> if (vm->pixelclk_pol)
> fbmode->sync = ???
>
> That's as far as I have come and I don't see a flag that seems right.
> Is this even a valid property of fb_videomode?
>
Thanks for considering it, I see IMX addresses it as proprietary FB_SYNC_ flag.
FB_SYNC_CLK_INVERT: arch/arm/plat-mxc/include/mach/mx3fb.h
Thanks,
Prakash
^ permalink raw reply
* [PATCH] backlight: Add of_find_backlight_by_node() function
From: Thierry Reding @ 2012-11-09 14:04 UTC (permalink / raw)
To: Richard Purdie, Florian Tobias Schandinat
Cc: linux-fbdev-u79uwXL29TY76Z2rM5mHXA,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1352326119-7301-1-git-send-email-thierry.reding@avionic-design.de>
This function finds the struct backlight_device for a given device tree
node. A dummy function is provided so that it safely compiles out if OF
support is disabled.
Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
---
drivers/video/backlight/backlight.c | 17 +++++++++++++++++
include/linux/backlight.h | 10 ++++++++++
2 files changed, 27 insertions(+)
diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index 297db2f..0d1ed4f 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -370,6 +370,23 @@ void backlight_device_unregister(struct backlight_device *bd)
}
EXPORT_SYMBOL(backlight_device_unregister);
+#if IS_ENABLED(CONFIG_OF)
+static int of_parent_match(struct device *dev, void *data)
+{
+ return dev->parent && dev->parent->of_node = data;
+}
+
+struct backlight_device *of_find_backlight_by_node(struct device_node *node)
+{
+ struct device *dev;
+
+ dev = class_find_device(backlight_class, NULL, node, of_parent_match);
+
+ return dev ? to_backlight_device(dev) : NULL;
+}
+EXPORT_SYMBOL(of_find_backlight_by_node);
+#endif
+
static void __exit backlight_class_exit(void)
{
class_destroy(backlight_class);
diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index 5ffc6dd..11840e9 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -134,4 +134,14 @@ struct generic_bl_info {
void (*kick_battery)(void);
};
+#if IS_ENABLED(CONFIG_OF)
+struct backlight_device *of_find_backlight_by_node(struct device_node *node);
+#else
+static inline struct backlight_device *
+of_find_backlight_by_node(struct device_node *node)
+{
+ return NULL;
+}
+#endif
+
#endif
--
1.8.0
^ permalink raw reply related
* Re: [PATCH v7 0/8] of: add display helper
From: Steffen Trumtrar @ 2012-11-09 8:22 UTC (permalink / raw)
To: Rob Herring
Cc: devicetree-discuss, linux-fbdev, dri-devel, Laurent Pinchart,
Thierry Reding, Guennady Liakhovetski, linux-media,
Tomi Valkeinen, Stephen Warren, kernel
In-Reply-To: <509C25B3.5060509@gmail.com>
On Thu, Nov 08, 2012 at 03:35:47PM -0600, Rob Herring wrote:
> On 10/31/2012 04:28 AM, Steffen Trumtrar wrote:
> > Hi!
> >
> > Finally, v7 of the series.
> >
> > Changes since v6:
> > - get rid of some empty lines etc.
> > - move functions to their subsystems
> > - split of_ from non-of_ functions
> > - add at least some kerneldoc to some functions
> >
> > Regards,
> > Steffen
> >
> >
> > Steffen Trumtrar (8):
> > video: add display_timing struct and helpers
> > of: add helper to parse display timings
> > of: add generic videomode description
> > video: add videomode helpers
> > fbmon: add videomode helpers
> > fbmon: add of_videomode helpers
> > drm_modes: add videomode helpers
> > drm_modes: add of_videomode helpers
> >
> > .../devicetree/bindings/video/display-timings.txt | 139 +++++++++++++++
> > drivers/gpu/drm/drm_modes.c | 78 +++++++++
> > drivers/of/Kconfig | 12 ++
> > drivers/of/Makefile | 2 +
> > drivers/of/of_display_timings.c | 185 ++++++++++++++++++++
> > drivers/of/of_videomode.c | 47 +++++
>
> Not sure why you moved this, but please move this back to drivers/video.
> We're trying to move subsystem specific pieces out of drivers/of.
>
> Rob
>
Hm, the of_xxx part always was in drivers/of, but I can move that. No problem.
Regards,
Steffen
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply
* Re: [PATCH] pwm-backlight: Pinctrl-fy
From: Thierry Reding @ 2012-11-09 8:06 UTC (permalink / raw)
To: Pantelis Antoniou
Cc: Richard Purdie, Florian Tobias Schandinat, linux-fbdev,
linux-kernel, Koen Kooi, Matt Porter, Russ Dill, linux-omap,
Linus Walleij
In-Reply-To: <1351699047-4487-1-git-send-email-panto@antoniou-consulting.com>
[-- Attachment #1: Type: text/plain, Size: 1923 bytes --]
On Wed, Oct 31, 2012 at 05:57:27PM +0200, Pantelis Antoniou wrote:
> Enable pinctrl for pwm-backlight.
>
> Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com>
> ---
> drivers/video/backlight/pwm_bl.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
> index 0c91023..f3b6194 100644
> --- a/drivers/video/backlight/pwm_bl.c
> +++ b/drivers/video/backlight/pwm_bl.c
> @@ -20,6 +20,8 @@
> #include <linux/pwm.h>
> #include <linux/pwm_backlight.h>
> #include <linux/slab.h>
> +#include <linux/pinctrl/consumer.h>
> +#include <linux/err.h>
>
> struct pwm_bl_data {
> struct pwm_device *pwm;
> @@ -180,9 +182,14 @@ static int pwm_backlight_probe(struct platform_device *pdev)
> struct backlight_properties props;
> struct backlight_device *bl;
> struct pwm_bl_data *pb;
> + struct pinctrl *pinctrl;
> unsigned int max;
> int ret;
>
> + pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
> + if (IS_ERR(pinctrl))
> + dev_warn(&pdev->dev, "unable to select pin group\n");
> +
I just saw this done in a similar way in some other driver and then
remembered your patch. When I reviewed this I wasn't sure if a warning
was good enough in this case. I've checked the kernel tree and it seems
like a majority handled this as failure instead of a warning. I took a
look at the pinctrl core and it seems like indeed if neither pinctrl is
enabled or if there isn't actually a pinmux configuration for a device,
then devm_pinctrl_get_select_default() will actually not return an
error, so in those cases where an error is returned it should actually
be handled as a fatal error.
I'm Cc'ing Linus Walleij, maybe he knows what to do.
Thierry
> if (!data) {
> ret = pwm_backlight_parse_dt(&pdev->dev, &defdata);
> if (ret < 0) {
> --
> 1.7.12
>
>
>
[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply
* [PATCH v4 8/8] video: exynos_dp: Enable hotplug interrupts
From: Jingoo Han @ 2012-11-09 5:53 UTC (permalink / raw)
To: linux-fbdev
From: Sean Paul <seanpaul@chromium.org>
Enable hotplug interrupts and move the hotplug scheduling into the
interrupt handler. This allows us to introduce a screen at any time
while we're running.
[jg1.han@samsung.com: moved the bit masking of hotplug interrupts]
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Reviewed-by: Olof Johansson <olofj@chromium.org>
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
drivers/video/exynos/exynos_dp_core.c | 38 ++++++++++++++++++++++++++-------
drivers/video/exynos/exynos_dp_core.h | 9 +++++++
drivers/video/exynos/exynos_dp_reg.c | 38 +++++++++++++++++++++++++++-----
3 files changed, 71 insertions(+), 14 deletions(-)
diff --git a/drivers/video/exynos/exynos_dp_core.c b/drivers/video/exynos/exynos_dp_core.c
index 79ba1ea..7cbba4a 100644
--- a/drivers/video/exynos/exynos_dp_core.c
+++ b/drivers/video/exynos/exynos_dp_core.c
@@ -48,10 +48,6 @@ static int exynos_dp_detect_hpd(struct exynos_dp_device *dp)
{
int timeout_loop = 0;
- exynos_dp_init_hpd(dp);
-
- usleep_range(200, 210);
-
while (exynos_dp_get_plug_in_status(dp) != 0) {
timeout_loop++;
if (DP_TIMEOUT_LOOP_COUNT < timeout_loop) {
@@ -833,7 +829,32 @@ static irqreturn_t exynos_dp_irq_handler(int irq, void *arg)
{
struct exynos_dp_device *dp = arg;
- dev_err(dp->dev, "exynos_dp_irq_handler\n");
+ enum dp_irq_type irq_type;
+
+ irq_type = exynos_dp_get_irq_type(dp);
+ switch (irq_type) {
+ case DP_IRQ_TYPE_HP_CABLE_IN:
+ dev_dbg(dp->dev, "Received irq - cable in\n");
+ schedule_work(&dp->hotplug_work);
+ exynos_dp_clear_hotplug_interrupts(dp);
+ break;
+ case DP_IRQ_TYPE_HP_CABLE_OUT:
+ dev_dbg(dp->dev, "Received irq - cable out\n");
+ exynos_dp_clear_hotplug_interrupts(dp);
+ break;
+ case DP_IRQ_TYPE_HP_CHANGE:
+ /*
+ * We get these change notifications once in a while, but there
+ * is nothing we can do with them. Just ignore it for now and
+ * only handle cable changes.
+ */
+ dev_dbg(dp->dev, "Received irq - hotplug change; ignoring.\n");
+ exynos_dp_clear_hotplug_interrupts(dp);
+ break;
+ default:
+ dev_err(dp->dev, "Received irq - unknown type!\n");
+ break;
+ }
return IRQ_HANDLED;
}
@@ -846,7 +867,7 @@ static void exynos_dp_hotplug(struct work_struct *work)
ret = exynos_dp_detect_hpd(dp);
if (ret) {
- dev_err(dp->dev, "unable to detect hpd\n");
+ /* Cable has been disconnected, we're done */
return;
}
@@ -937,7 +958,6 @@ static int __devinit exynos_dp_probe(struct platform_device *pdev)
exynos_dp_init_dp(dp);
platform_set_drvdata(pdev, dp);
- schedule_work(&dp->hotplug_work);
return 0;
}
@@ -965,6 +985,8 @@ static int exynos_dp_suspend(struct device *dev)
struct exynos_dp_platdata *pdata = pdev->dev.platform_data;
struct exynos_dp_device *dp = platform_get_drvdata(pdev);
+ disable_irq(dp->irq);
+
if (work_pending(&dp->hotplug_work))
flush_work(&dp->hotplug_work);
@@ -989,7 +1011,7 @@ static int exynos_dp_resume(struct device *dev)
exynos_dp_init_dp(dp);
- schedule_work(&dp->hotplug_work);
+ enable_irq(dp->irq);
return 0;
}
diff --git a/drivers/video/exynos/exynos_dp_core.h b/drivers/video/exynos/exynos_dp_core.h
index 66f11f4..520486e 100644
--- a/drivers/video/exynos/exynos_dp_core.h
+++ b/drivers/video/exynos/exynos_dp_core.h
@@ -13,6 +13,13 @@
#ifndef _EXYNOS_DP_CORE_H
#define _EXYNOS_DP_CORE_H
+enum dp_irq_type {
+ DP_IRQ_TYPE_HP_CABLE_IN,
+ DP_IRQ_TYPE_HP_CABLE_OUT,
+ DP_IRQ_TYPE_HP_CHANGE,
+ DP_IRQ_TYPE_UNKNOWN,
+};
+
struct link_train {
int eq_loop;
int cr_loop[4];
@@ -51,6 +58,8 @@ void exynos_dp_set_analog_power_down(struct exynos_dp_device *dp,
bool enable);
void exynos_dp_init_analog_func(struct exynos_dp_device *dp);
void exynos_dp_init_hpd(struct exynos_dp_device *dp);
+enum dp_irq_type exynos_dp_get_irq_type(struct exynos_dp_device *dp);
+void exynos_dp_clear_hotplug_interrupts(struct exynos_dp_device *dp);
void exynos_dp_reset_aux(struct exynos_dp_device *dp);
void exynos_dp_init_aux(struct exynos_dp_device *dp);
int exynos_dp_get_plug_in_status(struct exynos_dp_device *dp);
diff --git a/drivers/video/exynos/exynos_dp_reg.c b/drivers/video/exynos/exynos_dp_reg.c
index fc19ef6..9fb901b 100644
--- a/drivers/video/exynos/exynos_dp_reg.c
+++ b/drivers/video/exynos/exynos_dp_reg.c
@@ -19,11 +19,11 @@
#include "exynos_dp_core.h"
#include "exynos_dp_reg.h"
-#define COMMON_INT_MASK_1 (0)
-#define COMMON_INT_MASK_2 (0)
-#define COMMON_INT_MASK_3 (0)
-#define COMMON_INT_MASK_4 (0)
-#define INT_STA_MASK (0)
+#define COMMON_INT_MASK_1 0
+#define COMMON_INT_MASK_2 0
+#define COMMON_INT_MASK_3 0
+#define COMMON_INT_MASK_4 (HOTPLUG_CHG | HPD_LOST | PLUG)
+#define INT_STA_MASK INT_HPD
void exynos_dp_enable_video_mute(struct exynos_dp_device *dp, bool enable)
{
@@ -324,7 +324,7 @@ void exynos_dp_init_analog_func(struct exynos_dp_device *dp)
writel(reg, dp->reg_base + EXYNOS_DP_FUNC_EN_2);
}
-void exynos_dp_init_hpd(struct exynos_dp_device *dp)
+void exynos_dp_clear_hotplug_interrupts(struct exynos_dp_device *dp)
{
u32 reg;
@@ -333,12 +333,38 @@ void exynos_dp_init_hpd(struct exynos_dp_device *dp)
reg = INT_HPD;
writel(reg, dp->reg_base + EXYNOS_DP_INT_STA);
+}
+
+void exynos_dp_init_hpd(struct exynos_dp_device *dp)
+{
+ u32 reg;
+
+ exynos_dp_clear_hotplug_interrupts(dp);
reg = readl(dp->reg_base + EXYNOS_DP_SYS_CTL_3);
reg &= ~(F_HPD | HPD_CTRL);
writel(reg, dp->reg_base + EXYNOS_DP_SYS_CTL_3);
}
+enum dp_irq_type exynos_dp_get_irq_type(struct exynos_dp_device *dp)
+{
+ u32 reg;
+
+ /* Parse hotplug interrupt status register */
+ reg = readl(dp->reg_base + EXYNOS_DP_COMMON_INT_STA_4);
+
+ if (reg & PLUG)
+ return DP_IRQ_TYPE_HP_CABLE_IN;
+
+ if (reg & HPD_LOST)
+ return DP_IRQ_TYPE_HP_CABLE_OUT;
+
+ if (reg & HOTPLUG_CHG)
+ return DP_IRQ_TYPE_HP_CHANGE;
+
+ return DP_IRQ_TYPE_UNKNOWN;
+}
+
void exynos_dp_reset_aux(struct exynos_dp_device *dp)
{
u32 reg;
--
1.7.1
^ permalink raw reply related
* [PATCH v4 7/8] video: exynos_dp: Move hotplug into a workqueue
From: Jingoo Han @ 2012-11-09 5:53 UTC (permalink / raw)
To: linux-fbdev
From: Sean Paul <seanpaul@chromium.org>
Move the hotplug related code from probe and resume into a workqueue.
This allows us to initialize the DP driver (and resume it) when there
is no monitor connected.
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Reviewed-by: Olof Johansson <olofj@chromium.org>
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
drivers/video/exynos/exynos_dp_core.c | 93 +++++++++++++++++---------------
drivers/video/exynos/exynos_dp_core.h | 1 +
2 files changed, 50 insertions(+), 44 deletions(-)
diff --git a/drivers/video/exynos/exynos_dp_core.c b/drivers/video/exynos/exynos_dp_core.c
index edb3bfe..79ba1ea 100644
--- a/drivers/video/exynos/exynos_dp_core.c
+++ b/drivers/video/exynos/exynos_dp_core.c
@@ -837,6 +837,45 @@ static irqreturn_t exynos_dp_irq_handler(int irq, void *arg)
return IRQ_HANDLED;
}
+static void exynos_dp_hotplug(struct work_struct *work)
+{
+ struct exynos_dp_device *dp;
+ int ret;
+
+ dp = container_of(work, struct exynos_dp_device, hotplug_work);
+
+ ret = exynos_dp_detect_hpd(dp);
+ if (ret) {
+ dev_err(dp->dev, "unable to detect hpd\n");
+ return;
+ }
+
+ ret = exynos_dp_handle_edid(dp);
+ if (ret) {
+ dev_err(dp->dev, "unable to handle edid\n");
+ return;
+ }
+
+ ret = exynos_dp_set_link_train(dp, dp->video_info->lane_count,
+ dp->video_info->link_rate);
+ if (ret) {
+ dev_err(dp->dev, "unable to do link train\n");
+ return;
+ }
+
+ exynos_dp_enable_scramble(dp, 1);
+ exynos_dp_enable_rx_to_enhanced_mode(dp, 1);
+ exynos_dp_enable_enhanced_mode(dp, 1);
+
+ exynos_dp_set_lane_count(dp, dp->video_info->lane_count);
+ exynos_dp_set_link_bandwidth(dp, dp->video_info->link_rate);
+
+ exynos_dp_init_video(dp);
+ ret = exynos_dp_config_video(dp, dp->video_info);
+ if (ret)
+ dev_err(dp->dev, "unable to config video\n");
+}
+
static int __devinit exynos_dp_probe(struct platform_device *pdev)
{
struct resource *res;
@@ -882,6 +921,8 @@ static int __devinit exynos_dp_probe(struct platform_device *pdev)
return -ENODEV;
}
+ INIT_WORK(&dp->hotplug_work, exynos_dp_hotplug);
+
ret = devm_request_irq(&pdev->dev, dp->irq, exynos_dp_irq_handler, 0,
"exynos-dp", dp);
if (ret) {
@@ -895,36 +936,8 @@ static int __devinit exynos_dp_probe(struct platform_device *pdev)
exynos_dp_init_dp(dp);
- ret = exynos_dp_detect_hpd(dp);
- if (ret) {
- dev_err(&pdev->dev, "unable to detect hpd\n");
- return ret;
- }
-
- exynos_dp_handle_edid(dp);
-
- ret = exynos_dp_set_link_train(dp, dp->video_info->lane_count,
- dp->video_info->link_rate);
- if (ret) {
- dev_err(&pdev->dev, "unable to do link train\n");
- return ret;
- }
-
- exynos_dp_enable_scramble(dp, 1);
- exynos_dp_enable_rx_to_enhanced_mode(dp, 1);
- exynos_dp_enable_enhanced_mode(dp, 1);
-
- exynos_dp_set_lane_count(dp, dp->video_info->lane_count);
- exynos_dp_set_link_bandwidth(dp, dp->video_info->link_rate);
-
- exynos_dp_init_video(dp);
- ret = exynos_dp_config_video(dp, dp->video_info);
- if (ret) {
- dev_err(&pdev->dev, "unable to config video\n");
- return ret;
- }
-
platform_set_drvdata(pdev, dp);
+ schedule_work(&dp->hotplug_work);
return 0;
}
@@ -934,6 +947,9 @@ static int __devexit exynos_dp_remove(struct platform_device *pdev)
struct exynos_dp_platdata *pdata = pdev->dev.platform_data;
struct exynos_dp_device *dp = platform_get_drvdata(pdev);
+ if (work_pending(&dp->hotplug_work))
+ flush_work(&dp->hotplug_work);
+
if (pdata && pdata->phy_exit)
pdata->phy_exit();
@@ -949,6 +965,9 @@ static int exynos_dp_suspend(struct device *dev)
struct exynos_dp_platdata *pdata = pdev->dev.platform_data;
struct exynos_dp_device *dp = platform_get_drvdata(pdev);
+ if (work_pending(&dp->hotplug_work))
+ flush_work(&dp->hotplug_work);
+
if (pdata && pdata->phy_exit)
pdata->phy_exit();
@@ -970,21 +989,7 @@ static int exynos_dp_resume(struct device *dev)
exynos_dp_init_dp(dp);
- exynos_dp_detect_hpd(dp);
- exynos_dp_handle_edid(dp);
-
- exynos_dp_set_link_train(dp, dp->video_info->lane_count,
- dp->video_info->link_rate);
-
- exynos_dp_enable_scramble(dp, 1);
- exynos_dp_enable_rx_to_enhanced_mode(dp, 1);
- exynos_dp_enable_enhanced_mode(dp, 1);
-
- exynos_dp_set_lane_count(dp, dp->video_info->lane_count);
- exynos_dp_set_link_bandwidth(dp, dp->video_info->link_rate);
-
- exynos_dp_init_video(dp);
- exynos_dp_config_video(dp, dp->video_info);
+ schedule_work(&dp->hotplug_work);
return 0;
}
diff --git a/drivers/video/exynos/exynos_dp_core.h b/drivers/video/exynos/exynos_dp_core.h
index 57b8a65..66f11f4 100644
--- a/drivers/video/exynos/exynos_dp_core.h
+++ b/drivers/video/exynos/exynos_dp_core.h
@@ -32,6 +32,7 @@ struct exynos_dp_device {
struct video_info *video_info;
struct link_train link_train;
+ struct work_struct hotplug_work;
};
/* exynos_dp_reg.c */
--
1.7.1
^ permalink raw reply related
* [PATCH v4 6/8] video: exynos_dp: Remove sink control to D0
From: Jingoo Han @ 2012-11-09 5:52 UTC (permalink / raw)
To: linux-fbdev
From: Sean Paul <seanpaul@chromium.org>
According to DP spec, it is not required in the Link Training
procedure.
[jg1.han@samsung.com: modified the commit message]
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
drivers/video/exynos/exynos_dp_core.c | 6 ------
1 files changed, 0 insertions(+), 6 deletions(-)
diff --git a/drivers/video/exynos/exynos_dp_core.c b/drivers/video/exynos/exynos_dp_core.c
index be3df15..edb3bfe 100644
--- a/drivers/video/exynos/exynos_dp_core.c
+++ b/drivers/video/exynos/exynos_dp_core.c
@@ -277,12 +277,6 @@ static int exynos_dp_link_start(struct exynos_dp_device *dp)
for (lane = 0; lane < lane_count; lane++)
dp->link_train.cr_loop[lane] = 0;
- /* Set sink to D0 (Sink Not Ready) mode. */
- retval = exynos_dp_write_byte_to_dpcd(dp, DPCD_ADDR_SINK_POWER_STATE,
- DPCD_SET_POWER_STATE_D0);
- if (retval)
- return retval;
-
/* Set link rate and count as you want to establish*/
exynos_dp_set_link_bandwidth(dp, dp->link_train.link_rate);
exynos_dp_set_lane_count(dp, dp->link_train.lane_count);
--
1.7.1
^ permalink raw reply related
* [PATCH v4 5/8] video: exynos_dp: Fix bug when checking dp->irq
From: Jingoo Han @ 2012-11-09 5:51 UTC (permalink / raw)
To: linux-fbdev
From: Sean Paul <seanpaul@chromium.org>
Fix a bug where we check !dp->irq instead of the correct check for
-ENXIO.
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Reviewed-by: Olof Johansson <olofj@chromium.org>
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
drivers/video/exynos/exynos_dp_core.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/video/exynos/exynos_dp_core.c b/drivers/video/exynos/exynos_dp_core.c
index 4a6ed2f..be3df15 100644
--- a/drivers/video/exynos/exynos_dp_core.c
+++ b/drivers/video/exynos/exynos_dp_core.c
@@ -883,7 +883,7 @@ static int __devinit exynos_dp_probe(struct platform_device *pdev)
}
dp->irq = platform_get_irq(pdev, 0);
- if (!dp->irq) {
+ if (dp->irq = -ENXIO) {
dev_err(&pdev->dev, "failed to get irq\n");
return -ENODEV;
}
--
1.7.1
^ permalink raw reply related
* [PATCH v4 4/8] video: exynos_dp: Improve EDID error handling
From: Jingoo Han @ 2012-11-09 5:50 UTC (permalink / raw)
To: linux-fbdev
From: Sean Paul <seanpaul@chromium.org>
EDID error handling has 2 problems:
- It doesn't fail as early as it can
- The retry counts for i2c and aux transactions are huge
This patch fails if the initial i2c transaction fails, and reduces the
aux and i2c retry counts down to 3.
[jg1.han@samsung.com: reduced the retry count of exynos_dp_read_byte_from_dpcd()]
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
drivers/video/exynos/exynos_dp_core.c | 13 ++++++++-----
drivers/video/exynos/exynos_dp_reg.c | 14 ++++++--------
2 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/drivers/video/exynos/exynos_dp_core.c b/drivers/video/exynos/exynos_dp_core.c
index 6e54a18..4a6ed2f 100644
--- a/drivers/video/exynos/exynos_dp_core.c
+++ b/drivers/video/exynos/exynos_dp_core.c
@@ -90,9 +90,11 @@ static int exynos_dp_read_edid(struct exynos_dp_device *dp)
*/
/* Read Extension Flag, Number of 128-byte EDID extension blocks */
- exynos_dp_read_byte_from_i2c(dp, I2C_EDID_DEVICE_ADDR,
+ retval = exynos_dp_read_byte_from_i2c(dp, I2C_EDID_DEVICE_ADDR,
EDID_EXTENSION_FLAG,
&extend_block);
+ if (retval)
+ return retval;
if (extend_block > 0) {
dev_dbg(dp->dev, "EDID data includes a single extension!\n");
@@ -181,14 +183,15 @@ static int exynos_dp_handle_edid(struct exynos_dp_device *dp)
int retval;
/* Read DPCD DPCD_ADDR_DPCD_REV~RECEIVE_PORT1_CAP_1 */
- exynos_dp_read_bytes_from_dpcd(dp,
- DPCD_ADDR_DPCD_REV,
- 12, buf);
+ retval = exynos_dp_read_bytes_from_dpcd(dp, DPCD_ADDR_DPCD_REV,
+ 12, buf);
+ if (retval)
+ return retval;
/* Read EDID */
for (i = 0; i < 3; i++) {
retval = exynos_dp_read_edid(dp);
- if (retval = 0)
+ if (!retval)
break;
}
diff --git a/drivers/video/exynos/exynos_dp_reg.c b/drivers/video/exynos/exynos_dp_reg.c
index 3f5ca8a..fc19ef6 100644
--- a/drivers/video/exynos/exynos_dp_reg.c
+++ b/drivers/video/exynos/exynos_dp_reg.c
@@ -491,7 +491,7 @@ int exynos_dp_read_byte_from_dpcd(struct exynos_dp_device *dp,
int i;
int retval;
- for (i = 0; i < 10; i++) {
+ for (i = 0; i < 3; i++) {
/* Clear AUX CH data buffer */
reg = BUF_CLR;
writel(reg, dp->reg_base + EXYNOS_DP_BUFFER_DATA_CTL);
@@ -552,7 +552,7 @@ int exynos_dp_write_bytes_to_dpcd(struct exynos_dp_device *dp,
else
cur_data_count = count - start_offset;
- for (i = 0; i < 10; i++) {
+ for (i = 0; i < 3; i++) {
/* Select DPCD device address */
reg = AUX_ADDR_7_0(reg_addr + start_offset);
writel(reg, dp->reg_base + EXYNOS_DP_AUX_ADDR_7_0);
@@ -617,7 +617,7 @@ int exynos_dp_read_bytes_from_dpcd(struct exynos_dp_device *dp,
cur_data_count = count - start_offset;
/* AUX CH Request Transaction process */
- for (i = 0; i < 10; i++) {
+ for (i = 0; i < 3; i++) {
/* Select DPCD device address */
reg = AUX_ADDR_7_0(reg_addr + start_offset);
writel(reg, dp->reg_base + EXYNOS_DP_AUX_ADDR_7_0);
@@ -700,17 +700,15 @@ int exynos_dp_read_byte_from_i2c(struct exynos_dp_device *dp,
int i;
int retval;
- for (i = 0; i < 10; i++) {
+ for (i = 0; i < 3; i++) {
/* Clear AUX CH data buffer */
reg = BUF_CLR;
writel(reg, dp->reg_base + EXYNOS_DP_BUFFER_DATA_CTL);
/* Select EDID device */
retval = exynos_dp_select_i2c_device(dp, device_addr, reg_addr);
- if (retval != 0) {
- dev_err(dp->dev, "Select EDID device fail!\n");
+ if (retval != 0)
continue;
- }
/*
* Set I2C transaction and read data
@@ -750,7 +748,7 @@ int exynos_dp_read_bytes_from_i2c(struct exynos_dp_device *dp,
int retval = 0;
for (i = 0; i < count; i += 16) {
- for (j = 0; j < 100; j++) {
+ for (j = 0; j < 3; j++) {
/* Clear AUX CH data buffer */
reg = BUF_CLR;
writel(reg, dp->reg_base + EXYNOS_DP_BUFFER_DATA_CTL);
--
1.7.1
^ permalink raw reply related
* [PATCH v4 3/8] video: exynos_dp: Get pll lock before pattern set
From: Jingoo Han @ 2012-11-09 5:49 UTC (permalink / raw)
To: linux-fbdev
From: Sean Paul <seanpaul@chromium.org>
According to the exynos datasheet (Figure 49-10), we should wait for PLL
lock before programming the training pattern when doing software eDP
link training.
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
drivers/video/exynos/exynos_dp_core.c | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/drivers/video/exynos/exynos_dp_core.c b/drivers/video/exynos/exynos_dp_core.c
index 8c9bcb9..6e54a18 100644
--- a/drivers/video/exynos/exynos_dp_core.c
+++ b/drivers/video/exynos/exynos_dp_core.c
@@ -264,7 +264,7 @@ static void exynos_dp_set_lane_lane_pre_emphasis(struct exynos_dp_device *dp,
static int exynos_dp_link_start(struct exynos_dp_device *dp)
{
u8 buf[4];
- int lane, lane_count, retval;
+ int lane, lane_count, pll_tries, retval;
lane_count = dp->link_train.lane_count;
@@ -297,6 +297,18 @@ static int exynos_dp_link_start(struct exynos_dp_device *dp)
exynos_dp_set_lane_lane_pre_emphasis(dp,
PRE_EMPHASIS_LEVEL_0, lane);
+ /* Wait for PLL lock */
+ pll_tries = 0;
+ while (exynos_dp_get_pll_lock_status(dp) = PLL_UNLOCKED) {
+ if (pll_tries = DP_TIMEOUT_LOOP_COUNT) {
+ dev_err(dp->dev, "Wait for PLL lock timed out\n");
+ return -ETIMEDOUT;
+ }
+
+ pll_tries++;
+ usleep_range(90, 120);
+ }
+
/* Set training pattern 1 */
exynos_dp_set_training_pattern(dp, TRAINING_PTN1);
--
1.7.1
^ permalink raw reply related
* [PATCH v4 2/8] video: exynos_dp: Clean up SW link training
From: Jingoo Han @ 2012-11-09 5:49 UTC (permalink / raw)
To: linux-fbdev
From: Sean Paul <seanpaul@chromium.org>
Clean up some of the SW training code to make it more clear and reduce
duplicate code.
[jg1.han@samsung.com: used exynos_dp_write_bytes_to_dpcd()]
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
drivers/video/exynos/exynos_dp_core.c | 292 +++++++++++++-------------------
1 files changed, 119 insertions(+), 173 deletions(-)
diff --git a/drivers/video/exynos/exynos_dp_core.c b/drivers/video/exynos/exynos_dp_core.c
index 44820f2..8c9bcb9 100644
--- a/drivers/video/exynos/exynos_dp_core.c
+++ b/drivers/video/exynos/exynos_dp_core.c
@@ -276,7 +276,7 @@ static int exynos_dp_link_start(struct exynos_dp_device *dp)
/* Set sink to D0 (Sink Not Ready) mode. */
retval = exynos_dp_write_byte_to_dpcd(dp, DPCD_ADDR_SINK_POWER_STATE,
- DPCD_SET_POWER_STATE_D0);
+ DPCD_SET_POWER_STATE_D0);
if (retval)
return retval;
@@ -301,17 +301,18 @@ static int exynos_dp_link_start(struct exynos_dp_device *dp)
exynos_dp_set_training_pattern(dp, TRAINING_PTN1);
/* Set RX training pattern */
- exynos_dp_write_byte_to_dpcd(dp,
- DPCD_ADDR_TRAINING_PATTERN_SET,
- DPCD_SCRAMBLING_DISABLED |
- DPCD_TRAINING_PATTERN_1);
+ retval = exynos_dp_write_byte_to_dpcd(dp,
+ DPCD_ADDR_TRAINING_PATTERN_SET,
+ DPCD_SCRAMBLING_DISABLED | DPCD_TRAINING_PATTERN_1);
+ if (retval)
+ return retval;
for (lane = 0; lane < lane_count; lane++)
buf[lane] = DPCD_PRE_EMPHASIS_PATTERN2_LEVEL0 |
DPCD_VOLTAGE_SWING_PATTERN1_LEVEL0;
- retval = exynos_dp_write_bytes_to_dpcd(dp,
- DPCD_ADDR_TRAINING_LANE0_SET,
- lane_count, buf);
+
+ retval = exynos_dp_write_bytes_to_dpcd(dp, DPCD_ADDR_TRAINING_LANE0_SET,
+ lane_count, buf);
return retval;
}
@@ -337,18 +338,17 @@ static int exynos_dp_clock_recovery_ok(u8 link_status[2], int lane_count)
return 0;
}
-static int exynos_dp_channel_eq_ok(u8 link_align[3], int lane_count)
+static int exynos_dp_channel_eq_ok(u8 link_status[2], u8 link_align,
+ int lane_count)
{
int lane;
- u8 lane_align;
u8 lane_status;
- lane_align = link_align[2];
- if ((lane_align & DPCD_INTERLANE_ALIGN_DONE) = 0)
+ if ((link_align & DPCD_INTERLANE_ALIGN_DONE) = 0)
return -EINVAL;
for (lane = 0; lane < lane_count; lane++) {
- lane_status = exynos_dp_get_lane_status(link_align, lane);
+ lane_status = exynos_dp_get_lane_status(link_status, lane);
lane_status &= DPCD_CHANNEL_EQ_BITS;
if (lane_status != DPCD_CHANNEL_EQ_BITS)
return -EINVAL;
@@ -432,22 +432,47 @@ static void exynos_dp_reduce_link_rate(struct exynos_dp_device *dp)
dp->link_train.lt_state = FAILED;
}
+static void exynos_dp_get_adjust_training_lane(struct exynos_dp_device *dp,
+ u8 adjust_request[2])
+{
+ int lane, lane_count;
+ u8 voltage_swing, pre_emphasis, training_lane;
+
+ lane_count = dp->link_train.lane_count;
+ for (lane = 0; lane < lane_count; lane++) {
+ voltage_swing = exynos_dp_get_adjust_request_voltage(
+ adjust_request, lane);
+ pre_emphasis = exynos_dp_get_adjust_request_pre_emphasis(
+ adjust_request, lane);
+ training_lane = DPCD_VOLTAGE_SWING_SET(voltage_swing) |
+ DPCD_PRE_EMPHASIS_SET(pre_emphasis);
+
+ if (voltage_swing = VOLTAGE_LEVEL_3)
+ training_lane |= DPCD_MAX_SWING_REACHED;
+ if (pre_emphasis = PRE_EMPHASIS_LEVEL_3)
+ training_lane |= DPCD_MAX_PRE_EMPHASIS_REACHED;
+
+ dp->link_train.training_lane[lane] = training_lane;
+ }
+}
+
static int exynos_dp_process_clock_recovery(struct exynos_dp_device *dp)
{
- u8 link_status[2];
int lane, lane_count, retval;
-
- u8 adjust_request[2];
- u8 voltage_swing;
- u8 pre_emphasis;
- u8 training_lane;
+ u8 voltage_swing, pre_emphasis, training_lane;
+ u8 link_status[2], adjust_request[2];
usleep_range(100, 101);
lane_count = dp->link_train.lane_count;
- retval = exynos_dp_read_bytes_from_dpcd(dp, DPCD_ADDR_LANE0_1_STATUS,
- 2, link_status);
+ retval = exynos_dp_read_bytes_from_dpcd(dp,
+ DPCD_ADDR_LANE0_1_STATUS, 2, link_status);
+ if (retval)
+ return retval;
+
+ retval = exynos_dp_read_bytes_from_dpcd(dp,
+ DPCD_ADDR_ADJUST_REQUEST_LANE0_1, 2, adjust_request);
if (retval)
return retval;
@@ -455,43 +480,10 @@ static int exynos_dp_process_clock_recovery(struct exynos_dp_device *dp)
/* set training pattern 2 for EQ */
exynos_dp_set_training_pattern(dp, TRAINING_PTN2);
- for (lane = 0; lane < lane_count; lane++) {
- retval = exynos_dp_read_bytes_from_dpcd(dp,
- DPCD_ADDR_ADJUST_REQUEST_LANE0_1,
- 2, adjust_request);
- if (retval)
- return retval;
-
- voltage_swing = exynos_dp_get_adjust_request_voltage(
- adjust_request, lane);
- pre_emphasis = exynos_dp_get_adjust_request_pre_emphasis(
- adjust_request, lane);
- training_lane = DPCD_VOLTAGE_SWING_SET(voltage_swing) |
- DPCD_PRE_EMPHASIS_SET(pre_emphasis);
-
- if (voltage_swing = VOLTAGE_LEVEL_3)
- training_lane |= DPCD_MAX_SWING_REACHED;
- if (pre_emphasis = PRE_EMPHASIS_LEVEL_3)
- training_lane |= DPCD_MAX_PRE_EMPHASIS_REACHED;
-
- dp->link_train.training_lane[lane] = training_lane;
-
- exynos_dp_set_lane_link_training(dp,
- dp->link_train.training_lane[lane],
- lane);
- }
-
retval = exynos_dp_write_byte_to_dpcd(dp,
- DPCD_ADDR_TRAINING_PATTERN_SET,
- DPCD_SCRAMBLING_DISABLED |
- DPCD_TRAINING_PATTERN_2);
- if (retval)
- return retval;
-
- retval = exynos_dp_write_bytes_to_dpcd(dp,
- DPCD_ADDR_TRAINING_LANE0_SET,
- lane_count,
- dp->link_train.training_lane);
+ DPCD_ADDR_TRAINING_PATTERN_SET,
+ DPCD_SCRAMBLING_DISABLED |
+ DPCD_TRAINING_PATTERN_2);
if (retval)
return retval;
@@ -501,162 +493,116 @@ static int exynos_dp_process_clock_recovery(struct exynos_dp_device *dp)
for (lane = 0; lane < lane_count; lane++) {
training_lane = exynos_dp_get_lane_link_training(
dp, lane);
- retval = exynos_dp_read_bytes_from_dpcd(dp,
- DPCD_ADDR_ADJUST_REQUEST_LANE0_1,
- 2, adjust_request);
- if (retval)
- return retval;
-
voltage_swing = exynos_dp_get_adjust_request_voltage(
adjust_request, lane);
pre_emphasis = exynos_dp_get_adjust_request_pre_emphasis(
adjust_request, lane);
- if (voltage_swing = VOLTAGE_LEVEL_3 ||
- pre_emphasis = PRE_EMPHASIS_LEVEL_3) {
- dev_err(dp->dev, "voltage or pre emphasis reached max level\n");
- goto reduce_link_rate;
- }
-
- if ((DPCD_VOLTAGE_SWING_GET(training_lane) =
- voltage_swing) &&
- (DPCD_PRE_EMPHASIS_GET(training_lane) =
- pre_emphasis)) {
+ if (DPCD_VOLTAGE_SWING_GET(training_lane) =
+ voltage_swing &&
+ DPCD_PRE_EMPHASIS_GET(training_lane) =
+ pre_emphasis)
dp->link_train.cr_loop[lane]++;
- if (dp->link_train.cr_loop[lane] = MAX_CR_LOOP) {
- dev_err(dp->dev, "CR Max loop\n");
- goto reduce_link_rate;
- }
- }
-
- training_lane = DPCD_VOLTAGE_SWING_SET(voltage_swing) |
- DPCD_PRE_EMPHASIS_SET(pre_emphasis);
- if (voltage_swing = VOLTAGE_LEVEL_3)
- training_lane |= DPCD_MAX_SWING_REACHED;
- if (pre_emphasis = PRE_EMPHASIS_LEVEL_3)
- training_lane |= DPCD_MAX_PRE_EMPHASIS_REACHED;
+ if (dp->link_train.cr_loop[lane] = MAX_CR_LOOP ||
+ voltage_swing = VOLTAGE_LEVEL_3 ||
+ pre_emphasis = PRE_EMPHASIS_LEVEL_3) {
+ dev_err(dp->dev, "CR Max reached (%d,%d,%d)\n",
+ dp->link_train.cr_loop[lane],
+ voltage_swing, pre_emphasis);
+ exynos_dp_reduce_link_rate(dp);
+ return -EIO;
+ }
+ }
+ }
- dp->link_train.training_lane[lane] = training_lane;
+ exynos_dp_get_adjust_training_lane(dp, adjust_request);
- exynos_dp_set_lane_link_training(dp,
- dp->link_train.training_lane[lane], lane);
- }
+ for (lane = 0; lane < lane_count; lane++)
+ exynos_dp_set_lane_link_training(dp,
+ dp->link_train.training_lane[lane], lane);
- retval = exynos_dp_write_bytes_to_dpcd(dp,
- DPCD_ADDR_TRAINING_LANE0_SET, lane_count,
- dp->link_train.training_lane);
- if (retval)
- return retval;
- }
+ retval = exynos_dp_write_bytes_to_dpcd(dp,
+ DPCD_ADDR_TRAINING_LANE0_SET, lane_count,
+ dp->link_train.training_lane);
+ if (retval)
+ return retval;
return retval;
-
-reduce_link_rate:
- exynos_dp_reduce_link_rate(dp);
- return -EIO;
}
static int exynos_dp_process_equalizer_training(struct exynos_dp_device *dp)
{
- u8 link_status[2];
- u8 link_align[3];
int lane, lane_count, retval;
u32 reg;
-
- u8 adjust_request[2];
- u8 voltage_swing;
- u8 pre_emphasis;
- u8 training_lane;
+ u8 link_align, link_status[2], adjust_request[2];
usleep_range(400, 401);
lane_count = dp->link_train.lane_count;
- retval = exynos_dp_read_bytes_from_dpcd(dp, DPCD_ADDR_LANE0_1_STATUS,
- 2, link_status);
+ retval = exynos_dp_read_bytes_from_dpcd(dp,
+ DPCD_ADDR_LANE0_1_STATUS, 2, link_status);
if (retval)
return retval;
- if (exynos_dp_clock_recovery_ok(link_status, lane_count) = 0) {
- link_align[0] = link_status[0];
- link_align[1] = link_status[1];
-
- exynos_dp_read_byte_from_dpcd(dp,
- DPCD_ADDR_LANE_ALIGN_STATUS_UPDATED,
- &link_align[2]);
-
- for (lane = 0; lane < lane_count; lane++) {
- retval = exynos_dp_read_bytes_from_dpcd(dp,
- DPCD_ADDR_ADJUST_REQUEST_LANE0_1,
- 2, adjust_request);
- if (retval)
- return retval;
+ if (exynos_dp_clock_recovery_ok(link_status, lane_count)) {
+ exynos_dp_reduce_link_rate(dp);
+ return -EIO;
+ }
- voltage_swing = exynos_dp_get_adjust_request_voltage(
- adjust_request, lane);
- pre_emphasis = exynos_dp_get_adjust_request_pre_emphasis(
- adjust_request, lane);
- training_lane = DPCD_VOLTAGE_SWING_SET(voltage_swing) |
- DPCD_PRE_EMPHASIS_SET(pre_emphasis);
+ retval = exynos_dp_read_bytes_from_dpcd(dp,
+ DPCD_ADDR_ADJUST_REQUEST_LANE0_1, 2, adjust_request);
+ if (retval)
+ return retval;
- if (voltage_swing = VOLTAGE_LEVEL_3)
- training_lane |= DPCD_MAX_SWING_REACHED;
- if (pre_emphasis = PRE_EMPHASIS_LEVEL_3)
- training_lane |= DPCD_MAX_PRE_EMPHASIS_REACHED;
+ retval = exynos_dp_read_byte_from_dpcd(dp,
+ DPCD_ADDR_LANE_ALIGN_STATUS_UPDATED, &link_align);
+ if (retval)
+ return retval;
- dp->link_train.training_lane[lane] = training_lane;
- }
+ exynos_dp_get_adjust_training_lane(dp, adjust_request);
- if (exynos_dp_channel_eq_ok(link_align, lane_count) = 0) {
- /* traing pattern Set to Normal */
- exynos_dp_training_pattern_dis(dp);
+ if (!exynos_dp_channel_eq_ok(link_status, link_align, lane_count)) {
+ /* traing pattern Set to Normal */
+ exynos_dp_training_pattern_dis(dp);
- dev_info(dp->dev, "Link Training success!\n");
+ dev_info(dp->dev, "Link Training success!\n");
- exynos_dp_get_link_bandwidth(dp, ®);
- dp->link_train.link_rate = reg;
- dev_dbg(dp->dev, "final bandwidth = %.2x\n",
- dp->link_train.link_rate);
+ exynos_dp_get_link_bandwidth(dp, ®);
+ dp->link_train.link_rate = reg;
+ dev_dbg(dp->dev, "final bandwidth = %.2x\n",
+ dp->link_train.link_rate);
- exynos_dp_get_lane_count(dp, ®);
- dp->link_train.lane_count = reg;
- dev_dbg(dp->dev, "final lane count = %.2x\n",
- dp->link_train.lane_count);
+ exynos_dp_get_lane_count(dp, ®);
+ dp->link_train.lane_count = reg;
+ dev_dbg(dp->dev, "final lane count = %.2x\n",
+ dp->link_train.lane_count);
- /* set enhanced mode if available */
- exynos_dp_set_enhanced_mode(dp);
- dp->link_train.lt_state = FINISHED;
- } else {
- /* not all locked */
- dp->link_train.eq_loop++;
+ /* set enhanced mode if available */
+ exynos_dp_set_enhanced_mode(dp);
+ dp->link_train.lt_state = FINISHED;
- if (dp->link_train.eq_loop > MAX_EQ_LOOP) {
- dev_err(dp->dev, "EQ Max loop\n");
- goto reduce_link_rate;
- }
+ return 0;
+ }
- for (lane = 0; lane < lane_count; lane++)
- exynos_dp_set_lane_link_training(dp,
- dp->link_train.training_lane[lane],
- lane);
+ /* not all locked */
+ dp->link_train.eq_loop++;
- retval = exynos_dp_write_bytes_to_dpcd(dp,
- DPCD_ADDR_TRAINING_LANE0_SET,
- lane_count,
- dp->link_train.training_lane);
- if (retval)
- return retval;
- }
- } else {
- goto reduce_link_rate;
+ if (dp->link_train.eq_loop > MAX_EQ_LOOP) {
+ dev_err(dp->dev, "EQ Max loop\n");
+ exynos_dp_reduce_link_rate(dp);
+ return -EIO;
}
- return 0;
+ for (lane = 0; lane < lane_count; lane++)
+ exynos_dp_set_lane_link_training(dp,
+ dp->link_train.training_lane[lane], lane);
-reduce_link_rate:
- exynos_dp_reduce_link_rate(dp);
- return -EIO;
+ retval = exynos_dp_write_bytes_to_dpcd(dp, DPCD_ADDR_TRAINING_LANE0_SET,
+ lane_count, dp->link_train.training_lane);
+
+ return retval;
}
static void exynos_dp_get_max_rx_bandwidth(struct exynos_dp_device *dp,
--
1.7.1
^ permalink raw reply related
* [PATCH v4 1/8] video: exynos_dp: Check DPCD return codes
From: Jingoo Han @ 2012-11-09 5:48 UTC (permalink / raw)
To: linux-fbdev
From: Sean Paul <seanpaul@chromium.org>
Add return code checks to the DPCD transactions in the SW link training
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
drivers/video/exynos/exynos_dp_core.c | 86 +++++++++++++++++++++-----------
1 files changed, 56 insertions(+), 30 deletions(-)
diff --git a/drivers/video/exynos/exynos_dp_core.c b/drivers/video/exynos/exynos_dp_core.c
index d55470e..44820f2 100644
--- a/drivers/video/exynos/exynos_dp_core.c
+++ b/drivers/video/exynos/exynos_dp_core.c
@@ -261,11 +261,10 @@ static void exynos_dp_set_lane_lane_pre_emphasis(struct exynos_dp_device *dp,
}
}
-static void exynos_dp_link_start(struct exynos_dp_device *dp)
+static int exynos_dp_link_start(struct exynos_dp_device *dp)
{
u8 buf[4];
- int lane;
- int lane_count;
+ int lane, lane_count, retval;
lane_count = dp->link_train.lane_count;
@@ -276,8 +275,10 @@ static void exynos_dp_link_start(struct exynos_dp_device *dp)
dp->link_train.cr_loop[lane] = 0;
/* Set sink to D0 (Sink Not Ready) mode. */
- exynos_dp_write_byte_to_dpcd(dp, DPCD_ADDR_SINK_POWER_STATE,
+ retval = exynos_dp_write_byte_to_dpcd(dp, DPCD_ADDR_SINK_POWER_STATE,
DPCD_SET_POWER_STATE_D0);
+ if (retval)
+ return retval;
/* Set link rate and count as you want to establish*/
exynos_dp_set_link_bandwidth(dp, dp->link_train.link_rate);
@@ -286,8 +287,10 @@ static void exynos_dp_link_start(struct exynos_dp_device *dp)
/* Setup RX configuration */
buf[0] = dp->link_train.link_rate;
buf[1] = dp->link_train.lane_count;
- exynos_dp_write_bytes_to_dpcd(dp, DPCD_ADDR_LINK_BW_SET,
+ retval = exynos_dp_write_bytes_to_dpcd(dp, DPCD_ADDR_LINK_BW_SET,
2, buf);
+ if (retval)
+ return retval;
/* Set TX pre-emphasis to minimum */
for (lane = 0; lane < lane_count; lane++)
@@ -306,9 +309,11 @@ static void exynos_dp_link_start(struct exynos_dp_device *dp)
for (lane = 0; lane < lane_count; lane++)
buf[lane] = DPCD_PRE_EMPHASIS_PATTERN2_LEVEL0 |
DPCD_VOLTAGE_SWING_PATTERN1_LEVEL0;
- exynos_dp_write_bytes_to_dpcd(dp,
+ retval = exynos_dp_write_bytes_to_dpcd(dp,
DPCD_ADDR_TRAINING_LANE0_SET,
lane_count, buf);
+
+ return retval;
}
static unsigned char exynos_dp_get_lane_status(u8 link_status[2], int lane)
@@ -430,8 +435,7 @@ static void exynos_dp_reduce_link_rate(struct exynos_dp_device *dp)
static int exynos_dp_process_clock_recovery(struct exynos_dp_device *dp)
{
u8 link_status[2];
- int lane;
- int lane_count;
+ int lane, lane_count, retval;
u8 adjust_request[2];
u8 voltage_swing;
@@ -442,17 +446,22 @@ static int exynos_dp_process_clock_recovery(struct exynos_dp_device *dp)
lane_count = dp->link_train.lane_count;
- exynos_dp_read_bytes_from_dpcd(dp, DPCD_ADDR_LANE0_1_STATUS,
+ retval = exynos_dp_read_bytes_from_dpcd(dp, DPCD_ADDR_LANE0_1_STATUS,
2, link_status);
+ if (retval)
+ return retval;
if (exynos_dp_clock_recovery_ok(link_status, lane_count) = 0) {
/* set training pattern 2 for EQ */
exynos_dp_set_training_pattern(dp, TRAINING_PTN2);
for (lane = 0; lane < lane_count; lane++) {
- exynos_dp_read_bytes_from_dpcd(dp,
+ retval = exynos_dp_read_bytes_from_dpcd(dp,
DPCD_ADDR_ADJUST_REQUEST_LANE0_1,
2, adjust_request);
+ if (retval)
+ return retval;
+
voltage_swing = exynos_dp_get_adjust_request_voltage(
adjust_request, lane);
pre_emphasis = exynos_dp_get_adjust_request_pre_emphasis(
@@ -472,15 +481,19 @@ static int exynos_dp_process_clock_recovery(struct exynos_dp_device *dp)
lane);
}
- exynos_dp_write_byte_to_dpcd(dp,
+ retval = exynos_dp_write_byte_to_dpcd(dp,
DPCD_ADDR_TRAINING_PATTERN_SET,
DPCD_SCRAMBLING_DISABLED |
DPCD_TRAINING_PATTERN_2);
+ if (retval)
+ return retval;
- exynos_dp_write_bytes_to_dpcd(dp,
+ retval = exynos_dp_write_bytes_to_dpcd(dp,
DPCD_ADDR_TRAINING_LANE0_SET,
lane_count,
dp->link_train.training_lane);
+ if (retval)
+ return retval;
dev_info(dp->dev, "Link Training Clock Recovery success\n");
dp->link_train.lt_state = EQUALIZER_TRAINING;
@@ -488,9 +501,12 @@ static int exynos_dp_process_clock_recovery(struct exynos_dp_device *dp)
for (lane = 0; lane < lane_count; lane++) {
training_lane = exynos_dp_get_lane_link_training(
dp, lane);
- exynos_dp_read_bytes_from_dpcd(dp,
+ retval = exynos_dp_read_bytes_from_dpcd(dp,
DPCD_ADDR_ADJUST_REQUEST_LANE0_1,
2, adjust_request);
+ if (retval)
+ return retval;
+
voltage_swing = exynos_dp_get_adjust_request_voltage(
adjust_request, lane);
pre_emphasis = exynos_dp_get_adjust_request_pre_emphasis(
@@ -527,13 +543,14 @@ static int exynos_dp_process_clock_recovery(struct exynos_dp_device *dp)
dp->link_train.training_lane[lane], lane);
}
- exynos_dp_write_bytes_to_dpcd(dp,
- DPCD_ADDR_TRAINING_LANE0_SET,
- lane_count,
- dp->link_train.training_lane);
+ retval = exynos_dp_write_bytes_to_dpcd(dp,
+ DPCD_ADDR_TRAINING_LANE0_SET, lane_count,
+ dp->link_train.training_lane);
+ if (retval)
+ return retval;
}
- return 0;
+ return retval;
reduce_link_rate:
exynos_dp_reduce_link_rate(dp);
@@ -544,8 +561,7 @@ static int exynos_dp_process_equalizer_training(struct exynos_dp_device *dp)
{
u8 link_status[2];
u8 link_align[3];
- int lane;
- int lane_count;
+ int lane, lane_count, retval;
u32 reg;
u8 adjust_request[2];
@@ -557,8 +573,10 @@ static int exynos_dp_process_equalizer_training(struct exynos_dp_device *dp)
lane_count = dp->link_train.lane_count;
- exynos_dp_read_bytes_from_dpcd(dp, DPCD_ADDR_LANE0_1_STATUS,
+ retval = exynos_dp_read_bytes_from_dpcd(dp, DPCD_ADDR_LANE0_1_STATUS,
2, link_status);
+ if (retval)
+ return retval;
if (exynos_dp_clock_recovery_ok(link_status, lane_count) = 0) {
link_align[0] = link_status[0];
@@ -569,9 +587,12 @@ static int exynos_dp_process_equalizer_training(struct exynos_dp_device *dp)
&link_align[2]);
for (lane = 0; lane < lane_count; lane++) {
- exynos_dp_read_bytes_from_dpcd(dp,
+ retval = exynos_dp_read_bytes_from_dpcd(dp,
DPCD_ADDR_ADJUST_REQUEST_LANE0_1,
2, adjust_request);
+ if (retval)
+ return retval;
+
voltage_swing = exynos_dp_get_adjust_request_voltage(
adjust_request, lane);
pre_emphasis = exynos_dp_get_adjust_request_pre_emphasis(
@@ -620,10 +641,12 @@ static int exynos_dp_process_equalizer_training(struct exynos_dp_device *dp)
dp->link_train.training_lane[lane],
lane);
- exynos_dp_write_bytes_to_dpcd(dp,
- DPCD_ADDR_TRAINING_LANE0_SET,
- lane_count,
- dp->link_train.training_lane);
+ retval = exynos_dp_write_bytes_to_dpcd(dp,
+ DPCD_ADDR_TRAINING_LANE0_SET,
+ lane_count,
+ dp->link_train.training_lane);
+ if (retval)
+ return retval;
}
} else {
goto reduce_link_rate;
@@ -701,16 +724,17 @@ static void exynos_dp_init_training(struct exynos_dp_device *dp,
static int exynos_dp_sw_link_training(struct exynos_dp_device *dp)
{
- int retval = 0;
- int training_finished = 0;
+ int retval = 0, training_finished = 0;
dp->link_train.lt_state = START;
/* Process here */
- while (!training_finished) {
+ while (!retval && !training_finished) {
switch (dp->link_train.lt_state) {
case START:
- exynos_dp_link_start(dp);
+ retval = exynos_dp_link_start(dp);
+ if (retval)
+ dev_err(dp->dev, "LT link start failed!\n");
break;
case CLOCK_RECOVERY:
retval = exynos_dp_process_clock_recovery(dp);
@@ -729,6 +753,8 @@ static int exynos_dp_sw_link_training(struct exynos_dp_device *dp)
return -EREMOTEIO;
}
}
+ if (retval)
+ dev_err(dp->dev, "eDP link training failed (%d)\n", retval);
return retval;
}
--
1.7.1
^ permalink raw reply related
* Re: [PATCH] video: exynos_dp: Clean up SW link training
From: Jingoo Han @ 2012-11-09 2:41 UTC (permalink / raw)
To: linux-fbdev
In-Reply-To: <1351702475-31324-1-git-send-email-seanpaul@chromium.org>
On Friday, November 09, 2012 6:03 AM Sean Paul wrote
>
> On Fri, Nov 2, 2012 at 10:45 AM, Sean Paul <seanpaul@chromium.org> wrote:
> > On Thu, Nov 1, 2012 at 8:48 PM, Jingoo Han <jg1.han@samsung.com> wrote:
> >> On Friday, November 02, 2012 1:15 AM Sean Paul wrote
> >>>
> >>> On Thu, Nov 1, 2012 at 1:35 AM, Jingoo Han <jg1.han@samsung.com> wrote:
> >>> > On Thursday, November 01, 2012 1:55 AM Sean Paul wrote
> >>> >>
> >>> >> Clean up some of the SW training code to make it more clear and reduce
> >>> >> duplicate code.
> >>> >>
> >>> >> Signed-off-by: Sean Paul <seanpaul@chromium.org>
> >>> >> ---
> >>> >> drivers/video/exynos/exynos_dp_core.c | 279 +++++++++++++--------------------
> >>> >> 1 files changed, 112 insertions(+), 167 deletions(-)
> >>> >>
> >>> >> Thanks for the pointer. There are still places where the code can be either
> >>> >> simplified, or duplication removed.
> >>> >
> >>> > Removing duplication is good, but don't change the Link training sequence.
> >>> > Link training sequence is very sensitive and tricky.
> >>> >
> >>>
> >>> I definitely appreciate how tricky it is :) I didn't actually change
> >>> any of the functionality from the original code.
> >>
> >> No, you changed the procedure when exynos_dp_clock_recovery_ok() fails.
> >> It is not the same with exynos_dp_get_adjust_training_lane().
> >> So, the else path at exynos_dp_process_clock_recovery() should not be
> >> changed.
> >>
> >>>
> >>> I noticed you made a couple of functional changes in your clean-up
> >>> patch (http://www.spinics.net/lists/linux-fbdev/msg06849.html). I
> >>> assumed that these functional changes were no-ops since bug fixes
> >>> would have gone in separate patches.
> >>>
> >>> I've also done a fair bit of testing to ensure it works.
> >>
> >> Yes, I know.
> >> But, most panels does NOT make the problem,
> >> even though there is a bug.
> >>
> >> With your panel, exynos_dp_clock_recovery_ok() does not fail,
> >> so, the problem does NOT happen.
> >>
> >>>
> >>> > I will modify your patch and I will submit new patch.
> >>> >
> >>>
> >>> More comments below.
> >>>
> >>> > Best regards,
> >>> > Jingoo Han
> >>> >
> >>> >>
> >>> >> Below is a rebased patch for your review.
> >>> >>
> >>> >> Sean
> >>> >>
> >>> >>
> >>> >> diff --git a/drivers/video/exynos/exynos_dp_core.c b/drivers/video/exynos/exynos_dp_core.c
> >>> >> index 44820f2..b126e8a 100644
> >>> >> --- a/drivers/video/exynos/exynos_dp_core.c
> >>> >> +++ b/drivers/video/exynos/exynos_dp_core.c
> >>> >> @@ -276,7 +276,7 @@ static int exynos_dp_link_start(struct exynos_dp_device *dp)
> >>> >>
> >>> >> /* Set sink to D0 (Sink Not Ready) mode. */
> >>> >> retval = exynos_dp_write_byte_to_dpcd(dp, DPCD_ADDR_SINK_POWER_STATE,
> >>> >> - DPCD_SET_POWER_STATE_D0);
> >>> >> + DPCD_SET_POWER_STATE_D0);
> >>> >> if (retval)
> >>> >> return retval;
> >>> >>
> >>> >> @@ -301,17 +301,18 @@ static int exynos_dp_link_start(struct exynos_dp_device *dp)
> >>> >> exynos_dp_set_training_pattern(dp, TRAINING_PTN1);
> >>> >>
> >>> >> /* Set RX training pattern */
> >>> >> - exynos_dp_write_byte_to_dpcd(dp,
> >>> >> - DPCD_ADDR_TRAINING_PATTERN_SET,
> >>> >> - DPCD_SCRAMBLING_DISABLED |
> >>> >> - DPCD_TRAINING_PATTERN_1);
> >>> >> + retval = exynos_dp_write_byte_to_dpcd(dp,
> >>> >> + DPCD_ADDR_TRAINING_PATTERN_SET,
> >>> >> + DPCD_SCRAMBLING_DISABLED | DPCD_TRAINING_PATTERN_1);
> >>> >> + if (retval)
> >>> >> + return retval;
> >>> >>
> >>> >> for (lane = 0; lane < lane_count; lane++)
> >>> >> buf[lane] = DPCD_PRE_EMPHASIS_PATTERN2_LEVEL0 |
> >>> >> DPCD_VOLTAGE_SWING_PATTERN1_LEVEL0;
> >>> >> - retval = exynos_dp_write_bytes_to_dpcd(dp,
> >>> >> - DPCD_ADDR_TRAINING_LANE0_SET,
> >>> >> - lane_count, buf);
> >>> >> +
> >>> >> + retval = exynos_dp_write_bytes_to_dpcd(dp, DPCD_ADDR_TRAINING_LANE0_SET,
> >>> >> + lane_count, buf);
> >>> >>
> >>> >> return retval;
> >>> >> }
> >>> >> @@ -337,18 +338,17 @@ static int exynos_dp_clock_recovery_ok(u8 link_status[2], int lane_count)
> >>> >> return 0;
> >>> >> }
> >>> >>
> >>> >> -static int exynos_dp_channel_eq_ok(u8 link_align[3], int lane_count)
> >>> >> +static int exynos_dp_channel_eq_ok(u8 link_status[2], u8 link_align,
> >>> >> + int lane_count)
> >>> >> {
> >>> >> int lane;
> >>> >> - u8 lane_align;
> >>> >> u8 lane_status;
> >>> >>
> >>> >> - lane_align = link_align[2];
> >>> >> - if ((lane_align & DPCD_INTERLANE_ALIGN_DONE) = 0)
> >>> >> + if ((link_align & DPCD_INTERLANE_ALIGN_DONE) = 0)
> >>> >> return -EINVAL;
> >>> >>
> >>> >> for (lane = 0; lane < lane_count; lane++) {
> >>> >> - lane_status = exynos_dp_get_lane_status(link_align, lane);
> >>> >> + lane_status = exynos_dp_get_lane_status(link_status, lane);
> >>> >> lane_status &= DPCD_CHANNEL_EQ_BITS;
> >>> >> if (lane_status != DPCD_CHANNEL_EQ_BITS)
> >>> >> return -EINVAL;
> >>> >> @@ -432,22 +432,47 @@ static void exynos_dp_reduce_link_rate(struct exynos_dp_device *dp)
> >>> >> dp->link_train.lt_state = FAILED;
> >>> >> }
> >>> >>
> >>> >> +static void exynos_dp_get_adjust_training_lane(struct exynos_dp_device *dp,
> >>> >> + u8 adjust_request[2])
> >>> >> +{
> >>> >> + int lane, lane_count;
> >>> >> + u8 voltage_swing, pre_emphasis, training_lane;
> >>> >> +
> >>> >> + lane_count = dp->link_train.lane_count;
> >>> >> + for (lane = 0; lane < lane_count; lane++) {
> >>> >> + voltage_swing = exynos_dp_get_adjust_request_voltage(
> >>> >> + adjust_request, lane);
> >>> >> + pre_emphasis = exynos_dp_get_adjust_request_pre_emphasis(
> >>> >> + adjust_request, lane);
> >>> >> + training_lane = DPCD_VOLTAGE_SWING_SET(voltage_swing) |
> >>> >> + DPCD_PRE_EMPHASIS_SET(pre_emphasis);
> >>> >> +
> >>> >> + if (voltage_swing = VOLTAGE_LEVEL_3)
> >>> >> + training_lane |= DPCD_MAX_SWING_REACHED;
> >>> >> + if (pre_emphasis = PRE_EMPHASIS_LEVEL_3)
> >>> >> + training_lane |= DPCD_MAX_PRE_EMPHASIS_REACHED;
> >>> >> +
> >>> >> + dp->link_train.training_lane[lane] = training_lane;
> >>> >> + }
> >>> >> +}
> >>> >> +
> >>> >> static int exynos_dp_process_clock_recovery(struct exynos_dp_device *dp)
> >>> >> {
> >>> >> - u8 link_status[2];
> >>> >> int lane, lane_count, retval;
> >>> >> -
> >>> >> - u8 adjust_request[2];
> >>> >> - u8 voltage_swing;
> >>> >> - u8 pre_emphasis;
> >>> >> - u8 training_lane;
> >>> >> + u8 voltage_swing, pre_emphasis, training_lane;
> >>> >> + u8 link_status[2], adjust_request[2];
> >>> >>
> >>> >> usleep_range(100, 101);
> >>> >>
> >>> >> lane_count = dp->link_train.lane_count;
> >>> >>
> >>> >> retval = exynos_dp_read_bytes_from_dpcd(dp, DPCD_ADDR_LANE0_1_STATUS,
> >>> >> - 2, link_status);
> >>> >> + 2, link_status);
> >>> >> + if (retval)
> >>> >> + return retval;
> >>> >> +
> >>> >> + retval = exynos_dp_read_bytes_from_dpcd(dp,
> >>> >> + DPCD_ADDR_ADJUST_REQUEST_LANE0_1, 2, adjust_request);
> >>> >> if (retval)
> >>> >> return retval;
> >>> >>
> >>> >> @@ -455,43 +480,9 @@ static int exynos_dp_process_clock_recovery(struct exynos_dp_device *dp)
> >>> >> /* set training pattern 2 for EQ */
> >>> >> exynos_dp_set_training_pattern(dp, TRAINING_PTN2);
> >>> >>
> >>> >> - for (lane = 0; lane < lane_count; lane++) {
> >>> >> - retval = exynos_dp_read_bytes_from_dpcd(dp,
> >>> >> - DPCD_ADDR_ADJUST_REQUEST_LANE0_1,
> >>> >> - 2, adjust_request);
> >>> >> - if (retval)
> >>> >> - return retval;
> >>> >> -
> >>> >> - voltage_swing = exynos_dp_get_adjust_request_voltage(
> >>> >> - adjust_request, lane);
> >>> >> - pre_emphasis = exynos_dp_get_adjust_request_pre_emphasis(
> >>> >> - adjust_request, lane);
> >>> >> - training_lane = DPCD_VOLTAGE_SWING_SET(voltage_swing) |
> >>> >> - DPCD_PRE_EMPHASIS_SET(pre_emphasis);
> >>> >> -
> >>> >> - if (voltage_swing = VOLTAGE_LEVEL_3)
> >>> >> - training_lane |= DPCD_MAX_SWING_REACHED;
> >>> >> - if (pre_emphasis = PRE_EMPHASIS_LEVEL_3)
> >>> >> - training_lane |= DPCD_MAX_PRE_EMPHASIS_REACHED;
> >>> >> -
> >>> >> - dp->link_train.training_lane[lane] = training_lane;
> >>> >> -
> >>> >> - exynos_dp_set_lane_link_training(dp,
> >>> >> - dp->link_train.training_lane[lane],
> >>> >> - lane);
> >>> >> - }
> >>> >> -
> >>> >
> >>> > Please don't move it to back.
> >>> >
> >>>
> >>> I assume you're talking about the adjust_request read here? I noticed
> >>> this was changed in your original clean-up patch
> >>> (http://www.spinics.net/lists/linux-fbdev/msg06849.html), but assumed
> >>> it was a no-op. What bug does it fix? According to the flowcharts in
> >>> the exynos5250 datasheet (figure 49-10 & 49-11), this should be done
> >>> *before* setting training pattern 2. Your alteration to my patch will
> >>> read it after.
> >>>
> >>> I also noticed that you added back exynos_dp_get_adjust_training_lane
> >>> call here, along with setting DPCD_ADDR_TRAINING_LANE0_SET. You'll
> >>> notice that this same code is run in the else path of this function.
> >>
> >> No, it is not same.
> >>
> >> 1) your patch
> >> exynos_dp_read_bytes_from_dpcd(dp,
> >> DPCD_ADDR_ADJUST_REQUEST_LANE0_1, 2, adjust_request);
> >> if (exynos_dp_clock_recovery_ok(link_status, lane_count) = 0) {
> >> ...
> >> } else {
> >> for (lane = 0; lane < lane_count; lane++) {
> >> training_lane = exynos_dp_get_lane_link_training()
> >> voltage_swing = exynos_dp_get_adjust_request_voltage()
> >> pre_emphasis = exynos_dp_get_adjust_request_pre_emphasis()
> >> ...
> >>
> >> 2) my patch
> >> if (exynos_dp_clock_recovery_ok(link_status, lane_count) = 0) {
> >> ...
> >> } else {
> >> for (lane = 0; lane < lane_count; lane++) {
> >> training_lane = exynos_dp_get_lane_link_training()
> >> exynos_dp_read_bytes_from_dpcd(dp,
> >> DPCD_ADDR_ADJUST_REQUEST_LANE0_1, 2, adjust_request);
> >> voltage_swing = exynos_dp_get_adjust_request_voltage()
> >> pre_emphasis = exynos_dp_get_adjust_request_pre_emphasis()
> >> ...
> >>
> >>
> >> When the place of reading DPCD_ADDR_ADJUST_REQUEST_LANE0_1 is changed,
> >> it makes the Link Fail problem when exynos_dp_clock_recovery_ok() fails.
> >> In the case of most panels, exynos_dp_clock_recovery_ok() does not fail.
> >> But, some panels failed at exynos_dp_clock_recovery_ok(), and makes the problem
> >> if your patch is used.
> >>
> >
> > I must be missing something. exynos_dp_clock_recovery_ok just
> > interprets link_status, which is read in the same place in both
> > patches. exynos_dp_get_lane_link_training reads from an exynos
> > register. I fail to see how either of those operations could affect
> > the adjust_request DPCD read.
> >
> > The following is the order of operations for
> > exynos_dp_clock_recovery_ok failure with my patch:
> >
> > (1) Read lane_status from DPCD
> > (2) Read adjust_request from DPCD
> > (3) clock_recovery_ok fails
> > (4) Get training_lane 0, parse voltage_swing 0 from adjust_request,
> > parse pre_emphasis 0 from adjust_request
> > (5) Check voltage_swing and pre_emphasis against training_lane,
> > increment loop count if nothing changed, exit earlyif max met
> > (6) Repeat (4),(5) for lane 1, 2, 3
> > (7) Change the value of training_lane to match adjust request read in step (2)
> > (8) Write training_ctl to exynos DP register (all lanes)
> > (9) Write training_lane back out to DPCD (all lanes)
> >
> > With your patch (http://www.spinics.net/lists/linux-fbdev/msg08548.html):
> >
> > (1) Read lane_status from DPCD
> > (2) clock_recovery_ok fails
> > (3) Get training_lane 0
> > (4) Read adjust_request from DPCD
> > (5) Parse voltage_swing 0 from adjust_request, parse pre_emphasis 0
> > from adjust_request
> > (6) Exit early if max met, check voltage_swing and pre_emphasis
> > against training_lane, increment loop count if nothing changed
> > (7) Change the value of training_lane to match adjust request read in step (4)
> > (8) Write training_ctl to exynos DP register for lane 0
> > (9) Repeat (3), (4), (5), (6), (7), (8) for lane 1, 2, 3
> > (9) Write training_lane back out to DPCD (all lanes)
> >
> > So unless reading the training lane from DPCD or
> > exynos_dp_set_lane_link_training (which writes an exynos register)
> > changes the value of the adjust_request read from DPCD, our patches
> > are the same :)
> >
> >> Also, your patch calls exynos_dp_get_adjust_request_voltage() and
> >> exynos_dp_get_adjust_request_pre_emphasis() twice,
> >> when exynos_dp_clock_recovery_ok() fails. Previously, exynos_dp_clock_recovery_ok()
> >> and exynos_dp_get_adjust_request_pre_emphasis() are called only onetime
> >> when exynos_dp_clock_recovery_ok() fails.
> >> There is no need to call exynos_dp_get_adjust_request_voltage() and
> >> exynos_dp_get_adjust_request_pre_emphasis() 'TWICE'.
> >>
> >
> > Yes, it does, but it's just a shift and bitwise-AND... not really
> > heavy weight. It would be nice to refactor that code a bit to remove
> > the nasty, but that's a different patch.
> >
> >
> >>
> >> Anyway, your patch is good and readability is improved.
> >> So, I went the extra mile to accept your original patch and
> >> add it to v3 patch that I sent.
> >> (http://www.spinics.net/lists/linux-fbdev/msg08548.html)
> >>
> >> But, it is necessary to be careful with some error paths,
> >> that is not used at most eDP panels.
> >>
> >
> > I'm still not convinced, but I think we're converging :)
> >
>
> Ping.
>
OK, I will accept your original patch.
Your original patch seems to be follow the Link Training procedure
of DP standard, more.
But, I will change exynos_dp_write_byte_to_dpcd() x 4 times
to exynos_dp_write_bytes_to_dpcd(), as I mentioned.
I will post v4 patches.
Thank you.
Best regards,
Jingoo Han
>
> > Cheers,
> >
> > Sean
> >
> >
> >
> >> Best regards,
> >> Jingoo Han
> >>
> >>> Hence, I removed the duplication and put it all at the bottom. This
> >>> improves readability, matches the flowchart more closely, and removes
> >>> duplication.
> >>>
> >>> I'd urge you to please read my patch more carefully and ask questions
> >>> if you have any.
> >>>
> >>> Thanks!
> >>>
> >>> Sean
> >>>
> >>> >> retval = exynos_dp_write_byte_to_dpcd(dp,
> >>> >> DPCD_ADDR_TRAINING_PATTERN_SET,
> >>> >> - DPCD_SCRAMBLING_DISABLED |
> >>> >> - DPCD_TRAINING_PATTERN_2);
> >>> >> - if (retval)
> >>> >> - return retval;
> >>> >> -
> >>> >> - retval = exynos_dp_write_bytes_to_dpcd(dp,
> >>> >> - DPCD_ADDR_TRAINING_LANE0_SET,
> >>> >> - lane_count,
> >>> >> - dp->link_train.training_lane);
> >>> >> + DPCD_SCRAMBLING_DISABLED | DPCD_TRAINING_PATTERN_2);
> >>> >> if (retval)
> >>> >> return retval;
> >>> >>
> >>> >> @@ -501,73 +492,49 @@ static int exynos_dp_process_clock_recovery(struct exynos_dp_device *dp)
> >>> >> for (lane = 0; lane < lane_count; lane++) {
> >>> >> training_lane = exynos_dp_get_lane_link_training(
> >>> >> dp, lane);
> >>> >> - retval = exynos_dp_read_bytes_from_dpcd(dp,
> >>> >> - DPCD_ADDR_ADJUST_REQUEST_LANE0_1,
> >>> >> - 2, adjust_request);
> >>> >> - if (retval)
> >>> >> - return retval;
> >>> >> -
> >>> >> voltage_swing = exynos_dp_get_adjust_request_voltage(
> >>> >> adjust_request, lane);
> >>> >> pre_emphasis = exynos_dp_get_adjust_request_pre_emphasis(
> >>> >> adjust_request, lane);
> >>> >>
> >>> >> - if (voltage_swing = VOLTAGE_LEVEL_3 ||
> >>> >> - pre_emphasis = PRE_EMPHASIS_LEVEL_3) {
> >>> >> - dev_err(dp->dev, "voltage or pre emphasis reached max level\n");
> >>> >> - goto reduce_link_rate;
> >>> >> - }
> >>> >> -
> >>> >> - if ((DPCD_VOLTAGE_SWING_GET(training_lane) =
> >>> >> - voltage_swing) &&
> >>> >> - (DPCD_PRE_EMPHASIS_GET(training_lane) =
> >>> >> - pre_emphasis)) {
> >>> >> + if (DPCD_VOLTAGE_SWING_GET(training_lane) =
> >>> >> + voltage_swing &&
> >>> >> + DPCD_PRE_EMPHASIS_GET(training_lane) =
> >>> >> + pre_emphasis)
> >>> >> dp->link_train.cr_loop[lane]++;
> >>> >> - if (dp->link_train.cr_loop[lane] = MAX_CR_LOOP) {
> >>> >> - dev_err(dp->dev, "CR Max loop\n");
> >>> >> - goto reduce_link_rate;
> >>> >> - }
> >>> >> - }
> >>> >>
> >>> >> - training_lane = DPCD_VOLTAGE_SWING_SET(voltage_swing) |
> >>> >> - DPCD_PRE_EMPHASIS_SET(pre_emphasis);
> >>> >> -
> >>> >> - if (voltage_swing = VOLTAGE_LEVEL_3)
> >>> >> - training_lane |= DPCD_MAX_SWING_REACHED;
> >>> >> - if (pre_emphasis = PRE_EMPHASIS_LEVEL_3)
> >>> >> - training_lane |= DPCD_MAX_PRE_EMPHASIS_REACHED;
> >>> >> -
> >>> >> - dp->link_train.training_lane[lane] = training_lane;
> >>> >> -
> >>> >> - exynos_dp_set_lane_link_training(dp,
> >>> >> - dp->link_train.training_lane[lane], lane);
> >>> >> + if (dp->link_train.cr_loop[lane] = MAX_CR_LOOP ||
> >>> >> + voltage_swing = VOLTAGE_LEVEL_3 ||
> >>> >> + pre_emphasis = PRE_EMPHASIS_LEVEL_3) {
> >>> >> + dev_err(dp->dev, "CR Max reached (%d,%d,%d)\n",
> >>> >> + dp->link_train.cr_loop[lane],
> >>> >> + voltage_swing, pre_emphasis);
> >>> >> + exynos_dp_reduce_link_rate(dp);
> >>> >> + return -EIO;
> >>> >> + }
> >>> >> }
> >>> >> + }
> >>> >> +
> >>> >> + exynos_dp_get_adjust_training_lane(dp, adjust_request);
> >>> >>
> >>> >> - retval = exynos_dp_write_bytes_to_dpcd(dp,
> >>> >> - DPCD_ADDR_TRAINING_LANE0_SET, lane_count,
> >>> >> - dp->link_train.training_lane);
> >>> >> + for (lane = 0; lane < lane_count; lane++) {
> >>> >> + exynos_dp_set_lane_link_training(dp,
> >>> >> + dp->link_train.training_lane[lane], lane);
> >>> >> + retval = exynos_dp_write_byte_to_dpcd(dp,
> >>> >> + DPCD_ADDR_TRAINING_LANE0_SET + lane,
> >>> >> + dp->link_train.training_lane[lane]);
> >>> >
> >>> > The following would be better.
> >>> > byte's'_to_dpcd is faster than byte_to_dpcd x 4 times.
> >>> >
> >>> > for (lane = 0; lane < lane_count; lane++) {
> >>> > exynos_dp_set_lane_link_training(dp,
> >>> > dp->link_train.training_lane[lane], lane);
> >>> > }
> >>> >
> >>> > retval = exynos_dp_write_bytes_to_dpcd(dp,
> >>> > DPCD_ADDR_TRAINING_LANE0_SET, lane_count,
> >>> > dp->link_train.training_lane);
> >>> >
> >>>
> >>>
> >>> Makes sense, that's a good change.
> >>>
> >>>
> >>> >> if (retval)
> >>> >> return retval;
> >>> >> }
> >>> >>
> >>> >> return retval;
> >>> >> -
> >>> >> -reduce_link_rate:
> >>> >> - exynos_dp_reduce_link_rate(dp);
> >>> >> - return -EIO;
> >>> >> }
> >>> >>
> >>> >> static int exynos_dp_process_equalizer_training(struct exynos_dp_device *dp)
> >>> >> {
> >>> >> - u8 link_status[2];
> >>> >> - u8 link_align[3];
> >>> >> int lane, lane_count, retval;
> >>> >> u32 reg;
> >>> >> -
> >>> >> - u8 adjust_request[2];
> >>> >> - u8 voltage_swing;
> >>> >> - u8 pre_emphasis;
> >>> >> - u8 training_lane;
> >>> >> + u8 link_align, link_status[2], adjust_request[2];
> >>> >>
> >>> >> usleep_range(400, 401);
> >>> >>
> >>> >> @@ -578,85 +545,63 @@ static int exynos_dp_process_equalizer_training(struct exynos_dp_device *dp)
> >>> >> if (retval)
> >>> >> return retval;
> >>> >>
> >>> >> - if (exynos_dp_clock_recovery_ok(link_status, lane_count) = 0) {
> >>> >> - link_align[0] = link_status[0];
> >>> >> - link_align[1] = link_status[1];
> >>> >> -
> >>> >> - exynos_dp_read_byte_from_dpcd(dp,
> >>> >> - DPCD_ADDR_LANE_ALIGN_STATUS_UPDATED,
> >>> >> - &link_align[2]);
> >>> >> -
> >>> >> - for (lane = 0; lane < lane_count; lane++) {
> >>> >> - retval = exynos_dp_read_bytes_from_dpcd(dp,
> >>> >> - DPCD_ADDR_ADJUST_REQUEST_LANE0_1,
> >>> >> - 2, adjust_request);
> >>> >> - if (retval)
> >>> >> - return retval;
> >>> >> + if (exynos_dp_clock_recovery_ok(link_status, lane_count)) {
> >>> >> + exynos_dp_reduce_link_rate(dp);
> >>> >> + return -EIO;
> >>> >> + }
> >>> >>
> >>> >> - voltage_swing = exynos_dp_get_adjust_request_voltage(
> >>> >> - adjust_request, lane);
> >>> >> - pre_emphasis = exynos_dp_get_adjust_request_pre_emphasis(
> >>> >> - adjust_request, lane);
> >>> >> - training_lane = DPCD_VOLTAGE_SWING_SET(voltage_swing) |
> >>> >> - DPCD_PRE_EMPHASIS_SET(pre_emphasis);
> >>> >> + retval = exynos_dp_read_bytes_from_dpcd(dp,
> >>> >> + DPCD_ADDR_ADJUST_REQUEST_LANE0_1, 2, adjust_request);
> >>> >> + if (retval)
> >>> >> + return retval;
> >>> >>
> >>> >> - if (voltage_swing = VOLTAGE_LEVEL_3)
> >>> >> - training_lane |= DPCD_MAX_SWING_REACHED;
> >>> >> - if (pre_emphasis = PRE_EMPHASIS_LEVEL_3)
> >>> >> - training_lane |= DPCD_MAX_PRE_EMPHASIS_REACHED;
> >>> >> + retval = exynos_dp_read_byte_from_dpcd(dp,
> >>> >> + DPCD_ADDR_LANE_ALIGN_STATUS_UPDATED, &link_align);
> >>> >> + if (retval)
> >>> >> + return retval;
> >>> >>
> >>> >> - dp->link_train.training_lane[lane] = training_lane;
> >>> >> - }
> >>> >> + exynos_dp_get_adjust_training_lane(dp, adjust_request);
> >>> >>
> >>> >> - if (exynos_dp_channel_eq_ok(link_align, lane_count) = 0) {
> >>> >> - /* traing pattern Set to Normal */
> >>> >> - exynos_dp_training_pattern_dis(dp);
> >>> >> + if (!exynos_dp_channel_eq_ok(link_status, link_align, lane_count)) {
> >>> >> + /* traing pattern Set to Normal */
> >>> >> + exynos_dp_training_pattern_dis(dp);
> >>> >>
> >>> >> - dev_info(dp->dev, "Link Training success!\n");
> >>> >> + dev_info(dp->dev, "Link Training success!\n");
> >>> >>
> >>> >> - exynos_dp_get_link_bandwidth(dp, ®);
> >>> >> - dp->link_train.link_rate = reg;
> >>> >> - dev_dbg(dp->dev, "final bandwidth = %.2x\n",
> >>> >> - dp->link_train.link_rate);
> >>> >> + exynos_dp_get_link_bandwidth(dp, ®);
> >>> >> + dp->link_train.link_rate = reg;
> >>> >> + dev_dbg(dp->dev, "final bandwidth = %.2x\n",
> >>> >> + dp->link_train.link_rate);
> >>> >>
> >>> >> - exynos_dp_get_lane_count(dp, ®);
> >>> >> - dp->link_train.lane_count = reg;
> >>> >> - dev_dbg(dp->dev, "final lane count = %.2x\n",
> >>> >> - dp->link_train.lane_count);
> >>> >> + exynos_dp_get_lane_count(dp, ®);
> >>> >> + dp->link_train.lane_count = reg;
> >>> >> + dev_dbg(dp->dev, "final lane count = %.2x\n",
> >>> >> + dp->link_train.lane_count);
> >>> >>
> >>> >> - /* set enhanced mode if available */
> >>> >> - exynos_dp_set_enhanced_mode(dp);
> >>> >> - dp->link_train.lt_state = FINISHED;
> >>> >> - } else {
> >>> >> - /* not all locked */
> >>> >> - dp->link_train.eq_loop++;
> >>> >> + /* set enhanced mode if available */
> >>> >> + exynos_dp_set_enhanced_mode(dp);
> >>> >> + dp->link_train.lt_state = FINISHED;
> >>> >>
> >>> >> - if (dp->link_train.eq_loop > MAX_EQ_LOOP) {
> >>> >> - dev_err(dp->dev, "EQ Max loop\n");
> >>> >> - goto reduce_link_rate;
> >>> >> - }
> >>> >> + return 0;
> >>> >> + }
> >>> >>
> >>> >> - for (lane = 0; lane < lane_count; lane++)
> >>> >> - exynos_dp_set_lane_link_training(dp,
> >>> >> - dp->link_train.training_lane[lane],
> >>> >> - lane);
> >>> >> + /* not all locked */
> >>> >> + dp->link_train.eq_loop++;
> >>> >>
> >>> >> - retval = exynos_dp_write_bytes_to_dpcd(dp,
> >>> >> - DPCD_ADDR_TRAINING_LANE0_SET,
> >>> >> - lane_count,
> >>> >> - dp->link_train.training_lane);
> >>> >> - if (retval)
> >>> >> - return retval;
> >>> >> - }
> >>> >> - } else {
> >>> >> - goto reduce_link_rate;
> >>> >> + if (dp->link_train.eq_loop > MAX_EQ_LOOP) {
> >>> >> + dev_err(dp->dev, "EQ Max loop\n");
> >>> >> + exynos_dp_reduce_link_rate(dp);
> >>> >> + return -EIO;
> >>> >> }
> >>> >>
> >>> >> - return 0;
> >>> >> + for (lane = 0; lane < lane_count; lane++)
> >>> >> + exynos_dp_set_lane_link_training(dp,
> >>> >> + dp->link_train.training_lane[lane], lane);
> >>> >>
> >>> >> -reduce_link_rate:
> >>> >> - exynos_dp_reduce_link_rate(dp);
> >>> >> - return -EIO;
> >>> >> + retval = exynos_dp_write_bytes_to_dpcd(dp, DPCD_ADDR_TRAINING_LANE0_SET,
> >>> >> + lane_count, dp->link_train.training_lane);
> >>> >> +
> >>> >> + return retval;
> >>> >> }
> >>> >>
> >>> >> static void exynos_dp_get_max_rx_bandwidth(struct exynos_dp_device *dp,
> >>> >> --
> >>> >> 1.7.7.3
> >>> >
> >>
^ permalink raw reply
* Re: [PATCH v7 0/8] of: add display helper
From: Rob Herring @ 2012-11-08 21:35 UTC (permalink / raw)
To: Steffen Trumtrar
Cc: devicetree-discuss, linux-fbdev, dri-devel, Laurent Pinchart,
Thierry Reding, Guennady Liakhovetski, linux-media,
Tomi Valkeinen, Stephen Warren, kernel
In-Reply-To: <1351675689-26814-1-git-send-email-s.trumtrar@pengutronix.de>
On 10/31/2012 04:28 AM, Steffen Trumtrar wrote:
> Hi!
>
> Finally, v7 of the series.
>
> Changes since v6:
> - get rid of some empty lines etc.
> - move functions to their subsystems
> - split of_ from non-of_ functions
> - add at least some kerneldoc to some functions
>
> Regards,
> Steffen
>
>
> Steffen Trumtrar (8):
> video: add display_timing struct and helpers
> of: add helper to parse display timings
> of: add generic videomode description
> video: add videomode helpers
> fbmon: add videomode helpers
> fbmon: add of_videomode helpers
> drm_modes: add videomode helpers
> drm_modes: add of_videomode helpers
>
> .../devicetree/bindings/video/display-timings.txt | 139 +++++++++++++++
> drivers/gpu/drm/drm_modes.c | 78 +++++++++
> drivers/of/Kconfig | 12 ++
> drivers/of/Makefile | 2 +
> drivers/of/of_display_timings.c | 185 ++++++++++++++++++++
> drivers/of/of_videomode.c | 47 +++++
Not sure why you moved this, but please move this back to drivers/video.
We're trying to move subsystem specific pieces out of drivers/of.
Rob
> drivers/video/Kconfig | 11 ++
> drivers/video/Makefile | 2 +
> drivers/video/display_timing.c | 24 +++
> drivers/video/fbmon.c | 76 ++++++++
> drivers/video/videomode.c | 44 +++++
> include/drm/drmP.h | 8 +
> include/linux/display_timing.h | 69 ++++++++
> include/linux/fb.h | 5 +
> include/linux/of_display_timings.h | 20 +++
> include/linux/of_videomode.h | 15 ++
> include/linux/videomode.h | 36 ++++
> 17 files changed, 773 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/video/display-timings.txt
> create mode 100644 drivers/of/of_display_timings.c
> create mode 100644 drivers/of/of_videomode.c
> create mode 100644 drivers/video/display_timing.c
> create mode 100644 drivers/video/videomode.c
> create mode 100644 include/linux/display_timing.h
> create mode 100644 include/linux/of_display_timings.h
> create mode 100644 include/linux/of_videomode.h
> create mode 100644 include/linux/videomode.h
>
^ permalink raw reply
* Re: [PATCH v7 5/8] fbmon: add videomode helpers
From: Steffen Trumtrar @ 2012-11-08 21:25 UTC (permalink / raw)
To: Manjunathappa, Prakash
Cc: devicetree-discuss@lists.ozlabs.org, Rob Herring,
linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org,
Laurent Pinchart, Thierry Reding, Guennady Liakhovetski,
linux-media@vger.kernel.org, Valkeinen, Tomi, Stephen Warren,
kernel@pengutronix.de
In-Reply-To: <A73F36158E33644199EB82C5EC81C7BC3E9E1B39@DBDE01.ent.ti.com>
Hi!
On Wed, Oct 31, 2012 at 03:30:03PM +0000, Manjunathappa, Prakash wrote:
> Hi Steffen,
>
> On Wed, Oct 31, 2012 at 14:58:05, Steffen Trumtrar wrote:
> > +#if IS_ENABLED(CONFIG_VIDEOMODE)
> > +int videomode_to_fb_videomode(struct videomode *vm, struct fb_videomode *fbmode)
> > +{
> > + fbmode->xres = vm->hactive;
> > + fbmode->left_margin = vm->hback_porch;
> > + fbmode->right_margin = vm->hfront_porch;
> > + fbmode->hsync_len = vm->hsync_len;
> > +
> > + fbmode->yres = vm->vactive;
> > + fbmode->upper_margin = vm->vback_porch;
> > + fbmode->lower_margin = vm->vfront_porch;
> > + fbmode->vsync_len = vm->vsync_len;
> > +
> > + fbmode->pixclock = KHZ2PICOS(vm->pixelclock / 1000);
> > +
> > + fbmode->sync = 0;
> > + fbmode->vmode = 0;
> > + if (vm->hah)
> > + fbmode->sync |= FB_SYNC_HOR_HIGH_ACT;
> > + if (vm->vah)
> > + fbmode->sync |= FB_SYNC_VERT_HIGH_ACT;
> > + if (vm->interlaced)
> > + fbmode->vmode |= FB_VMODE_INTERLACED;
> > + if (vm->doublescan)
> > + fbmode->vmode |= FB_VMODE_DOUBLE;
> > +
>
> "pixelclk-inverted" property of the panel is not percolated fb_videomode.
> Please let me know if I am missing something.
>
The next version is almost finished. Only thing I'm missing is this.
And I actually do not know which flag would represent an inverted pixelclock
in fb_videomode. Does anybody have any idea what I have to do here?
if (vm->pixelclk_pol)
fbmode->sync = ???
That's as far as I have come and I don't see a flag that seems right.
Is this even a valid property of fb_videomode?
Regards,
Steffen
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply
* Re: [PATCH] video: exynos_dp: Clean up SW link training
From: Sean Paul @ 2012-11-08 21:02 UTC (permalink / raw)
To: linux-fbdev
In-Reply-To: <1351702475-31324-1-git-send-email-seanpaul@chromium.org>
On Fri, Nov 2, 2012 at 10:45 AM, Sean Paul <seanpaul@chromium.org> wrote:
> On Thu, Nov 1, 2012 at 8:48 PM, Jingoo Han <jg1.han@samsung.com> wrote:
>> On Friday, November 02, 2012 1:15 AM Sean Paul wrote
>>>
>>> On Thu, Nov 1, 2012 at 1:35 AM, Jingoo Han <jg1.han@samsung.com> wrote:
>>> > On Thursday, November 01, 2012 1:55 AM Sean Paul wrote
>>> >>
>>> >> Clean up some of the SW training code to make it more clear and reduce
>>> >> duplicate code.
>>> >>
>>> >> Signed-off-by: Sean Paul <seanpaul@chromium.org>
>>> >> ---
>>> >> drivers/video/exynos/exynos_dp_core.c | 279 +++++++++++++--------------------
>>> >> 1 files changed, 112 insertions(+), 167 deletions(-)
>>> >>
>>> >> Thanks for the pointer. There are still places where the code can be either
>>> >> simplified, or duplication removed.
>>> >
>>> > Removing duplication is good, but don't change the Link training sequence.
>>> > Link training sequence is very sensitive and tricky.
>>> >
>>>
>>> I definitely appreciate how tricky it is :) I didn't actually change
>>> any of the functionality from the original code.
>>
>> No, you changed the procedure when exynos_dp_clock_recovery_ok() fails.
>> It is not the same with exynos_dp_get_adjust_training_lane().
>> So, the else path at exynos_dp_process_clock_recovery() should not be
>> changed.
>>
>>>
>>> I noticed you made a couple of functional changes in your clean-up
>>> patch (http://www.spinics.net/lists/linux-fbdev/msg06849.html). I
>>> assumed that these functional changes were no-ops since bug fixes
>>> would have gone in separate patches.
>>>
>>> I've also done a fair bit of testing to ensure it works.
>>
>> Yes, I know.
>> But, most panels does NOT make the problem,
>> even though there is a bug.
>>
>> With your panel, exynos_dp_clock_recovery_ok() does not fail,
>> so, the problem does NOT happen.
>>
>>>
>>> > I will modify your patch and I will submit new patch.
>>> >
>>>
>>> More comments below.
>>>
>>> > Best regards,
>>> > Jingoo Han
>>> >
>>> >>
>>> >> Below is a rebased patch for your review.
>>> >>
>>> >> Sean
>>> >>
>>> >>
>>> >> diff --git a/drivers/video/exynos/exynos_dp_core.c b/drivers/video/exynos/exynos_dp_core.c
>>> >> index 44820f2..b126e8a 100644
>>> >> --- a/drivers/video/exynos/exynos_dp_core.c
>>> >> +++ b/drivers/video/exynos/exynos_dp_core.c
>>> >> @@ -276,7 +276,7 @@ static int exynos_dp_link_start(struct exynos_dp_device *dp)
>>> >>
>>> >> /* Set sink to D0 (Sink Not Ready) mode. */
>>> >> retval = exynos_dp_write_byte_to_dpcd(dp, DPCD_ADDR_SINK_POWER_STATE,
>>> >> - DPCD_SET_POWER_STATE_D0);
>>> >> + DPCD_SET_POWER_STATE_D0);
>>> >> if (retval)
>>> >> return retval;
>>> >>
>>> >> @@ -301,17 +301,18 @@ static int exynos_dp_link_start(struct exynos_dp_device *dp)
>>> >> exynos_dp_set_training_pattern(dp, TRAINING_PTN1);
>>> >>
>>> >> /* Set RX training pattern */
>>> >> - exynos_dp_write_byte_to_dpcd(dp,
>>> >> - DPCD_ADDR_TRAINING_PATTERN_SET,
>>> >> - DPCD_SCRAMBLING_DISABLED |
>>> >> - DPCD_TRAINING_PATTERN_1);
>>> >> + retval = exynos_dp_write_byte_to_dpcd(dp,
>>> >> + DPCD_ADDR_TRAINING_PATTERN_SET,
>>> >> + DPCD_SCRAMBLING_DISABLED | DPCD_TRAINING_PATTERN_1);
>>> >> + if (retval)
>>> >> + return retval;
>>> >>
>>> >> for (lane = 0; lane < lane_count; lane++)
>>> >> buf[lane] = DPCD_PRE_EMPHASIS_PATTERN2_LEVEL0 |
>>> >> DPCD_VOLTAGE_SWING_PATTERN1_LEVEL0;
>>> >> - retval = exynos_dp_write_bytes_to_dpcd(dp,
>>> >> - DPCD_ADDR_TRAINING_LANE0_SET,
>>> >> - lane_count, buf);
>>> >> +
>>> >> + retval = exynos_dp_write_bytes_to_dpcd(dp, DPCD_ADDR_TRAINING_LANE0_SET,
>>> >> + lane_count, buf);
>>> >>
>>> >> return retval;
>>> >> }
>>> >> @@ -337,18 +338,17 @@ static int exynos_dp_clock_recovery_ok(u8 link_status[2], int lane_count)
>>> >> return 0;
>>> >> }
>>> >>
>>> >> -static int exynos_dp_channel_eq_ok(u8 link_align[3], int lane_count)
>>> >> +static int exynos_dp_channel_eq_ok(u8 link_status[2], u8 link_align,
>>> >> + int lane_count)
>>> >> {
>>> >> int lane;
>>> >> - u8 lane_align;
>>> >> u8 lane_status;
>>> >>
>>> >> - lane_align = link_align[2];
>>> >> - if ((lane_align & DPCD_INTERLANE_ALIGN_DONE) = 0)
>>> >> + if ((link_align & DPCD_INTERLANE_ALIGN_DONE) = 0)
>>> >> return -EINVAL;
>>> >>
>>> >> for (lane = 0; lane < lane_count; lane++) {
>>> >> - lane_status = exynos_dp_get_lane_status(link_align, lane);
>>> >> + lane_status = exynos_dp_get_lane_status(link_status, lane);
>>> >> lane_status &= DPCD_CHANNEL_EQ_BITS;
>>> >> if (lane_status != DPCD_CHANNEL_EQ_BITS)
>>> >> return -EINVAL;
>>> >> @@ -432,22 +432,47 @@ static void exynos_dp_reduce_link_rate(struct exynos_dp_device *dp)
>>> >> dp->link_train.lt_state = FAILED;
>>> >> }
>>> >>
>>> >> +static void exynos_dp_get_adjust_training_lane(struct exynos_dp_device *dp,
>>> >> + u8 adjust_request[2])
>>> >> +{
>>> >> + int lane, lane_count;
>>> >> + u8 voltage_swing, pre_emphasis, training_lane;
>>> >> +
>>> >> + lane_count = dp->link_train.lane_count;
>>> >> + for (lane = 0; lane < lane_count; lane++) {
>>> >> + voltage_swing = exynos_dp_get_adjust_request_voltage(
>>> >> + adjust_request, lane);
>>> >> + pre_emphasis = exynos_dp_get_adjust_request_pre_emphasis(
>>> >> + adjust_request, lane);
>>> >> + training_lane = DPCD_VOLTAGE_SWING_SET(voltage_swing) |
>>> >> + DPCD_PRE_EMPHASIS_SET(pre_emphasis);
>>> >> +
>>> >> + if (voltage_swing = VOLTAGE_LEVEL_3)
>>> >> + training_lane |= DPCD_MAX_SWING_REACHED;
>>> >> + if (pre_emphasis = PRE_EMPHASIS_LEVEL_3)
>>> >> + training_lane |= DPCD_MAX_PRE_EMPHASIS_REACHED;
>>> >> +
>>> >> + dp->link_train.training_lane[lane] = training_lane;
>>> >> + }
>>> >> +}
>>> >> +
>>> >> static int exynos_dp_process_clock_recovery(struct exynos_dp_device *dp)
>>> >> {
>>> >> - u8 link_status[2];
>>> >> int lane, lane_count, retval;
>>> >> -
>>> >> - u8 adjust_request[2];
>>> >> - u8 voltage_swing;
>>> >> - u8 pre_emphasis;
>>> >> - u8 training_lane;
>>> >> + u8 voltage_swing, pre_emphasis, training_lane;
>>> >> + u8 link_status[2], adjust_request[2];
>>> >>
>>> >> usleep_range(100, 101);
>>> >>
>>> >> lane_count = dp->link_train.lane_count;
>>> >>
>>> >> retval = exynos_dp_read_bytes_from_dpcd(dp, DPCD_ADDR_LANE0_1_STATUS,
>>> >> - 2, link_status);
>>> >> + 2, link_status);
>>> >> + if (retval)
>>> >> + return retval;
>>> >> +
>>> >> + retval = exynos_dp_read_bytes_from_dpcd(dp,
>>> >> + DPCD_ADDR_ADJUST_REQUEST_LANE0_1, 2, adjust_request);
>>> >> if (retval)
>>> >> return retval;
>>> >>
>>> >> @@ -455,43 +480,9 @@ static int exynos_dp_process_clock_recovery(struct exynos_dp_device *dp)
>>> >> /* set training pattern 2 for EQ */
>>> >> exynos_dp_set_training_pattern(dp, TRAINING_PTN2);
>>> >>
>>> >> - for (lane = 0; lane < lane_count; lane++) {
>>> >> - retval = exynos_dp_read_bytes_from_dpcd(dp,
>>> >> - DPCD_ADDR_ADJUST_REQUEST_LANE0_1,
>>> >> - 2, adjust_request);
>>> >> - if (retval)
>>> >> - return retval;
>>> >> -
>>> >> - voltage_swing = exynos_dp_get_adjust_request_voltage(
>>> >> - adjust_request, lane);
>>> >> - pre_emphasis = exynos_dp_get_adjust_request_pre_emphasis(
>>> >> - adjust_request, lane);
>>> >> - training_lane = DPCD_VOLTAGE_SWING_SET(voltage_swing) |
>>> >> - DPCD_PRE_EMPHASIS_SET(pre_emphasis);
>>> >> -
>>> >> - if (voltage_swing = VOLTAGE_LEVEL_3)
>>> >> - training_lane |= DPCD_MAX_SWING_REACHED;
>>> >> - if (pre_emphasis = PRE_EMPHASIS_LEVEL_3)
>>> >> - training_lane |= DPCD_MAX_PRE_EMPHASIS_REACHED;
>>> >> -
>>> >> - dp->link_train.training_lane[lane] = training_lane;
>>> >> -
>>> >> - exynos_dp_set_lane_link_training(dp,
>>> >> - dp->link_train.training_lane[lane],
>>> >> - lane);
>>> >> - }
>>> >> -
>>> >
>>> > Please don't move it to back.
>>> >
>>>
>>> I assume you're talking about the adjust_request read here? I noticed
>>> this was changed in your original clean-up patch
>>> (http://www.spinics.net/lists/linux-fbdev/msg06849.html), but assumed
>>> it was a no-op. What bug does it fix? According to the flowcharts in
>>> the exynos5250 datasheet (figure 49-10 & 49-11), this should be done
>>> *before* setting training pattern 2. Your alteration to my patch will
>>> read it after.
>>>
>>> I also noticed that you added back exynos_dp_get_adjust_training_lane
>>> call here, along with setting DPCD_ADDR_TRAINING_LANE0_SET. You'll
>>> notice that this same code is run in the else path of this function.
>>
>> No, it is not same.
>>
>> 1) your patch
>> exynos_dp_read_bytes_from_dpcd(dp,
>> DPCD_ADDR_ADJUST_REQUEST_LANE0_1, 2, adjust_request);
>> if (exynos_dp_clock_recovery_ok(link_status, lane_count) = 0) {
>> ...
>> } else {
>> for (lane = 0; lane < lane_count; lane++) {
>> training_lane = exynos_dp_get_lane_link_training()
>> voltage_swing = exynos_dp_get_adjust_request_voltage()
>> pre_emphasis = exynos_dp_get_adjust_request_pre_emphasis()
>> ...
>>
>> 2) my patch
>> if (exynos_dp_clock_recovery_ok(link_status, lane_count) = 0) {
>> ...
>> } else {
>> for (lane = 0; lane < lane_count; lane++) {
>> training_lane = exynos_dp_get_lane_link_training()
>> exynos_dp_read_bytes_from_dpcd(dp,
>> DPCD_ADDR_ADJUST_REQUEST_LANE0_1, 2, adjust_request);
>> voltage_swing = exynos_dp_get_adjust_request_voltage()
>> pre_emphasis = exynos_dp_get_adjust_request_pre_emphasis()
>> ...
>>
>>
>> When the place of reading DPCD_ADDR_ADJUST_REQUEST_LANE0_1 is changed,
>> it makes the Link Fail problem when exynos_dp_clock_recovery_ok() fails.
>> In the case of most panels, exynos_dp_clock_recovery_ok() does not fail.
>> But, some panels failed at exynos_dp_clock_recovery_ok(), and makes the problem
>> if your patch is used.
>>
>
> I must be missing something. exynos_dp_clock_recovery_ok just
> interprets link_status, which is read in the same place in both
> patches. exynos_dp_get_lane_link_training reads from an exynos
> register. I fail to see how either of those operations could affect
> the adjust_request DPCD read.
>
> The following is the order of operations for
> exynos_dp_clock_recovery_ok failure with my patch:
>
> (1) Read lane_status from DPCD
> (2) Read adjust_request from DPCD
> (3) clock_recovery_ok fails
> (4) Get training_lane 0, parse voltage_swing 0 from adjust_request,
> parse pre_emphasis 0 from adjust_request
> (5) Check voltage_swing and pre_emphasis against training_lane,
> increment loop count if nothing changed, exit earlyif max met
> (6) Repeat (4),(5) for lane 1, 2, 3
> (7) Change the value of training_lane to match adjust request read in step (2)
> (8) Write training_ctl to exynos DP register (all lanes)
> (9) Write training_lane back out to DPCD (all lanes)
>
> With your patch (http://www.spinics.net/lists/linux-fbdev/msg08548.html):
>
> (1) Read lane_status from DPCD
> (2) clock_recovery_ok fails
> (3) Get training_lane 0
> (4) Read adjust_request from DPCD
> (5) Parse voltage_swing 0 from adjust_request, parse pre_emphasis 0
> from adjust_request
> (6) Exit early if max met, check voltage_swing and pre_emphasis
> against training_lane, increment loop count if nothing changed
> (7) Change the value of training_lane to match adjust request read in step (4)
> (8) Write training_ctl to exynos DP register for lane 0
> (9) Repeat (3), (4), (5), (6), (7), (8) for lane 1, 2, 3
> (9) Write training_lane back out to DPCD (all lanes)
>
> So unless reading the training lane from DPCD or
> exynos_dp_set_lane_link_training (which writes an exynos register)
> changes the value of the adjust_request read from DPCD, our patches
> are the same :)
>
>> Also, your patch calls exynos_dp_get_adjust_request_voltage() and
>> exynos_dp_get_adjust_request_pre_emphasis() twice,
>> when exynos_dp_clock_recovery_ok() fails. Previously, exynos_dp_clock_recovery_ok()
>> and exynos_dp_get_adjust_request_pre_emphasis() are called only onetime
>> when exynos_dp_clock_recovery_ok() fails.
>> There is no need to call exynos_dp_get_adjust_request_voltage() and
>> exynos_dp_get_adjust_request_pre_emphasis() 'TWICE'.
>>
>
> Yes, it does, but it's just a shift and bitwise-AND... not really
> heavy weight. It would be nice to refactor that code a bit to remove
> the nasty, but that's a different patch.
>
>
>>
>> Anyway, your patch is good and readability is improved.
>> So, I went the extra mile to accept your original patch and
>> add it to v3 patch that I sent.
>> (http://www.spinics.net/lists/linux-fbdev/msg08548.html)
>>
>> But, it is necessary to be careful with some error paths,
>> that is not used at most eDP panels.
>>
>
> I'm still not convinced, but I think we're converging :)
>
Ping.
> Cheers,
>
> Sean
>
>
>
>> Best regards,
>> Jingoo Han
>>
>>> Hence, I removed the duplication and put it all at the bottom. This
>>> improves readability, matches the flowchart more closely, and removes
>>> duplication.
>>>
>>> I'd urge you to please read my patch more carefully and ask questions
>>> if you have any.
>>>
>>> Thanks!
>>>
>>> Sean
>>>
>>> >> retval = exynos_dp_write_byte_to_dpcd(dp,
>>> >> DPCD_ADDR_TRAINING_PATTERN_SET,
>>> >> - DPCD_SCRAMBLING_DISABLED |
>>> >> - DPCD_TRAINING_PATTERN_2);
>>> >> - if (retval)
>>> >> - return retval;
>>> >> -
>>> >> - retval = exynos_dp_write_bytes_to_dpcd(dp,
>>> >> - DPCD_ADDR_TRAINING_LANE0_SET,
>>> >> - lane_count,
>>> >> - dp->link_train.training_lane);
>>> >> + DPCD_SCRAMBLING_DISABLED | DPCD_TRAINING_PATTERN_2);
>>> >> if (retval)
>>> >> return retval;
>>> >>
>>> >> @@ -501,73 +492,49 @@ static int exynos_dp_process_clock_recovery(struct exynos_dp_device *dp)
>>> >> for (lane = 0; lane < lane_count; lane++) {
>>> >> training_lane = exynos_dp_get_lane_link_training(
>>> >> dp, lane);
>>> >> - retval = exynos_dp_read_bytes_from_dpcd(dp,
>>> >> - DPCD_ADDR_ADJUST_REQUEST_LANE0_1,
>>> >> - 2, adjust_request);
>>> >> - if (retval)
>>> >> - return retval;
>>> >> -
>>> >> voltage_swing = exynos_dp_get_adjust_request_voltage(
>>> >> adjust_request, lane);
>>> >> pre_emphasis = exynos_dp_get_adjust_request_pre_emphasis(
>>> >> adjust_request, lane);
>>> >>
>>> >> - if (voltage_swing = VOLTAGE_LEVEL_3 ||
>>> >> - pre_emphasis = PRE_EMPHASIS_LEVEL_3) {
>>> >> - dev_err(dp->dev, "voltage or pre emphasis reached max level\n");
>>> >> - goto reduce_link_rate;
>>> >> - }
>>> >> -
>>> >> - if ((DPCD_VOLTAGE_SWING_GET(training_lane) =
>>> >> - voltage_swing) &&
>>> >> - (DPCD_PRE_EMPHASIS_GET(training_lane) =
>>> >> - pre_emphasis)) {
>>> >> + if (DPCD_VOLTAGE_SWING_GET(training_lane) =
>>> >> + voltage_swing &&
>>> >> + DPCD_PRE_EMPHASIS_GET(training_lane) =
>>> >> + pre_emphasis)
>>> >> dp->link_train.cr_loop[lane]++;
>>> >> - if (dp->link_train.cr_loop[lane] = MAX_CR_LOOP) {
>>> >> - dev_err(dp->dev, "CR Max loop\n");
>>> >> - goto reduce_link_rate;
>>> >> - }
>>> >> - }
>>> >>
>>> >> - training_lane = DPCD_VOLTAGE_SWING_SET(voltage_swing) |
>>> >> - DPCD_PRE_EMPHASIS_SET(pre_emphasis);
>>> >> -
>>> >> - if (voltage_swing = VOLTAGE_LEVEL_3)
>>> >> - training_lane |= DPCD_MAX_SWING_REACHED;
>>> >> - if (pre_emphasis = PRE_EMPHASIS_LEVEL_3)
>>> >> - training_lane |= DPCD_MAX_PRE_EMPHASIS_REACHED;
>>> >> -
>>> >> - dp->link_train.training_lane[lane] = training_lane;
>>> >> -
>>> >> - exynos_dp_set_lane_link_training(dp,
>>> >> - dp->link_train.training_lane[lane], lane);
>>> >> + if (dp->link_train.cr_loop[lane] = MAX_CR_LOOP ||
>>> >> + voltage_swing = VOLTAGE_LEVEL_3 ||
>>> >> + pre_emphasis = PRE_EMPHASIS_LEVEL_3) {
>>> >> + dev_err(dp->dev, "CR Max reached (%d,%d,%d)\n",
>>> >> + dp->link_train.cr_loop[lane],
>>> >> + voltage_swing, pre_emphasis);
>>> >> + exynos_dp_reduce_link_rate(dp);
>>> >> + return -EIO;
>>> >> + }
>>> >> }
>>> >> + }
>>> >> +
>>> >> + exynos_dp_get_adjust_training_lane(dp, adjust_request);
>>> >>
>>> >> - retval = exynos_dp_write_bytes_to_dpcd(dp,
>>> >> - DPCD_ADDR_TRAINING_LANE0_SET, lane_count,
>>> >> - dp->link_train.training_lane);
>>> >> + for (lane = 0; lane < lane_count; lane++) {
>>> >> + exynos_dp_set_lane_link_training(dp,
>>> >> + dp->link_train.training_lane[lane], lane);
>>> >> + retval = exynos_dp_write_byte_to_dpcd(dp,
>>> >> + DPCD_ADDR_TRAINING_LANE0_SET + lane,
>>> >> + dp->link_train.training_lane[lane]);
>>> >
>>> > The following would be better.
>>> > byte's'_to_dpcd is faster than byte_to_dpcd x 4 times.
>>> >
>>> > for (lane = 0; lane < lane_count; lane++) {
>>> > exynos_dp_set_lane_link_training(dp,
>>> > dp->link_train.training_lane[lane], lane);
>>> > }
>>> >
>>> > retval = exynos_dp_write_bytes_to_dpcd(dp,
>>> > DPCD_ADDR_TRAINING_LANE0_SET, lane_count,
>>> > dp->link_train.training_lane);
>>> >
>>>
>>>
>>> Makes sense, that's a good change.
>>>
>>>
>>> >> if (retval)
>>> >> return retval;
>>> >> }
>>> >>
>>> >> return retval;
>>> >> -
>>> >> -reduce_link_rate:
>>> >> - exynos_dp_reduce_link_rate(dp);
>>> >> - return -EIO;
>>> >> }
>>> >>
>>> >> static int exynos_dp_process_equalizer_training(struct exynos_dp_device *dp)
>>> >> {
>>> >> - u8 link_status[2];
>>> >> - u8 link_align[3];
>>> >> int lane, lane_count, retval;
>>> >> u32 reg;
>>> >> -
>>> >> - u8 adjust_request[2];
>>> >> - u8 voltage_swing;
>>> >> - u8 pre_emphasis;
>>> >> - u8 training_lane;
>>> >> + u8 link_align, link_status[2], adjust_request[2];
>>> >>
>>> >> usleep_range(400, 401);
>>> >>
>>> >> @@ -578,85 +545,63 @@ static int exynos_dp_process_equalizer_training(struct exynos_dp_device *dp)
>>> >> if (retval)
>>> >> return retval;
>>> >>
>>> >> - if (exynos_dp_clock_recovery_ok(link_status, lane_count) = 0) {
>>> >> - link_align[0] = link_status[0];
>>> >> - link_align[1] = link_status[1];
>>> >> -
>>> >> - exynos_dp_read_byte_from_dpcd(dp,
>>> >> - DPCD_ADDR_LANE_ALIGN_STATUS_UPDATED,
>>> >> - &link_align[2]);
>>> >> -
>>> >> - for (lane = 0; lane < lane_count; lane++) {
>>> >> - retval = exynos_dp_read_bytes_from_dpcd(dp,
>>> >> - DPCD_ADDR_ADJUST_REQUEST_LANE0_1,
>>> >> - 2, adjust_request);
>>> >> - if (retval)
>>> >> - return retval;
>>> >> + if (exynos_dp_clock_recovery_ok(link_status, lane_count)) {
>>> >> + exynos_dp_reduce_link_rate(dp);
>>> >> + return -EIO;
>>> >> + }
>>> >>
>>> >> - voltage_swing = exynos_dp_get_adjust_request_voltage(
>>> >> - adjust_request, lane);
>>> >> - pre_emphasis = exynos_dp_get_adjust_request_pre_emphasis(
>>> >> - adjust_request, lane);
>>> >> - training_lane = DPCD_VOLTAGE_SWING_SET(voltage_swing) |
>>> >> - DPCD_PRE_EMPHASIS_SET(pre_emphasis);
>>> >> + retval = exynos_dp_read_bytes_from_dpcd(dp,
>>> >> + DPCD_ADDR_ADJUST_REQUEST_LANE0_1, 2, adjust_request);
>>> >> + if (retval)
>>> >> + return retval;
>>> >>
>>> >> - if (voltage_swing = VOLTAGE_LEVEL_3)
>>> >> - training_lane |= DPCD_MAX_SWING_REACHED;
>>> >> - if (pre_emphasis = PRE_EMPHASIS_LEVEL_3)
>>> >> - training_lane |= DPCD_MAX_PRE_EMPHASIS_REACHED;
>>> >> + retval = exynos_dp_read_byte_from_dpcd(dp,
>>> >> + DPCD_ADDR_LANE_ALIGN_STATUS_UPDATED, &link_align);
>>> >> + if (retval)
>>> >> + return retval;
>>> >>
>>> >> - dp->link_train.training_lane[lane] = training_lane;
>>> >> - }
>>> >> + exynos_dp_get_adjust_training_lane(dp, adjust_request);
>>> >>
>>> >> - if (exynos_dp_channel_eq_ok(link_align, lane_count) = 0) {
>>> >> - /* traing pattern Set to Normal */
>>> >> - exynos_dp_training_pattern_dis(dp);
>>> >> + if (!exynos_dp_channel_eq_ok(link_status, link_align, lane_count)) {
>>> >> + /* traing pattern Set to Normal */
>>> >> + exynos_dp_training_pattern_dis(dp);
>>> >>
>>> >> - dev_info(dp->dev, "Link Training success!\n");
>>> >> + dev_info(dp->dev, "Link Training success!\n");
>>> >>
>>> >> - exynos_dp_get_link_bandwidth(dp, ®);
>>> >> - dp->link_train.link_rate = reg;
>>> >> - dev_dbg(dp->dev, "final bandwidth = %.2x\n",
>>> >> - dp->link_train.link_rate);
>>> >> + exynos_dp_get_link_bandwidth(dp, ®);
>>> >> + dp->link_train.link_rate = reg;
>>> >> + dev_dbg(dp->dev, "final bandwidth = %.2x\n",
>>> >> + dp->link_train.link_rate);
>>> >>
>>> >> - exynos_dp_get_lane_count(dp, ®);
>>> >> - dp->link_train.lane_count = reg;
>>> >> - dev_dbg(dp->dev, "final lane count = %.2x\n",
>>> >> - dp->link_train.lane_count);
>>> >> + exynos_dp_get_lane_count(dp, ®);
>>> >> + dp->link_train.lane_count = reg;
>>> >> + dev_dbg(dp->dev, "final lane count = %.2x\n",
>>> >> + dp->link_train.lane_count);
>>> >>
>>> >> - /* set enhanced mode if available */
>>> >> - exynos_dp_set_enhanced_mode(dp);
>>> >> - dp->link_train.lt_state = FINISHED;
>>> >> - } else {
>>> >> - /* not all locked */
>>> >> - dp->link_train.eq_loop++;
>>> >> + /* set enhanced mode if available */
>>> >> + exynos_dp_set_enhanced_mode(dp);
>>> >> + dp->link_train.lt_state = FINISHED;
>>> >>
>>> >> - if (dp->link_train.eq_loop > MAX_EQ_LOOP) {
>>> >> - dev_err(dp->dev, "EQ Max loop\n");
>>> >> - goto reduce_link_rate;
>>> >> - }
>>> >> + return 0;
>>> >> + }
>>> >>
>>> >> - for (lane = 0; lane < lane_count; lane++)
>>> >> - exynos_dp_set_lane_link_training(dp,
>>> >> - dp->link_train.training_lane[lane],
>>> >> - lane);
>>> >> + /* not all locked */
>>> >> + dp->link_train.eq_loop++;
>>> >>
>>> >> - retval = exynos_dp_write_bytes_to_dpcd(dp,
>>> >> - DPCD_ADDR_TRAINING_LANE0_SET,
>>> >> - lane_count,
>>> >> - dp->link_train.training_lane);
>>> >> - if (retval)
>>> >> - return retval;
>>> >> - }
>>> >> - } else {
>>> >> - goto reduce_link_rate;
>>> >> + if (dp->link_train.eq_loop > MAX_EQ_LOOP) {
>>> >> + dev_err(dp->dev, "EQ Max loop\n");
>>> >> + exynos_dp_reduce_link_rate(dp);
>>> >> + return -EIO;
>>> >> }
>>> >>
>>> >> - return 0;
>>> >> + for (lane = 0; lane < lane_count; lane++)
>>> >> + exynos_dp_set_lane_link_training(dp,
>>> >> + dp->link_train.training_lane[lane], lane);
>>> >>
>>> >> -reduce_link_rate:
>>> >> - exynos_dp_reduce_link_rate(dp);
>>> >> - return -EIO;
>>> >> + retval = exynos_dp_write_bytes_to_dpcd(dp, DPCD_ADDR_TRAINING_LANE0_SET,
>>> >> + lane_count, dp->link_train.training_lane);
>>> >> +
>>> >> + return retval;
>>> >> }
>>> >>
>>> >> static void exynos_dp_get_max_rx_bandwidth(struct exynos_dp_device *dp,
>>> >> --
>>> >> 1.7.7.3
>>> >
>>
^ permalink raw reply
* Re: tty, vt: lockdep warnings (Patch v3)
From: Alan Cox @ 2012-11-08 14:34 UTC (permalink / raw)
To: Bjørn Mork
Cc: Sasha Levin, Dave Jones, Hugh Dickins, Sasha Levin, Daniel Vetter,
Greg Kroah-Hartman, Jiri Slaby, linux-kernel, linux-fbdev,
florianSchandinat
In-Reply-To: <87625h9yoe.fsf@nemi.mork.no>
commit f35b3fbf24c4e4debb6a7a864b09854ccc2a22e7
Author: Alan Cox <alan@linux.intel.com>
Date: Wed Nov 7 16:35:08 2012 +0000
fb: Rework locking to fix lock ordering on takeover
Adjust the console layer to allow a take over call where the caller already
holds the locks. Make the fb layer lock in order.
This s partly a band aid, the fb layer is terminally confused about the
locking rules it uses for its notifiers it seems.
Signed-off-by: Alan Cox <alan@linux.intel.com>
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index f87d7e8..77bf205 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -2984,7 +2984,7 @@ int __init vty_init(const struct file_operations *console_fops)
static struct class *vtconsole_class;
-static int bind_con_driver(const struct consw *csw, int first, int last,
+static int do_bind_con_driver(const struct consw *csw, int first, int last,
int deflt)
{
struct module *owner = csw->owner;
@@ -2995,7 +2995,7 @@ static int bind_con_driver(const struct consw *csw, int first, int last,
if (!try_module_get(owner))
return -ENODEV;
- console_lock();
+ WARN_CONSOLE_UNLOCKED();
/* check if driver is registered */
for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
@@ -3080,11 +3080,22 @@ static int bind_con_driver(const struct consw *csw, int first, int last,
retval = 0;
err:
- console_unlock();
module_put(owner);
return retval;
};
+
+static int bind_con_driver(const struct consw *csw, int first, int last,
+ int deflt)
+{
+ int ret;
+
+ console_lock();
+ ret = do_bind_con_driver(csw, first, last, deflt);
+ console_unlock();
+ return ret;
+}
+
#ifdef CONFIG_VT_HW_CONSOLE_BINDING
static int con_is_graphics(const struct consw *csw, int first, int last)
{
@@ -3196,9 +3207,9 @@ int unbind_con_driver(const struct consw *csw, int first, int last, int deflt)
if (!con_is_bound(csw))
con_driver->flag &= ~CON_DRIVER_FLAG_INIT;
- console_unlock();
/* ignore return value, binding should not fail */
- bind_con_driver(defcsw, first, last, deflt);
+ do_bind_con_driver(defcsw, first, last, deflt);
+ console_unlock();
err:
module_put(owner);
return retval;
@@ -3489,28 +3500,18 @@ int con_debug_leave(void)
}
EXPORT_SYMBOL_GPL(con_debug_leave);
-/**
- * register_con_driver - register console driver to console layer
- * @csw: console driver
- * @first: the first console to take over, minimum value is 0
- * @last: the last console to take over, maximum value is MAX_NR_CONSOLES -1
- *
- * DESCRIPTION: This function registers a console driver which can later
- * bind to a range of consoles specified by @first and @last. It will
- * also initialize the console driver by calling con_startup().
- */
-int register_con_driver(const struct consw *csw, int first, int last)
+static int do_register_con_driver(const struct consw *csw, int first, int last)
{
struct module *owner = csw->owner;
struct con_driver *con_driver;
const char *desc;
int i, retval = 0;
+ WARN_CONSOLE_UNLOCKED();
+
if (!try_module_get(owner))
return -ENODEV;
- console_lock();
-
for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
con_driver = ®istered_con_driver[i];
@@ -3563,10 +3564,29 @@ int register_con_driver(const struct consw *csw, int first, int last)
}
err:
- console_unlock();
module_put(owner);
return retval;
}
+
+/**
+ * register_con_driver - register console driver to console layer
+ * @csw: console driver
+ * @first: the first console to take over, minimum value is 0
+ * @last: the last console to take over, maximum value is MAX_NR_CONSOLES -1
+ *
+ * DESCRIPTION: This function registers a console driver which can later
+ * bind to a range of consoles specified by @first and @last. It will
+ * also initialize the console driver by calling con_startup().
+ */
+int register_con_driver(const struct consw *csw, int first, int last)
+{
+ int retval;
+
+ console_lock();
+ retval = do_register_con_driver(csw, first, last);
+ console_unlock();
+ return retval;
+}
EXPORT_SYMBOL(register_con_driver);
/**
@@ -3622,6 +3642,29 @@ EXPORT_SYMBOL(unregister_con_driver);
*
* take_over_console is basically a register followed by unbind
*/
+int do_take_over_console(const struct consw *csw, int first, int last, int deflt)
+{
+ int err;
+
+ err = do_register_con_driver(csw, first, last);
+ /* if we get an busy error we still want to bind the console driver
+ * and return success, as we may have unbound the console driver
+ * but not unregistered it.
+ */
+ if (err = -EBUSY)
+ err = 0;
+ if (!err)
+ do_bind_con_driver(csw, first, last, deflt);
+
+ return err;
+}
+/*
+ * If we support more console drivers, this function is used
+ * when a driver wants to take over some existing consoles
+ * and become default driver for newly opened ones.
+ *
+ * take_over_console is basically a register followed by unbind
+ */
int take_over_console(const struct consw *csw, int first, int last, int deflt)
{
int err;
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index fdefa8f..c75f8ce 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -529,6 +529,34 @@ static int search_for_mapped_con(void)
return retval;
}
+static int do_fbcon_takeover(int show_logo)
+{
+ int err, i;
+
+ if (!num_registered_fb)
+ return -ENODEV;
+
+ if (!show_logo)
+ logo_shown = FBCON_LOGO_DONTSHOW;
+
+ for (i = first_fb_vc; i <= last_fb_vc; i++)
+ con2fb_map[i] = info_idx;
+
+ err = do_take_over_console(&fb_con, first_fb_vc, last_fb_vc,
+ fbcon_is_default);
+
+ if (err) {
+ for (i = first_fb_vc; i <= last_fb_vc; i++) {
+ con2fb_map[i] = -1;
+ }
+ info_idx = -1;
+ } else {
+ fbcon_has_console_bind = 1;
+ }
+
+ return err;
+}
+
static int fbcon_takeover(int show_logo)
{
int err, i;
@@ -3115,7 +3143,7 @@ static int fbcon_fb_registered(struct fb_info *info)
}
if (info_idx != -1)
- ret = fbcon_takeover(1);
+ ret = do_fbcon_takeover(1);
} else {
for (i = first_fb_vc; i <= last_fb_vc; i++) {
if (con2fb_map_boot[i] = idx)
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 3ff0105..564ebe9 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -1650,7 +1650,9 @@ static int do_register_framebuffer(struct fb_info *fb_info)
event.info = fb_info;
if (!lock_fb_info(fb_info))
return -ENODEV;
+ console_lock();
fb_notifier_call_chain(FB_EVENT_FB_REGISTERED, &event);
+ console_unlock();
unlock_fb_info(fb_info);
return 0;
}
@@ -1853,11 +1855,8 @@ int fb_new_modelist(struct fb_info *info)
err = 1;
if (!list_empty(&info->modelist)) {
- if (!lock_fb_info(info))
- return -ENODEV;
event.info = info;
err = fb_notifier_call_chain(FB_EVENT_NEW_MODELIST, &event);
- unlock_fb_info(info);
}
return err;
diff --git a/drivers/video/fbsysfs.c b/drivers/video/fbsysfs.c
index a55e366..ef476b0 100644
--- a/drivers/video/fbsysfs.c
+++ b/drivers/video/fbsysfs.c
@@ -177,6 +177,8 @@ static ssize_t store_modes(struct device *device,
if (i * sizeof(struct fb_videomode) != count)
return -EINVAL;
+ if (!lock_fb_info(fb_info))
+ return -ENODEV;
console_lock();
list_splice(&fb_info->modelist, &old_list);
fb_videomode_to_modelist((const struct fb_videomode *)buf, i,
@@ -188,6 +190,7 @@ static ssize_t store_modes(struct device *device,
fb_destroy_modelist(&old_list);
console_unlock();
+ unlock_fb_info(fb_info);
return 0;
}
diff --git a/include/linux/console.h b/include/linux/console.h
index dedb082..4ef4307 100644
--- a/include/linux/console.h
+++ b/include/linux/console.h
@@ -78,6 +78,7 @@ int con_is_bound(const struct consw *csw);
int register_con_driver(const struct consw *csw, int first, int last);
int unregister_con_driver(const struct consw *csw);
int take_over_console(const struct consw *sw, int first, int last, int deflt);
+int do_take_over_console(const struct consw *sw, int first, int last, int deflt);
void give_up_console(const struct consw *sw);
#ifdef CONFIG_HW_CONSOLE
int con_debug_enter(struct vc_data *vc);
^ permalink raw reply related
* Re: [PATCH 12/12] OMAPDSS: DPI: always use DSI PLL if available
From: Tomi Valkeinen @ 2012-11-08 7:39 UTC (permalink / raw)
To: Rob Clark
Cc: Tomi Valkeinen, Archit Taneja, linux-omap, linux-fbdev, dri-devel
In-Reply-To: <CAF6AEGsvRV=ez_aqz_tkb+azNMy4jQuSVdd7oKg6=nTnguX-Kw@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 4910 bytes --]
On 2012-11-07 21:18, Rob Clark wrote:
> On Wed, Nov 7, 2012 at 9:13 AM, Tomi Valkeinen <tomi.valkeinen@ti.com> wrote:
>> On 2012-11-07 16:32, Rob Clark wrote:
>>> On Wed, Nov 7, 2012 at 4:01 AM, Tomi Valkeinen <tomi.valkeinen@ti.com> wrote:
>>
>>>> Hotplugging is not some abstract future scenario, we already have
>>>> hardware that could use it. For example, omap3 SDP board has a
>>>> switchable output to DVI or LCD panel. In this case we know what the two
>>>> options are, but the disabled component is still effectually removed
>>>> from the system, and plugged back in when it's enabled.
>>>
>>> I would look at this as two different connectors which can not be used
>>> at the same time. You have this scenario with desktop graphics cards.
>>
>> Yes, that's an option with fixed amount of display devices. But doesn't
>> work for capes.
>
> Only if capes are hotpluggable.. otherwise probe what cape(s?) are
> present at boot time (is this possible to detect a cape from sw?), and
> create the associated connector(s).
Well, a cape can be anything. For beaglebone they have capes with
eeprom, and you can detect it.
The reason I'd like to have hotplug is that it would simplify panel
drivers in the case where we have multiple possible panels for the same
output, like the DVI/LCD case above for omap3 SDP.
If we don't have hotplug, then both DVI and LCD panel devices are
present at the same time, and they will share resources. In the minimum
they are sharing the video output, but more often than not they share
gpios/powers/etc.
It's normal that a driver will acquire resources for its device in its
probe, and thus we would have two drivers acquiring the same resources
at boot time, leading to the other driver failing. We currently manage
this by acquiring the resources late, only when the panel is being
enabled. But I think that's rather ugly.
It would be much cleaner if the panel device does not exist at all if
the panel is disconnected, and is created only when it is connected.
This of course creates the problem of who is responsible for creating
the panel device, and what triggers it. I think that's case specific,
and for capes, it'd be the cape driver.
But then again, I guess it's acceptable that we don't allow changing the
plugged-in panels at runtime. The user would have to select them with
kernel parameters or such. I guess this would be ok for capes and
development boards. I'm not aware of a production board that would
switch panels at runtime, although I know these were on the table in Nokia.
> Anyways, I think we are stretching a bit hard for use cases for
> hot-pluggable panels.. I just prefer to ignore hotplug for now and
> come back to it when there is a more legitimate use-case.
Ok, fair enough. But let's keep hotplug in mind, and if we're going to
create code that would make hotplug impossible to implement, let's stop
for a moment and think if we can do that in some other way.
>> I'm not so sure. The output (dpi/dsi/hdmi...) is the second step in our
>> chain. The primary "output" is in the DISPC module, the overlay manager.
>> That's where the timings, pixel clock, etc. are programmed. The second
>> step, our output, is really a converter IP. It receives the primary
>> output, converts it and outputs something else. Just like an external
>> converter chip would do.
>>
>
> the timings, pixel clock, vblank/framedone irqs, that all maps to crtc.
>
> encoder == converter, so I think this fits. "An encoder takes pixel
> data from a CRTC and converts it to a format suitable for any attached
> connectors" (from drm docbook)
Oh, ok. Then what you say makes sense. I thought encoder contains the
timings, as you said previously: "Basically the encoder is doing the
"control" stuff (power on/off, set timings, etc)".
In the case we have a long chain of display blocks, encoder could cover
all of them, not just the output block of OMAP? I don't know where the
panel goes, though.
>> And the output can be quite a bit anything. For example, with DBI or DSI
>> command mode outputs we don't have any of the conventional video
>> timings. It doesn't make sense to program, say, video blanking periods
>> to those outputs. But even with DBI and DSI we do have video blanking
>> periods in the DISPC's output, the ovl mgr.
>
> the encoder has mode_fixup() which can alter the timings that end up
> getting set, which might be a way to account for this. I guess really
> it should be the panel driver that is telling the encoder what
> adjusted timings to give to the crtc.. so the panel driver doesn't
> quite map to connector.
The panel can't say what timings to give to crtc, it depends on what's
between the crtc and the panel. In case of OMAP DSI, the dsi driver
needs to specify the timings for crtc, based on the panel.
Tomi
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 897 bytes --]
^ permalink raw reply
* Re: [PATCH 2/2] video: exynos_dp: move exynos_dp_config_video to a workqueue
From: Jingoo Han @ 2012-11-08 0:58 UTC (permalink / raw)
To: linux-fbdev
In-Reply-To: <1352286744-22588-2-git-send-email-ajaykumar.rs@samsung.com>
On Wednesday, November 07, 2012 8:12 PM Ajay Kumar wrote
>
> This speeds up boot significantly, since it can take up to a second to
> get the display up and going, and we want to keep on booting (through
> some userspace) while that happens.
This patch is not necessary.
The exynos_dp_config_video was already moved by Sean Paul's patch.
(http://www.spinics.net/lists/linux-fbdev/msg08555.html)
This patch including other Sean Paul's patches, will be merged to 3.8-rc1.
>
> Signed-off-by: Olof Johansson <olof@lixom.net>
> Signed-off-by: Ajay Kumar <ajaykumar.rs@samsung.com>
> ---
> drivers/video/exynos/exynos_dp_core.c | 30 ++++++++++++++++++------------
> drivers/video/exynos/exynos_dp_core.h | 1 +
> 2 files changed, 19 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/video/exynos/exynos_dp_core.c b/drivers/video/exynos/exynos_dp_core.c
> index f62778c..ecae6f4 100644
> --- a/drivers/video/exynos/exynos_dp_core.c
> +++ b/drivers/video/exynos/exynos_dp_core.c
> @@ -18,6 +18,7 @@
> #include <linux/io.h>
> #include <linux/interrupt.h>
> #include <linux/delay.h>
> +#include <linux/workqueue.h>
>
> #include <video/exynos_dp.h>
>
> @@ -752,19 +753,22 @@ static int exynos_dp_set_link_train(struct exynos_dp_device *dp,
> return retval;
> }
>
> -static int exynos_dp_config_video(struct exynos_dp_device *dp)
> +static void exynos_dp_config_video(struct work_struct *work)
> {
> + struct exynos_dp_device *dp;
> int retval = 0;
> int timeout_loop = 0;
> int done_count = 0;
>
> + dp = container_of(work, struct exynos_dp_device, config_work);
> +
> exynos_dp_config_video_slave_mode(dp);
>
> exynos_dp_set_video_color_format(dp);
>
> if (exynos_dp_get_pll_lock_status(dp) = PLL_UNLOCKED) {
> dev_err(dp->dev, "PLL is not locked yet.\n");
> - return -EINVAL;
> + return;
> }
>
> for (;;) {
> @@ -773,7 +777,7 @@ static int exynos_dp_config_video(struct exynos_dp_device *dp)
> break;
> if (DP_TIMEOUT_LOOP_COUNT < timeout_loop) {
> dev_err(dp->dev, "Timeout of video streamclk ok\n");
> - return -ETIMEDOUT;
> + return;
> }
>
> usleep_range(1, 2);
> @@ -807,7 +811,7 @@ static int exynos_dp_config_video(struct exynos_dp_device *dp)
> }
> if (DP_TIMEOUT_LOOP_COUNT < timeout_loop) {
> dev_err(dp->dev, "Timeout of video streamclk ok\n");
> - return -ETIMEDOUT;
> + return;
> }
>
> usleep_range(1000, 1001);
> @@ -815,8 +819,6 @@ static int exynos_dp_config_video(struct exynos_dp_device *dp)
>
> if (retval != 0)
> dev_err(dp->dev, "Video stream is not detected!\n");
> -
> - return retval;
> }
>
> static void exynos_dp_enable_scramble(struct exynos_dp_device *dp, bool enable)
> @@ -933,11 +935,9 @@ static int __devinit exynos_dp_probe(struct platform_device *pdev)
> exynos_dp_set_link_bandwidth(dp, dp->video_info->link_rate);
>
> exynos_dp_init_video(dp);
> - ret = exynos_dp_config_video(dp);
> - if (ret) {
> - dev_err(&pdev->dev, "unable to config video\n");
> - return ret;
> - }
> +
> + INIT_WORK(&dp->config_work, exynos_dp_config_video);
> + schedule_work(&dp->config_work);
>
> platform_set_drvdata(pdev, dp);
>
> @@ -949,6 +949,9 @@ static int __devexit exynos_dp_remove(struct platform_device *pdev)
> struct exynos_dp_platdata *pdata = pdev->dev.platform_data;
> struct exynos_dp_device *dp = platform_get_drvdata(pdev);
>
> + if (work_pending(&dp->config_work))
> + flush_work_sync(&dp->config_work);
> +
> if (pdata && pdata->phy_exit)
> pdata->phy_exit();
>
> @@ -964,6 +967,9 @@ static int exynos_dp_suspend(struct device *dev)
> struct exynos_dp_platdata *pdata = pdev->dev.platform_data;
> struct exynos_dp_device *dp = platform_get_drvdata(pdev);
>
> + if (work_pending(&dp->config_work))
> + flush_work_sync(&dp->config_work);
> +
> if (pdata && pdata->phy_exit)
> pdata->phy_exit();
>
> @@ -999,7 +1005,7 @@ static int exynos_dp_resume(struct device *dev)
> exynos_dp_set_link_bandwidth(dp, dp->video_info->link_rate);
>
> exynos_dp_init_video(dp);
> - exynos_dp_config_video(dp);
> + schedule_work(&dp->config_work);
>
> return 0;
> }
> diff --git a/drivers/video/exynos/exynos_dp_core.h b/drivers/video/exynos/exynos_dp_core.h
> index 1e646d7..303831d 100644
> --- a/drivers/video/exynos/exynos_dp_core.h
> +++ b/drivers/video/exynos/exynos_dp_core.h
> @@ -32,6 +32,7 @@ struct exynos_dp_device {
>
> struct video_info *video_info;
> struct link_train link_train;
> + struct work_struct config_work;
> };
>
> /* exynos_dp_reg.c */
> --
> 1.7.0.4
^ permalink raw reply
* Re: [PATCH 1/2] video: exynos_dp: remove redundant parameters
From: Jingoo Han @ 2012-11-08 0:54 UTC (permalink / raw)
To: linux-fbdev
In-Reply-To: <1352286744-22588-1-git-send-email-ajaykumar.rs@samsung.com>
On Wednesday, November 07, 2012 8:12 PM Ajay Kumar wrote
>
> This patch cleans up few redundant parameters keeping
> the same functionality intact.
>
> Signed-off-by: Olof Johansson <olof@lixom.net>
> Signed-off-by: Ajay Kumar <ajaykumar.rs@samsung.com>
Acked-by: Jingoo Han <jg1.han@samsung.com>
> ---
> drivers/video/exynos/exynos_dp_core.c | 14 +++++---------
> drivers/video/exynos/exynos_dp_core.h | 9 ++-------
> drivers/video/exynos/exynos_dp_reg.c | 23 +++++++++--------------
> 3 files changed, 16 insertions(+), 30 deletions(-)
>
> diff --git a/drivers/video/exynos/exynos_dp_core.c b/drivers/video/exynos/exynos_dp_core.c
> index d55470e..f62778c 100644
> --- a/drivers/video/exynos/exynos_dp_core.c
> +++ b/drivers/video/exynos/exynos_dp_core.c
> @@ -752,19 +752,15 @@ static int exynos_dp_set_link_train(struct exynos_dp_device *dp,
> return retval;
> }
>
> -static int exynos_dp_config_video(struct exynos_dp_device *dp,
> - struct video_info *video_info)
> +static int exynos_dp_config_video(struct exynos_dp_device *dp)
> {
> int retval = 0;
> int timeout_loop = 0;
> int done_count = 0;
>
> - exynos_dp_config_video_slave_mode(dp, video_info);
> + exynos_dp_config_video_slave_mode(dp);
>
> - exynos_dp_set_video_color_format(dp, video_info->color_depth,
> - video_info->color_space,
> - video_info->dynamic_range,
> - video_info->ycbcr_coeff);
> + exynos_dp_set_video_color_format(dp);
>
> if (exynos_dp_get_pll_lock_status(dp) = PLL_UNLOCKED) {
> dev_err(dp->dev, "PLL is not locked yet.\n");
> @@ -937,7 +933,7 @@ static int __devinit exynos_dp_probe(struct platform_device *pdev)
> exynos_dp_set_link_bandwidth(dp, dp->video_info->link_rate);
>
> exynos_dp_init_video(dp);
> - ret = exynos_dp_config_video(dp, dp->video_info);
> + ret = exynos_dp_config_video(dp);
> if (ret) {
> dev_err(&pdev->dev, "unable to config video\n");
> return ret;
> @@ -1003,7 +999,7 @@ static int exynos_dp_resume(struct device *dev)
> exynos_dp_set_link_bandwidth(dp, dp->video_info->link_rate);
>
> exynos_dp_init_video(dp);
> - exynos_dp_config_video(dp, dp->video_info);
> + exynos_dp_config_video(dp);
>
> return 0;
> }
> diff --git a/drivers/video/exynos/exynos_dp_core.h b/drivers/video/exynos/exynos_dp_core.h
> index 57b8a65..1e646d7 100644
> --- a/drivers/video/exynos/exynos_dp_core.h
> +++ b/drivers/video/exynos/exynos_dp_core.h
> @@ -107,11 +107,7 @@ u32 exynos_dp_get_lane3_link_training(struct exynos_dp_device *dp);
> void exynos_dp_reset_macro(struct exynos_dp_device *dp);
> void exynos_dp_init_video(struct exynos_dp_device *dp);
>
> -void exynos_dp_set_video_color_format(struct exynos_dp_device *dp,
> - u32 color_depth,
> - u32 color_space,
> - u32 dynamic_range,
> - u32 ycbcr_coeff);
> +void exynos_dp_set_video_color_format(struct exynos_dp_device *dp);
> int exynos_dp_is_slave_video_stream_clock_on(struct exynos_dp_device *dp);
> void exynos_dp_set_video_cr_mn(struct exynos_dp_device *dp,
> enum clock_recovery_m_value_type type,
> @@ -121,8 +117,7 @@ void exynos_dp_set_video_timing_mode(struct exynos_dp_device *dp, u32 type);
> void exynos_dp_enable_video_master(struct exynos_dp_device *dp, bool enable);
> void exynos_dp_start_video(struct exynos_dp_device *dp);
> int exynos_dp_is_video_stream_on(struct exynos_dp_device *dp);
> -void exynos_dp_config_video_slave_mode(struct exynos_dp_device *dp,
> - struct video_info *video_info);
> +void exynos_dp_config_video_slave_mode(struct exynos_dp_device *dp);
> void exynos_dp_enable_scrambling(struct exynos_dp_device *dp);
> void exynos_dp_disable_scrambling(struct exynos_dp_device *dp);
>
> diff --git a/drivers/video/exynos/exynos_dp_reg.c b/drivers/video/exynos/exynos_dp_reg.c
> index 3f5ca8a..db4975d 100644
> --- a/drivers/video/exynos/exynos_dp_reg.c
> +++ b/drivers/video/exynos/exynos_dp_reg.c
> @@ -1034,24 +1034,20 @@ void exynos_dp_init_video(struct exynos_dp_device *dp)
> writel(reg, dp->reg_base + EXYNOS_DP_VIDEO_CTL_8);
> }
>
> -void exynos_dp_set_video_color_format(struct exynos_dp_device *dp,
> - u32 color_depth,
> - u32 color_space,
> - u32 dynamic_range,
> - u32 ycbcr_coeff)
> +void exynos_dp_set_video_color_format(struct exynos_dp_device *dp)
> {
> u32 reg;
>
> /* Configure the input color depth, color space, dynamic range */
> - reg = (dynamic_range << IN_D_RANGE_SHIFT) |
> - (color_depth << IN_BPC_SHIFT) |
> - (color_space << IN_COLOR_F_SHIFT);
> + reg = (dp->video_info->dynamic_range << IN_D_RANGE_SHIFT) |
> + (dp->video_info->color_depth << IN_BPC_SHIFT) |
> + (dp->video_info->color_space << IN_COLOR_F_SHIFT);
> writel(reg, dp->reg_base + EXYNOS_DP_VIDEO_CTL_2);
>
> /* Set Input Color YCbCr Coefficients to ITU601 or ITU709 */
> reg = readl(dp->reg_base + EXYNOS_DP_VIDEO_CTL_3);
> reg &= ~IN_YC_COEFFI_MASK;
> - if (ycbcr_coeff)
> + if (dp->video_info->ycbcr_coeff)
> reg |= IN_YC_COEFFI_ITU709;
> else
> reg |= IN_YC_COEFFI_ITU601;
> @@ -1178,8 +1174,7 @@ int exynos_dp_is_video_stream_on(struct exynos_dp_device *dp)
> return 0;
> }
>
> -void exynos_dp_config_video_slave_mode(struct exynos_dp_device *dp,
> - struct video_info *video_info)
> +void exynos_dp_config_video_slave_mode(struct exynos_dp_device *dp)
> {
> u32 reg;
>
> @@ -1190,17 +1185,17 @@ void exynos_dp_config_video_slave_mode(struct exynos_dp_device *dp,
>
> reg = readl(dp->reg_base + EXYNOS_DP_VIDEO_CTL_10);
> reg &= ~INTERACE_SCAN_CFG;
> - reg |= (video_info->interlaced << 2);
> + reg |= (dp->video_info->interlaced << 2);
> writel(reg, dp->reg_base + EXYNOS_DP_VIDEO_CTL_10);
>
> reg = readl(dp->reg_base + EXYNOS_DP_VIDEO_CTL_10);
> reg &= ~VSYNC_POLARITY_CFG;
> - reg |= (video_info->v_sync_polarity << 1);
> + reg |= (dp->video_info->v_sync_polarity << 1);
> writel(reg, dp->reg_base + EXYNOS_DP_VIDEO_CTL_10);
>
> reg = readl(dp->reg_base + EXYNOS_DP_VIDEO_CTL_10);
> reg &= ~HSYNC_POLARITY_CFG;
> - reg |= (video_info->h_sync_polarity << 0);
> + reg |= (dp->video_info->h_sync_polarity << 0);
> writel(reg, dp->reg_base + EXYNOS_DP_VIDEO_CTL_10);
>
> reg = AUDIO_MODE_SPDIF_MODE | VIDEO_MODE_SLAVE_MODE;
> --
> 1.7.0.4
^ permalink raw reply
* [PATCH] backlight: Add of_find_backlight_by_node() function
From: Thierry Reding @ 2012-11-07 22:08 UTC (permalink / raw)
To: Florian Tobias Schandinat
Cc: linux-fbdev-u79uwXL29TY76Z2rM5mHXA,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
This function finds the struct backlight_device for a given device tree
node. A dummy function is provided so that it safely compiles out if OF
support is disabled.
Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
---
drivers/video/backlight/backlight.c | 17 +++++++++++++++++
include/linux/backlight.h | 10 ++++++++++
2 files changed, 27 insertions(+)
diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index 297db2f..0d1ed4f 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -370,6 +370,23 @@ void backlight_device_unregister(struct backlight_device *bd)
}
EXPORT_SYMBOL(backlight_device_unregister);
+#if IS_ENABLED(CONFIG_OF)
+static int of_parent_match(struct device *dev, void *data)
+{
+ return dev->parent && dev->parent->of_node = data;
+}
+
+struct backlight_device *of_find_backlight_by_node(struct device_node *node)
+{
+ struct device *dev;
+
+ dev = class_find_device(backlight_class, NULL, node, of_parent_match);
+
+ return dev ? to_backlight_device(dev) : NULL;
+}
+EXPORT_SYMBOL(of_find_backlight_by_node);
+#endif
+
static void __exit backlight_class_exit(void)
{
class_destroy(backlight_class);
diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index 5ffc6dd..11840e9 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -134,4 +134,14 @@ struct generic_bl_info {
void (*kick_battery)(void);
};
+#if IS_ENABLED(CONFIG_OF)
+struct backlight_device *of_find_backlight_by_node(struct device_node *node);
+#else
+static inline struct backlight_device *
+of_find_backlight_by_node(struct device_node *node)
+{
+ return NULL;
+}
+#endif
+
#endif
--
1.8.0
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox