Hi,
The attached patch examines the kernel command line passed to
qemu-system-arm, 
and changes the clcd register to match the CLCD video modes currently
supported by then linux kernel:

 video=640x480
 video=240x320
 video=320x240

Perhaps someone has a more general or a better way of doing this.
Before this patch, the only ways I found to change the video mode of
qemu versatile was to
change the default clcd mode in the kernel code or change the clcd mode
in the qemu code.

The patch applies to 0.9.0 and current CVS.

-Don Mahurin
diff -ru qemu-0.9.0/hw/arm_sysctl.c qemu-0.9.0-arm-vga/hw/arm_sysctl.c
--- qemu-0.9.0/hw/arm_sysctl.c	2007-02-05 15:01:54.000000000 -0800
+++ qemu-0.9.0-arm-vga/hw/arm_sysctl.c	2007-03-08 11:56:48.000000000 -0800
@@ -22,6 +22,7 @@
     uint32_t flags;
     uint32_t nvflags;
     uint32_t resetlevel;
+    uint32_t clcd;
 } arm_sysctl_state;
 
 static uint32_t arm_sysctl_read(void *opaque, target_phys_addr_t offset)
@@ -65,7 +66,7 @@
     case 0x4c: /* FLASH */
         return 0;
     case 0x50: /* CLCD */
-        return 0x1000;
+        return s->clcd;
     case 0x54: /* CLCDSER */
         return 0;
     case 0x58: /* BOOTCS */
@@ -157,6 +158,8 @@
         break;
     case 0x4c: /* FLASH */
     case 0x50: /* CLCD */
+        s->clcd = val;
+        break;
     case 0x54: /* CLCDSER */
     case 0x64: /* DMAPSR0 */
     case 0x68: /* DMAPSR1 */
@@ -190,6 +193,35 @@
    arm_sysctl_write
 };
 
+static int arm_clcd = -1;
+
+void arm_sysctl_parse_video_preinit(const char *kernel_cmdline)
+{
+#ifndef NO_ARM_VIDEO_PARSE
+    int video = -1;
+    char *video_cmd;
+
+    video_cmd = strstr(kernel_cmdline, "video=");
+    if(video_cmd != NULL)
+    {
+        int video_cmd_len;
+        char *end_video_cmd;
+        video_cmd+=6;
+        end_video_cmd = strchr(video_cmd, ' ');
+        if(end_video_cmd != NULL)
+            video_cmd_len = (int) (end_video_cmd - video_cmd);
+        else
+            video_cmd_len = strlen(video_cmd);
+        if(!strncmp(video_cmd, "320x240", video_cmd_len))
+            arm_clcd = 0x0;
+        else if(!strncmp(video_cmd, "240x320", video_cmd_len))
+            arm_clcd = 0x700;
+        else if(!strncmp(video_cmd, "640x480", video_cmd_len))
+            arm_clcd = 0x1f00;
+    }
+#endif
+}
+
 void arm_sysctl_init(uint32_t base, uint32_t sys_id)
 {
     arm_sysctl_state *s;
@@ -200,6 +232,7 @@
         return;
     s->base = base;
     s->sys_id = sys_id;
+    s->clcd = (arm_clcd >= 0) ? arm_clcd : 0x1000; 
     iomemtype = cpu_register_io_memory(0, arm_sysctl_readfn,
                                        arm_sysctl_writefn, s);
     cpu_register_physical_memory(base, 0x00000fff, iomemtype);
diff -ru qemu-0.9.0/hw/versatilepb.c qemu-0.9.0-arm-vga/hw/versatilepb.c
--- qemu-0.9.0/hw/versatilepb.c	2007-02-05 15:01:54.000000000 -0800
+++ qemu-0.9.0-arm-vga/hw/versatilepb.c	2007-03-08 11:56:34.000000000 -0800
@@ -171,6 +171,10 @@
     /* SDRAM at address zero.  */
     cpu_register_physical_memory(0, ram_size, IO_MEM_RAM);
 
+#ifndef NO_ARM_VIDEO_PARSE
+    arm_sysctl_parse_video_preinit(kernel_cmdline);
+#endif
+
     arm_sysctl_init(0x10000000, 0x41007004);
     pic = arm_pic_init_cpu(env);
     pic = pl190_init(0x10140000, pic, ARM_PIC_CPU_IRQ, ARM_PIC_CPU_FIQ);
diff -ru qemu-0.9.0/vl.h qemu-0.9.0-arm-vga/vl.h
--- qemu-0.9.0/vl.h	2007-02-05 15:01:54.000000000 -0800
+++ qemu-0.9.0-arm-vga/vl.h	2007-03-08 11:56:24.000000000 -0800
@@ -1327,6 +1327,7 @@
 void icp_pit_init(uint32_t base, void *pic, int irq);
 
 /* arm_sysctl.c */
+void arm_sysctl_parse_video_preinit(const char *kernel_cmdline);
 void arm_sysctl_init(uint32_t base, uint32_t sys_id);
 
 /* arm_gic.c */
_______________________________________________
Qemu-devel mailing list
Qemu-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/qemu-devel

Reply via email to