From: Josh Huber <huberj@WPI.EDU>
To: linuxppc-dev@lists.linuxppc.org
Subject: LCD stretching partially working!
Date: Thu, 28 Oct 1999 12:46:07 -0400 (EDT) [thread overview]
Message-ID: <14360.32207.88755.452600@cpu.wpi.edu> (raw)
[-- Attachment #1: message body text --]
[-- Type: text/plain, Size: 1622 bytes --]
I'm working on getting hardware stretching for the Rage LT chipset
(wallst. & lombard at least), and have got this far:
In console mode:
1. Stretching in the vertical direction works
2. stretching in the horiz direction works
3. doing both at the same time appears to work...except for a little
screen flicker. (what could cause this?)
In X, strange things happen, to say the least.
Perhaps someone with a little more knowledge with both X and the ATI
video driver would like to take a look at my code...try it out, etc?
Attached are the following files:
aty.h.diff /usr/src/linux/drivers/video/aty.h patch
atyfb.c.diff /usr/src/linux/drivers/video/atyfb.c patch
lcdtest.c user space program for manipulating the registers
The driver files must be patched (they add a couple ioctls for
accessing the LCD_INDEX and LCD_DATA registers), the kernel
recompiled...just restart after putting the new kernel in.
BTW, the .diff files are against paul's latest stable tree (2.2.13) as
of 2 days ago. They'll probably work on an older one too.
Change line 80 and 81 in lcdtest.c to either 0 or 1 to enable/disable
stretching in either the H or V direction. lcdtest.c will print out
the relevant registers (3 of them), enable stretching, wait for 3
seconds, and switch back to the previous values. This is good when
your whole screen gets messed up.
To really try this out, first do:
# fbset 640x480-60
to switch modes, then run the lcdtest program.
right now it's hard-coded for both a 1024x756 LCD panel, and a 640x480
target res.
If you have any ideas, etc, feel free to email me or the list (I'm on
it)
Josh
[-- Attachment #2: aty.h.diff --]
[-- Type: application/octet-stream, Size: 1001 bytes --]
--- aty.h.old Tue Oct 26 20:43:50 1999
+++ aty.h Thu Oct 28 00:57:14 1999
@@ -962,4 +962,29 @@
#define PWR_MGT_STATUS_MASK 0xC0000000
#define PWR_MGT_STATUS_SUSPEND 0x80000000
+/* LCD Panel configuration registers */
+/* added by Josh Huber <huberj@wpi.edu> */
+
+#define LCD_INDEX 0x00A4 /* Dword offset 0_29 */
+
+#define LCD_DATA 0x00A8 /* Dword offset 0_2A */
+
+#define IDX_CONFIG_PANEL 0
+#define IDX_LCD_GEN_CTRL 1
+#define IDX_DSTN_CONTROL 2
+#define IDX_HFB_PITCH_ADDR 3
+#define IDX_HORZ_STRETCHING 4
+#define IDX_VERT_STRETCHING 5
+#define IDX_EXT_VERT_STRETCH 6
+#define IDX_LT_GIO 7
+#define IDX_POWER_MANAGEMENT 8
+#define IDX_ZVGPIO 9
+
+/* LCD Panel Testing IOCTLs */
+#define ATY_IOC_MAGIC 'A'
+#define IDX_REG_SET _IOW(ATY_IOC_MAGIC, 1, __u32)
+#define IDX_REG_GET _IOR(ATY_IOC_MAGIC, 2, __u32)
+#define LCD_REG_SET _IOW(ATY_IOC_MAGIC, 3, __u32)
+#define LCD_REG_GET _IOR(ATY_IOC_MAGIC, 4, __u32)
+
#endif /* REGMACH64_H */
[-- Attachment #3: atyfb.c.diff --]
[-- Type: application/octet-stream, Size: 1690 bytes --]
--- atyfb.c.old Tue Oct 26 20:43:57 1999
+++ atyfb.c Thu Oct 28 01:00:40 1999
@@ -72,8 +72,8 @@
#ifdef __sparc__
#include <asm/pbm.h>
#include <asm/fbio.h>
-#include <asm/uaccess.h>
#endif
+#include <asm/uaccess.h>
#include <video/fbcon.h>
#include <video/fbcon-cfb8.h>
@@ -2235,7 +2235,34 @@
}
return 0;
#else
- return -EINVAL;
+ u32 reg;
+ struct fb_info_aty *fb = (struct fb_info_aty *)info;
+
+ switch(cmd) {
+ case IDX_REG_GET:
+ reg = aty_ld_le32(LCD_INDEX, fb);
+ copy_to_user_ret((u32 *)arg, ®, sizeof(u32), -EFAULT);
+ break;
+
+ case IDX_REG_SET:
+ copy_from_user_ret(®, (u32 *)arg, sizeof(u32), -EFAULT);
+ aty_st_le32(LCD_INDEX, reg, fb);
+ break;
+
+ case LCD_REG_GET:
+ reg = aty_ld_le32(LCD_DATA, fb);
+ copy_to_user_ret((u32 *)arg, ®, sizeof(u32), -EFAULT);
+ break;
+
+ case LCD_REG_SET:
+ copy_from_user_ret(®, (u32 *)arg, sizeof(u32), -EFAULT);
+ aty_st_le32(LCD_DATA, reg, fb);
+ break;
+
+ default:
+ return -EINVAL;
+ }
+ return 0;
#endif
}
@@ -2465,6 +2492,7 @@
return 0;
} else
printk("atyfb: %s [0x%04x rev 0x%02x] ", chipname, Gx, Rev);
+
if ((Gx == GX_CHIP_ID) || (Gx == CX_CHIP_ID)) {
info->bus_type = (aty_ld_le32(CONFIG_STAT0, info) >> 0) & 0x07;
info->ram_type = (aty_ld_le32(CONFIG_STAT0, info) >> 3) & 0x07;
@@ -2671,6 +2699,7 @@
for (i = 0; i < 16; i++)
printk(" %02x", aty_ld_pll(i, info));
printk("\n");
+
}
#endif
@@ -3017,6 +3046,8 @@
info->ati_regbase_phys += 0xc00;
info->ati_regbase += 0xc00;
+
+
/*
* Enable memory-space accesses using config-space
[-- Attachment #4: lcdtest.c --]
[-- Type: application/octet-stream, Size: 4030 bytes --]
/* Rage LT Pro LCD stretch test utility */
/* Josh Huber <huberj@wpi.edu> */
#include "/usr/src/linux/drivers/video/aty.h"
#include <linux/ioctl.h>
#include <stdio.h>
#include <linux/types.h>
struct IDX {
unsigned int empty:21;
unsigned int crt2_dis:1;
unsigned int src:1;
unsigned int lcd_dis:1;
unsigned int empty2:4;
unsigned int index:4;
};
struct HS {
unsigned int enable:1;
unsigned int mode:1;
unsigned int empty:11;
unsigned int loop_stretch:3;
unsigned int ratio:16;
};
struct VS {
unsigned int enable:1;
unsigned int use:1;
unsigned int r2:10;
unsigned int r1:10;
unsigned int r0:10;
};
struct EVS {
unsigned int empty:7;
unsigned int vsync:1;
unsigned int fp_pos:1;
unsigned int vert_ratio:1;
unsigned int size:11;
unsigned int mode:1;
unsigned int ratio:10;
};
struct IDX idx, idx_old;
struct EVS evs, evs_old;
struct VS vs, vs_old;
struct HS hs, hs_old;
char *int2bin(unsigned int);
void print_regs(void);
void set_regs(void);
void get_regs(void);
int main(int argc, char *argv[]) {
get_regs();
idx_old = idx;
evs_old = evs;
vs_old = vs;
hs_old = hs;
printf("Setting values...\n");
hs.ratio = 2560;
hs.mode = 1;
evs.mode = 1;
vs.use = 1;
vs.r0 = 640;
evs.size = 767;
if(argc > 1) {
hs.ratio = atoi(argv[1]);
}
print_regs();
printf("Enabling stretch registers...\n");
hs.enable = 1;
vs.enable = 1;
set_regs();
print_regs();
printf("Sleeping...\n");
hs = hs_old;
vs = vs_old;
evs = evs_old;
sleep(3);
set_regs();
printf("Previous register values restored!\n");
}
void get_regs(void) {
int fd;
fd = open("/dev/fb0", 0);
if(fd < 0) {
perror("open /dev/fb0");
exit(1);
}
ioctl(fd, IDX_REG_GET, &idx);
idx.index = IDX_HORZ_STRETCHING;
ioctl(fd, IDX_REG_SET, &idx);
/* hopefully this won't crash the machine... */
if(ioctl(fd, LCD_REG_GET, &hs) == -1) {
perror("ioctl LCD_REG_GET");
close(fd);
exit(1);
}
idx.index = IDX_VERT_STRETCHING;
ioctl(fd, IDX_REG_SET, &idx);
if(ioctl(fd, LCD_REG_GET, &vs) == -1) {
perror("ioctl LCD_REG_GET");
close(fd);
exit(1);
}
idx.index = IDX_EXT_VERT_STRETCH;
ioctl(fd, IDX_REG_SET, &idx);
if(ioctl(fd, LCD_REG_GET, &evs) == -1) {
perror("ioctl LCD_REG_GET");
close(fd);
exit(1);
}
close(fd);
}
void print_regs(void) {
unsigned int ai;
/* now display the information */
memcpy(&ai, &hs, sizeof(struct HS));
printf("%s\nHORZ_STRETCHING:\n", int2bin(ai));
printf("\tHORZ_STRETCH_EN: %d\n", hs.enable);
printf("\tHORZ_STRETCH_MODE: %d\n", hs.mode);
printf("\tLOOP_STRETCH: %d\n", hs.loop_stretch);
printf("\tHORZ_STRETCH_RATIO: %d\n\n", hs.ratio);
memcpy(&ai, &vs, sizeof(struct VS));
printf("%s\nVERT_STRETCHING:\n", int2bin(ai));
printf("\tVERT_STRETCH_EN: %d\n", vs.enable);
printf("\tUSE_RATIO0: %d\n", vs.use);
printf("\tVERT_STRETCH_RATIO2: %d\n", vs.r2);
printf("\tVERT_STRETCH_RATIO1: %d\n", vs.r1);
printf("\tVERT_STRETCH_RATIO0: %d\n\n", vs.r0);
memcpy(&ai, &evs, sizeof(struct EVS));
printf("%s\nEXT_VERT_STRETCH:\n", int2bin(ai));
printf("\tUSE_AUTO_LCD_VSYNC: %s\n", int2bin(evs.vsync));
printf("\tUSE_AUTO_FP_POS: %s\n", int2bin(evs.fp_pos));
printf("\tAUTO_VERT_RATIO: %s\n", int2bin(evs.vert_ratio));
printf("\tVERT_PANEL_SIZE: %d\n", evs.size);
printf("\tVERT_STRETCH_MODE: %s\n", int2bin(evs.mode));
printf("\tVERT_STRETCH_RATIO3: %s\n\n", int2bin(evs.ratio));
}
void set_regs(void) {
int fd;
fd = open("/dev/fb0", 0);
if(fd < 0) {
perror("open /dev/fb0");
exit(1);
}
sync();
ioctl(fd, IDX_REG_GET, &idx);
idx.index = IDX_HORZ_STRETCHING;
ioctl(fd, IDX_REG_SET, &idx);
ioctl(fd, LCD_REG_SET, &hs);
idx.index = IDX_VERT_STRETCHING;
ioctl(fd, IDX_REG_SET, &idx);
ioctl(fd, LCD_REG_SET, &vs);
idx.index = IDX_EXT_VERT_STRETCH;
ioctl(fd, IDX_REG_SET, &idx);
ioctl(fd, LCD_REG_SET, &evs);
close(fd);
}
char *int2bin(unsigned int i) {
char *str = (char *)malloc(sizeof(char) * 255);
int n = 0;
for(;;) {
str[n++] = (i%2)+'0';
i /= 2;
if(i==0) break;
}
str[n] = '\0';
return str;
}
next reply other threads:[~1999-10-28 16:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-10-28 16:46 Josh Huber [this message]
1999-10-28 20:46 ` LCD stretching partially working! Geert Uytterhoeven
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=14360.32207.88755.452600@cpu.wpi.edu \
--to=huberj@wpi.edu \
--cc=linuxppc-dev@lists.linuxppc.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.