On Fri, Sep 17, 2004 at 09:31:56PM -0400, Joshua Wise wrote:
> >It basically moves common/ipaq/h4000_lcd.c to mach-pxa/h4000/h4000_lcd.c
> >and adds some backlight and lcd controls.
> Hmmm, all the other _lcd modules are in common/ipaq. What is different
> about h4000?
see the thread here for the reasons:
http://www.handhelds.org/hypermail/kernel-discuss/current/0125.html
>
> Also, please diff between old h4000_lcd.c and new h4000_lcd.c...
> otherwise it's just a whole load of diff not showing any real
> differences (diff does not handle mv well)
>
your right, but how should i diff the other files that changed?
attached is just the diff between old h4000_lcd.c and new h4000_lcd.c
--- kernel26/arch/arm/common/ipaq/h4000_lcd.c 2004-06-30 21:31:22.000000000 -0600
+++ kernel26_h/arch/arm/mach-pxa/h4000/h4000_lcd.c 2004-09-17 18:41:33.000000000 -0600
@@ -1,102 +1,134 @@
/*
- * Hardware definitions for HP iPAQ Handheld Computers
- *
- * Copyright 2000-2003 Hewlett-Packard Company.
- *
* Use consistent with the GNU GPL is permitted,
* provided that this copyright notice is
* preserved in its entirety in all copies and derived works.
*
- * COMPAQ COMPUTER CORPORATION MAKES NO WARRANTIES, EXPRESSED OR IMPLIED,
- * AS TO THE USEFULNESS OR CORRECTNESS OF THIS CODE OR ITS
- * FITNESS FOR ANY PARTICULAR PURPOSE.
- *
- * Author: Jamey Hicks.
- *
* History:
*
- * 2004-03-01 Eddi De Pieri Adapted for h4000 using h3900_lcd.c and
- * Shawn's functions
- * 2004-??-?? Shawn Anderson Lcd hacking on h4000
- * 2003-05-14 Joshua Wise Adapted for the HP iPAQ H1900
- * 2002-08-23 Jamey Hicks Adapted for use with PXA250-based iPAQs
- * 2001-10-?? Andrew Christian Added support for iPAQ H3800
- * and abstracted EGPIO interface.
+ * 2004-03-01 Eddi De Pieri Adapted for h4000 using h3900_lcd.c
+ * 2004 Shawn Anderson Lcd hacking on h4000
+ * see h3900_lcd.c for more history.
*
*/
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/tty.h>
-#include <linux/sched.h>
-#include <linux/delay.h>
-#include <linux/pm.h>
-#include <linux/lcd.h>
-#include <linux/backlight.h>
-#include <linux/fb.h>
-#include <asm/arch/pxafb.h>
-
-#include <asm/mach-types.h>
-#include <asm/hardware.h>
-#include <asm/setup.h>
-#include <asm/mach/arch.h>
-#include <asm/arch/h3900_asic.h>
-#include <asm/arch/h4000-gpio.h>
-#include <asm/arch/ipaq.h>
+#include <linux/types.h>
+#include <asm/arch/hardware.h> /* for pxa-regs.h (__REG) */
+#include <asm/arch/pxa-regs.h> /* LCCR[0,1,2,3]* */
+#include <asm/arch/bitfield.h> /* for pxa-regs.h (Fld, etc) */
+#include <asm/arch/pxafb.h> /* pxafb_mach_info, set_pxa_fb_info */
+#include <asm/mach-types.h> /* machine_is_h4000 */
+#include <linux/lcd.h> /* lcd_device */
+#include <linux/backlight.h> /* backlight_device */
-#include "asic3_base.h"
+#include <asm/arch/h4000-gpio.h>
+#include <asm/arch/h4000-asic.h>
+#include <asm/hardware/ipaq-asic3.h>
-extern struct platform_device h4000_asic3;
+static int h4000_lcd_get_power(struct lcd_device *lm)
+{
+ /* Get the LCD panel power status (0: full on, 1..3: controller
+ * power on, flat panel power off, 4: full off) */
+
+ if (IPAQ_ASIC3_GPIO_C_OUT(H4000_ASIC3_VIRT) & GPIOC_LCD_5V_EN)
+ return 0;
+ else
+ return 4;
+}
-/*
- On screen enable, we get
-
- h3800_lcd_power_on(1)
- LCD controller starts
- h3800_lcd_enable(1)
-
- On screen disable, we get
-
- h3800_lcd_enable(0)
- LCD controller stops
- h3800_lcd_power_on(0)
-*/
+static int h4000_lcd_set_power(struct lcd_device *lm, int power)
+{
+ /* Enable or disable power to the LCD (0: on; 4: off) */
+
+ if (power == 0) {
+ //IPAQ_ASIC3_GPIO_B_OUT(H4000_ASIC3_VIRT) |= GPIOB_LCD_ON;
+ //IPAQ_ASIC3_GPIO_B_OUT(H4000_ASIC3_VIRT) |= GPIOB_LCD_PCI;
+ //IPAQ_ASIC3_GPIO_C_OUT(H4000_ASIC3_VIRT) |= GPIOC_LCD_N3V_EN;
+ IPAQ_ASIC3_GPIO_C_OUT(H4000_ASIC3_VIRT) |= GPIOC_LCD_5V_EN;
+ //IPAQ_ASIC3_GPIO_C_OUT(H4000_ASIC3_VIRT) |= GPIOC_LCD_3V3_ON;
+ } else {
+ //IPAQ_ASIC3_GPIO_B_OUT(H4000_ASIC3_VIRT) &= ~GPIOB_LCD_ON;
+ //IPAQ_ASIC3_GPIO_B_OUT(H4000_ASIC3_VIRT) &= ~GPIOB_LCD_PCI;
+ //IPAQ_ASIC3_GPIO_C_OUT(H4000_ASIC3_VIRT) &= ~GPIOC_LCD_N3V_EN;
+ IPAQ_ASIC3_GPIO_C_OUT(H4000_ASIC3_VIRT) &= ~GPIOC_LCD_5V_EN;
+ //IPAQ_ASIC3_GPIO_C_OUT(H4000_ASIC3_VIRT) &= ~GPIOC_LCD_3V3_ON;
+ }
+
+ return 0;
+}
-static int h4000_lcd_set_power( struct lcd_device *lm, int level )
+static int h4000_lcd_get_contrast(struct lcd_device *ld)
{
- printk("%s: \n", __FUNCTION__);
+ /* Get the current contrast setting (0-max_contrast) */
+//DBG*/ printk("%s: not implemented yet\n", __FUNCTION__);
return 0;
}
-static int h4000_lcd_get_power( struct lcd_device *lm )
+static int h4000_lcd_set_contrast(struct lcd_device *ld, int contrast)
{
- printk("%s: \n", __FUNCTION__);
+ /* Set LCD panel contrast */
+//DBG*/ printk("%s: not implemented yet\n", __FUNCTION__);
return 0;
}
-static int h4000_backlight_set_power (struct backlight_device *bl, int level)
+static int h4000_bl_get_power(struct backlight_device *bl)
{
- printk("%s: backlight o%s\n", __FUNCTION__, level ? "ff" : "n");
- if (level < 1) {
- // also CKEN[0] = 1 turns on PWM clock, mabey do that here too.
- GAFR0_U |= 0x2;
- printk("%s: GAFR0_U |= 0x2, GAFR0_U=0x%x\n", __FUNCTION__, GAFR0_U);
- printk("%s: CKEN=0x%x\n", __FUNCTION__, CKEN);
- }
- else
- GAFR0_U &= ~(0x2);
+ /* Get the power status (0: on, 1..3: power saving modes; 4: off) */
+ // GPIO_NR_H4000_LCD_PWM, CKEN0_PWM0, GPIOB_BACKLIGHT_POWER_ON
+ if (GAFR0_U & 0x2)
+ return 0;
+ else
+ return 4;
+}
+
+static int h4000_bl_set_power(struct backlight_device *bl, int power)
+{
+ /* Enable or disable power to the LCD (0: on; 4: off) */
- return 0;
+ if (power < 1) {
+ IPAQ_ASIC3_GPIO_B_OUT(H4000_ASIC3_VIRT) |=
+ GPIOB_BACKLIGHT_POWER_ON;
+ pxa_gpio_mode(GPIO16_PWM0_MD);
+ pxa_set_cken(CKEN0_PWM0, 1);
+ } else {
+ IPAQ_ASIC3_GPIO_B_OUT(H4000_ASIC3_VIRT) &
+ ~GPIOB_BACKLIGHT_POWER_ON;
+ pxa_set_cken(CKEN0_PWM0, 0);
+ }
+ return 0;
}
-static int h4000_backlight_get_power (struct backlight_device *bl)
+static int h4000_bl_get_brightness(struct backlight_device *bd)
{
- printk("%s: \n", __FUNCTION__);
- if (GAFR0_U & 0x2)
- return 0;
+ /* Get current backlight brightness */
+ u32 x, y;
+
+ x = PWM_PWDUTY0 & 0x3ff;
+ y = PWM_PERVAL0 & 0x3ff;
+ // To avoid division, we'll approximate y to nearest 2^n-1.
+ // PocketPC is using 0xfe as PERVAL0 and we're using 0x3ff.
+ x <<= (10 - fls (y));
+ return x;
+}
+
+static int h4000_bl_set_brightness(struct backlight_device *bd, int brightness)
+{
+ /* Set backlight brightness (0..max_brightness) */
+ if (brightness > 0x3ff)
+ brightness = 0x3ff;
+
+ /* LCD brightness is driven by PWM0.
+ * We'll set the pre-scaler to 8, and the period to 1024, this
+ * means the backlight refresh rate will be 3686400/(8*1024) =
+ * 450 Hz which is quite enough.
+ */
+ PWM_CTRL0 = 7; /* pre-scaler */
+ PWM_PWDUTY0 = brightness; /* duty cycle */
+ PWM_PERVAL0 = 0x3ff; /* period */
+ if (brightness)
+ pxa_set_cken(CKEN0_PWM0, 1);
else
- return 4;
+ pxa_set_cken(CKEN0_PWM0, 0);
+ return 0;
}
/*
@@ -110,69 +142,87 @@
* HSP=0x1, VSP=0x1, API=0x0, ACD=0x0, PCD=0x8
*/
-static struct pxafb_mach_info h4000_fb_info = {
- .pixclock = 0,
+static struct pxafb_mach_info sony_acx502bmu __initdata= {
+ .pixclock = 171521, // (160756 > 180849)
.bpp = 16, // BPP (0x4 == 16bits)
.xres = 240, // PPL + 1
.yres = 320, // LPP + 1
.hsync_len = 4, // HSW + 1
.vsync_len = 1, // VSW + 1
.left_margin = 20, // BLW + 1
- .upper_margin = 8, // BFW + 1
+ .upper_margin = 8, // BFW + 1
.right_margin = 8, // ELW + 1
.lower_margin = 9, // EFW + 1
- .sync = 0,
- .lccr0 = (LCCR0_LDM | LCCR0_SFM | LCCR0_IUM | LCCR0_EFM |
- LCCR0_PAS | LCCR0_QDM | LCCR0_BM | LCCR0_OUM),
-#if 0
- .lccr3 = (LCCR3_HorSnchL | LCCR3_VrtSnchL | LCCR3_16BPP |
- LCCR3_PCP | /*PCD */ 0x8)
-#endif
+ .sync = 0,
+ .lccr0 = LCCR0_Act | LCCR0_Sngl | LCCR0_Color,
+ .lccr3 = LCCR3_OutEnH | LCCR3_PixFlEdg | LCCR3_Acb(0),
+
+ //.pxafb_backlight_power = ,
+ //.pxafb_lcd_power = ,
};
-static struct lcd_properties h4000_lcd_properties = {
- .owner = THIS_MODULE,
- .set_power = h4000_lcd_set_power,
- .get_power = h4000_lcd_get_power,
+struct lcd_properties h4000_lcd_properties =
+{
+ .owner = THIS_MODULE,
+ .get_power = h4000_lcd_get_power,
+ .set_power = h4000_lcd_set_power,
+ .max_contrast = 7,
+ .get_contrast = h4000_lcd_get_contrast,
+ .set_contrast = h4000_lcd_set_contrast,
};
-static struct backlight_properties h4000_backlight_properties = {
- .owner = THIS_MODULE,
- .set_power = h4000_backlight_set_power,
- .get_power = h4000_backlight_get_power,
+static struct backlight_properties h4000_bl_properties =
+{
+ .owner = THIS_MODULE,
+ .get_power = h4000_bl_get_power,
+ .set_power = h4000_bl_set_power,
+ .max_brightness = 0x3ff,
+ .get_brightness = h4000_bl_get_brightness,
+ .set_brightness = h4000_bl_set_brightness,
};
static struct lcd_device *pxafb_lcd_device;
static struct backlight_device *pxafb_backlight_device;
-static int
-h4000_lcd_init (void)
+static int h4000_lcd_init(void)
{
int rc = 0;
-
- if (! machine_is_h4000 ())
+
+ if (!machine_is_h4000())
return -ENODEV;
- rc = lcd_device_register("pxafb", (void*)&h4000_fb_info, &h4000_lcd_properties,
- &pxafb_lcd_device);
- if (rc)
- return rc;
- rc = backlight_device_register("pxafb", NULL, &h4000_backlight_properties,
- &pxafb_backlight_device);
-
+ //should we have to run both set_pxa_fb_info and lcd_device_register?
+ set_pxa_fb_info(&sony_acx502bmu);
+
+ rc = lcd_device_register("pxafb", (void*)&sony_acx502bmu,
+ &h4000_lcd_properties, &pxafb_lcd_device);
+ if (rc) {
+ printk("%s: lcd_device_register failed (%d)\n",__FUNCTION__,rc);
+ return rc;
+ }
+
+ rc = backlight_device_register("pxafb", NULL,
+ &h4000_bl_properties, &pxafb_backlight_device);
+ if (rc) {
+ printk("%s: backlight_device_register failed (%d)\n",
+ __FUNCTION__,rc);
+ return rc;
+ }
return rc;
}
-static void
-h4000_lcd_exit (void)
+static void h4000_lcd_exit(void)
{
- lcd_device_unregister(pxafb_lcd_device);
+ lcd_device_unregister(pxafb_lcd_device);
backlight_device_unregister(pxafb_backlight_device);
}
-module_init (h4000_lcd_init);
-module_exit (h4000_lcd_exit);
+module_init(h4000_lcd_init);
+module_exit(h4000_lcd_exit);
-MODULE_AUTHOR(" ");
+MODULE_AUTHOR("h4000 port team h4100-port@handhelds.org");
MODULE_DESCRIPTION("Framebuffer driver for iPAQ H4000");
MODULE_LICENSE("GPL");
+
+/* vim: set ts=8 tw=80 shiftwidth=8 noet: */
+
Received on Fri Sep 17 21:51:57 2004
This archive was generated by hypermail 2.1.8 : Fri Sep 17 2004 - 21:52:35 EDT