[PATCH radeontool 3/5] Only print current status in usage() if we are root
Tormod Volden
lists.tormod at gmail.com
Fri Dec 2 13:32:04 PST 2011
From: Tormod Volden <debian.tormod at gmail.com>
Otherwise print "unknown" for dac and backlight status.
Signed-off-by: Tormod Volden <debian.tormod at gmail.com>
---
radeontool.c | 24 ++++++++++++++++++------
1 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/radeontool.c b/radeontool.c
index cb7f051..f9710fc 100644
--- a/radeontool.c
+++ b/radeontool.c
@@ -26,13 +26,15 @@
#include "radeon_reg.h"
+static void map_radeon_cntl_mem(void);
+
int debug = 0;
int skip = 0;
/* *radeon_cntl_mem is mapped to the actual device's memory mapped control area. */
/* Not the address but what it points to is volatile. */
struct pci_device *avivo_device = NULL;
-unsigned char * volatile radeon_cntl_mem;
+unsigned char * volatile radeon_cntl_mem = NULL;
int ctrl_region = -1, fb_region = -1;
unsigned char * volatile fb_mem;
unsigned char * volatile ctrl_mem;
@@ -141,13 +143,24 @@ static void radeon_set_mcind(unsigned long offset, const char *name,
static void usage(void)
{
+ const char *dac_status = "unknown";
+ const char *light_status = "unknown";
+
+ if (geteuid() == 0) {
+ if (radeon_cntl_mem == NULL)
+ map_radeon_cntl_mem();
+ dac_status = (radeon_get(RADEON_DAC_CNTL, "RADEON_DAC_CNTL")
+ & RADEON_DAC_PDWN) ? "off" : "on";
+ light_status = (radeon_get(RADEON_LVDS_GEN_CNTL, "RADEON_LVDS_GEN_CNTL")
+ & RADEON_LVDS_ON) ? "on" : "off";
+ }
fprintf(stderr,"usage: radeontool [options] [command]\n");
fprintf(stderr," --debug - show a little debug info\n");
fprintf(stderr," --skip=1 - use the second radeon card\n");
- fprintf(stderr," dac [on|off] - power down the external video outputs (%s)\n",
- (radeon_get(RADEON_DAC_CNTL,"RADEON_DAC_CNTL")&RADEON_DAC_PDWN)?"off":"on");
- fprintf(stderr," light [on|off] - power down the backlight (%s)\n",
- (radeon_get(RADEON_LVDS_GEN_CNTL,"RADEON_LVDS_GEN_CNTL")&RADEON_LVDS_ON)?"on":"off");
+ fprintf(stderr," dac [on|off] - power down the external "
+ "video outputs (%s)\n", dac_status);
+ fprintf(stderr," light [on|off] - power down the backlight "
+ "(%s)\n", light_status);
fprintf(stderr," stretch [on|off|vert|horiz|auto|manual] - stretching for resolution mismatch \n");
fprintf(stderr," regs - show a listing of some random registers\n");
fprintf(stderr," regmatch <pattern> - show registers matching wildcard pattern\n");
@@ -2954,7 +2967,6 @@ int main(int argc,char *argv[])
if (geteuid() != 0)
fprintf(stderr, "Warning: Need root privileges to access hardware\n");
if(argc == 1) {
- map_radeon_cntl_mem();
usage();
}
while (argc >= 2) {
--
1.7.5.4
More information about the xorg-driver-ati
mailing list