summaryrefslogtreecommitdiff
path: root/src/theatre200.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/theatre200.c')
-rw-r--r--src/theatre200.c129
1 files changed, 71 insertions, 58 deletions
diff --git a/src/theatre200.c b/src/theatre200.c
index 9d95b7f..4b64884 100644
--- a/src/theatre200.c
+++ b/src/theatre200.c
@@ -1,5 +1,5 @@
/*************************************************************************************
- * $Id: theatre200.c,v 1.4 2005/08/28 18:00:23 bogdand Exp $
+ * $Id$
*
* Copyright (C) 2005 Bogdan D. bogdand@users.sourceforge.net
*
@@ -22,7 +22,17 @@
* otherwise to promote the sale, use or other dealings in this Software without prior written
* authorization from the author.
*
- * $Log: theatre200.c,v $
+ * $Log$
+ * Revision 1.6 2006/03/22 22:30:14 krh
+ * 2006-03-22 Kristian Høgsberg <krh@redhat.com>
+ *
+ * * src/theatre200.c: Convert use of xf86fopen() and other xf86
+ * wrapped libc symbols to use libc symbols directly. The xf86*
+ * versions aren't supposed to be used directly.
+ *
+ * * src/ *.c: Drop libc wrapper; don't include xf86_ansic.h and add
+ * includes now missing.
+ *
* Revision 1.4 2005/08/28 18:00:23 bogdand
* Modified the licens type from GPL to a X/MIT one
*
@@ -39,9 +49,11 @@
#include "config.h"
#endif
+#include <stdio.h>
+#include <string.h>
+
#include "xf86.h"
#include "generic_bus.h"
-#include "xf86_ansic.h"
#include "radeon_reg.h"
#include "radeon.h"
#include "theatre_reg.h"
@@ -62,24 +74,24 @@ static int dsp_load(TheatrePtr t, struct rt200_microc_data* microc_datap);
static CARD32 dsp_send_command(TheatrePtr t, CARD32 fb_scratch1, CARD32 fb_scratch0);
static CARD32 dsp_set_video_input_connector(TheatrePtr t, CARD32 connector);
-static CARD32 dsp_reset(TheatrePtr t);
+//static CARD32 dsp_reset(TheatrePtr t);
static CARD32 dsp_set_lowpowerstate(TheatrePtr t, CARD32 pstate);
static CARD32 dsp_set_video_standard(TheatrePtr t, CARD32 standard);
static CARD32 dsp_set_videostreamformat(TheatrePtr t, CARD32 format);
static CARD32 dsp_video_standard_detection(TheatrePtr t);
-static CARD32 dsp_get_signallockstatus(TheatrePtr t);
-static CARD32 dsp_get_signallinenumber(TheatrePtr t);
+//static CARD32 dsp_get_signallockstatus(TheatrePtr t);
+//static CARD32 dsp_get_signallinenumber(TheatrePtr t);
static CARD32 dsp_set_brightness(TheatrePtr t, CARD8 brightness);
static CARD32 dsp_set_contrast(TheatrePtr t, CARD8 contrast);
-static CARD32 dsp_set_sharpness(TheatrePtr t, int sharpness);
+//static CARD32 dsp_set_sharpness(TheatrePtr t, int sharpness);
static CARD32 dsp_set_tint(TheatrePtr t, CARD8 tint);
static CARD32 dsp_set_saturation(TheatrePtr t, CARD8 saturation);
static CARD32 dsp_set_video_scaler_horizontal(TheatrePtr t, CARD16 output_width, CARD16 horz_start, CARD16 horz_end);
static CARD32 dsp_set_video_scaler_vertical(TheatrePtr t, CARD16 output_height, CARD16 vert_start, CARD16 vert_end);
static CARD32 dsp_audio_mute(TheatrePtr t, CARD8 left, CARD8 right);
static CARD32 dsp_set_audio_volume(TheatrePtr t, CARD8 left, CARD8 right, CARD8 auto_mute);
-static CARD32 dsp_audio_detection(TheatrePtr t, CARD8 option);
+//static CARD32 dsp_audio_detection(TheatrePtr t, CARD8 option);
static CARD32 dsp_configure_i2s_port(TheatrePtr t, CARD8 tx_mode, CARD8 rx_mode, CARD8 clk_mode);
static CARD32 dsp_configure_spdif_port(TheatrePtr t, CARD8 state);
@@ -128,15 +140,15 @@ static int microc_load (char* micro_path, char* micro_type, struct rt200_microc_
if (micro_type == NULL)
return -1;
- file = xf86fopen(micro_path, "r");
+ file = fopen(micro_path, "r");
if (file == NULL) {
ERROR_0("Cannot open microcode file\n");
return -1;
}
- if (!xf86strcmp(micro_type, "BINARY"))
+ if (!strcmp(micro_type, "BINARY"))
{
- if (xf86fread(microc_headp, sizeof(struct rt200_microc_head), 1, file) != 1)
+ if (fread(microc_headp, sizeof(struct rt200_microc_head), 1, file) != 1)
{
ERROR("Cannot read header from file: %s\n", micro_path);
goto fail_exit;
@@ -151,23 +163,23 @@ static int microc_load (char* micro_path, char* micro_type, struct rt200_microc_
{
int ret;
- curr_seg = (struct rt200_microc_seg*)xf86malloc(sizeof(struct rt200_microc_seg));
+ curr_seg = (struct rt200_microc_seg*)Xalloc(sizeof(struct rt200_microc_seg));
if (curr_seg == NULL)
{
ERROR_0("Cannot allocate memory\n");
goto fail_exit;
}
- ret = xf86fread(&curr_seg->num_bytes, 4, 1, file);
- ret += xf86fread(&curr_seg->download_dst, 4, 1, file);
- ret += xf86fread(&curr_seg->crc_val, 4, 1, file);
+ ret = fread(&curr_seg->num_bytes, 4, 1, file);
+ ret += fread(&curr_seg->download_dst, 4, 1, file);
+ ret += fread(&curr_seg->crc_val, 4, 1, file);
if (ret != 3)
{
ERROR("Cannot read segment from microcode file: %s\n", micro_path);
goto fail_exit;
}
- curr_seg->data = (unsigned char*)xf86malloc(curr_seg->num_bytes);
+ curr_seg->data = (unsigned char*)Xalloc(curr_seg->num_bytes);
if (curr_seg->data == NULL)
{
ERROR_0("cannot allocate memory\n");
@@ -193,7 +205,7 @@ static int microc_load (char* micro_path, char* micro_type, struct rt200_microc_
curr_seg = seg_list;
while (curr_seg)
{
- if (xf86fread(curr_seg->data, curr_seg->num_bytes, 1, file) != 1)
+ if (fread(curr_seg->data, curr_seg->num_bytes, 1, file) != 1)
{
ERROR_0("Cannot read segment data\n");
goto fail_exit;
@@ -202,20 +214,20 @@ static int microc_load (char* micro_path, char* micro_type, struct rt200_microc_
curr_seg = curr_seg->next;
}
}
- else if (!xf86strcmp(micro_type, "ASCII"))
+ else if (!strcmp(micro_type, "ASCII"))
{
char tmp1[12], tmp2[12], tmp3[12], tmp4[12];
unsigned int ltmp;
- if ((xf86fgets(tmp1, 12, file) != NULL) &&
- (xf86fgets(tmp2, 12, file) != NULL) &&
- (xf86fgets(tmp3, 12, file) != NULL) &&
- xf86fgets(tmp4, 12, file) != NULL)
+ if ((fgets(tmp1, 12, file) != NULL) &&
+ (fgets(tmp2, 12, file) != NULL) &&
+ (fgets(tmp3, 12, file) != NULL) &&
+ fgets(tmp4, 12, file) != NULL)
{
- microc_headp->device_id = xf86strtoul(tmp1, NULL, 16);
- microc_headp->vendor_id = xf86strtoul(tmp2, NULL, 16);
- microc_headp->revision_id = xf86strtoul(tmp3, NULL, 16);
- microc_headp->num_seg = xf86strtoul(tmp4, NULL, 16);
+ microc_headp->device_id = strtoul(tmp1, NULL, 16);
+ microc_headp->vendor_id = strtoul(tmp2, NULL, 16);
+ microc_headp->revision_id = strtoul(tmp3, NULL, 16);
+ microc_headp->num_seg = strtoul(tmp4, NULL, 16);
}
else
{
@@ -230,20 +242,20 @@ static int microc_load (char* micro_path, char* micro_type, struct rt200_microc_
for (i = 0; i < microc_headp->num_seg; i++)
{
- curr_seg = (struct rt200_microc_seg*)xf86malloc(sizeof(struct rt200_microc_seg));
+ curr_seg = (struct rt200_microc_seg*)Xalloc(sizeof(struct rt200_microc_seg));
if (curr_seg == NULL)
{
ERROR_0("Cannot allocate memory\n");
goto fail_exit;
}
- if (xf86fgets(tmp1, 12, file) != NULL &&
- xf86fgets(tmp2, 12, file) != NULL &&
- xf86fgets(tmp3, 12, file) != NULL)
+ if (fgets(tmp1, 12, file) != NULL &&
+ fgets(tmp2, 12, file) != NULL &&
+ fgets(tmp3, 12, file) != NULL)
{
- curr_seg->num_bytes = xf86strtoul(tmp1, NULL, 16);
- curr_seg->download_dst = xf86strtoul(tmp2, NULL, 16);
- curr_seg->crc_val = xf86strtoul(tmp3, NULL, 16);
+ curr_seg->num_bytes = strtoul(tmp1, NULL, 16);
+ curr_seg->download_dst = strtoul(tmp2, NULL, 16);
+ curr_seg->crc_val = strtoul(tmp3, NULL, 16);
}
else
{
@@ -251,7 +263,7 @@ static int microc_load (char* micro_path, char* micro_type, struct rt200_microc_
goto fail_exit;
}
- curr_seg->data = (unsigned char*)xf86malloc(curr_seg->num_bytes);
+ curr_seg->data = (unsigned char*)Xalloc(curr_seg->num_bytes);
if (curr_seg->data == NULL)
{
ERROR_0("cannot allocate memory\n");
@@ -279,12 +291,12 @@ static int microc_load (char* micro_path, char* micro_type, struct rt200_microc_
for ( i = 0; i < curr_seg->num_bytes; i+=4)
{
- if (xf86fgets(tmp1, 12, file) == NULL)
+ if (fgets(tmp1, 12, file) == NULL)
{
ERROR_0("Cannot read from file\n");
goto fail_exit;
}
- ltmp = xf86strtoul(tmp1, NULL, 16);
+ ltmp = strtoul(tmp1, NULL, 16);
*(unsigned int*)(curr_seg->data + i) = ltmp;
}
@@ -300,7 +312,7 @@ static int microc_load (char* micro_path, char* micro_type, struct rt200_microc_
microc_datap->microc_seg_list = seg_list;
- xf86fclose(file);
+ fclose(file);
return 0;
fail_exit:
@@ -312,7 +324,7 @@ fail_exit:
curr_seg = curr_seg->next;
Xfree(prev_seg);
}
- xf86fclose(file);
+ fclose(file);
return -1;
}
@@ -364,12 +376,8 @@ static int dsp_load(TheatrePtr t, struct rt200_microc_data* microc_datap)
CARD32 tries = 0;
CARD32 result = 0;
CARD32 seg_id = 0;
-
int screen = t->VIP->scrnIndex;
- ScrnInfoPtr pScrn = xf86Screens[t->VIP->scrnIndex];
- RADEONInfoPtr info = RADEONPTR(pScrn);
- unsigned char *RADEONMMIO = info->MMIO;
-
+
DEBUG("Microcode: before everything: %x\n", data8);
if (RT_fifor(0x000, &data8))
@@ -619,6 +627,7 @@ static CARD32 dsp_set_video_input_connector(TheatrePtr t, CARD32 connector)
return result;
}
+#if 0
static CARD32 dsp_reset(TheatrePtr t)
{
CARD32 fb_scratch0 = 0;
@@ -633,6 +642,7 @@ static CARD32 dsp_reset(TheatrePtr t)
return result;
}
+#endif
static CARD32 dsp_set_lowpowerstate(TheatrePtr t, CARD32 pstate)
{
@@ -693,6 +703,7 @@ static CARD32 dsp_video_standard_detection(TheatrePtr t)
return result;
}
+#if 0
static CARD32 dsp_get_signallockstatus(TheatrePtr t)
{
CARD32 fb_scratch1 = 0;
@@ -726,6 +737,7 @@ static CARD32 dsp_get_signallinenumber(TheatrePtr t)
return result;
}
+#endif
static CARD32 dsp_set_brightness(TheatrePtr t, CARD8 brightness)
{
@@ -759,6 +771,7 @@ static CARD32 dsp_set_contrast(TheatrePtr t, CARD8 contrast)
return result;
}
+#if 0
static CARD32 dsp_set_sharpness(TheatrePtr t, int sharpness)
{
CARD32 fb_scratch1 = 0;
@@ -774,6 +787,7 @@ static CARD32 dsp_set_sharpness(TheatrePtr t, int sharpness)
return result;
}
+#endif
static CARD32 dsp_set_tint(TheatrePtr t, CARD8 tint)
{
@@ -873,6 +887,7 @@ static CARD32 dsp_set_audio_volume(TheatrePtr t, CARD8 left, CARD8 right, CARD8
return result;
}
+#if 0
static CARD32 dsp_audio_detection(TheatrePtr t, CARD8 option)
{
CARD32 fb_scratch1 = 0;
@@ -888,6 +903,7 @@ static CARD32 dsp_audio_detection(TheatrePtr t, CARD8 option)
return result;
}
+#endif
static CARD32 dsp_configure_i2s_port(TheatrePtr t, CARD8 tx_mode, CARD8 rx_mode, CARD8 clk_mode)
{
@@ -1441,6 +1457,7 @@ static void WriteRT_fld1 (TheatrePtr t, CARD32 dwReg, CARD32 dwData)
} /* WriteRT_fld ()... */
+#if 0
/****************************************************************************
* ReadRT_fld (CARD32 dwReg) *
* Function: Reads a register field within Rage Theatre *
@@ -1464,8 +1481,10 @@ static CARD32 ReadRT_fld1 (TheatrePtr t,CARD32 dwReg)
} /* ReadRT_fld ()... */
-#define WriteRT_fld(a,b) WriteRT_fld1(t, (a), (b))
#define ReadRT_fld(a) ReadRT_fld1(t,(a))
+#endif
+
+#define WriteRT_fld(a,b) WriteRT_fld1(t, (a), (b))
/****************************************************************************
@@ -1781,10 +1800,10 @@ void RT_SetConnector (TheatrePtr t, CARD16 wConnector, int tunerFlag)
t->wConnector = wConnector;
theatre_read(t, VIP_GPIO_CNTL, &data);
- xf86DrvMsg(t->VIP->scrnIndex,X_INFO,"VIP_GPIO_CNTL: %x\n", data);
+ xf86DrvMsg(t->VIP->scrnIndex,X_INFO,"VIP_GPIO_CNTL: %lx\n", data);
theatre_read(t, VIP_GPIO_INOUT, &data);
- xf86DrvMsg(t->VIP->scrnIndex,X_INFO,"VIP_GPIO_INOUT: %x\n", data);
+ xf86DrvMsg(t->VIP->scrnIndex,X_INFO,"VIP_GPIO_INOUT: %lx\n", data);
switch (wConnector)
{
@@ -1833,10 +1852,10 @@ void RT_SetConnector (TheatrePtr t, CARD16 wConnector, int tunerFlag)
}
theatre_read(t, VIP_GPIO_CNTL, &data);
- xf86DrvMsg(t->VIP->scrnIndex,X_INFO,"VIP_GPIO_CNTL: %x\n", data);
+ xf86DrvMsg(t->VIP->scrnIndex,X_INFO,"VIP_GPIO_CNTL: %lx\n", data);
theatre_read(t, VIP_GPIO_INOUT, &data);
- xf86DrvMsg(t->VIP->scrnIndex,X_INFO,"VIP_GPIO_INOUT: %x\n", data);
+ xf86DrvMsg(t->VIP->scrnIndex,X_INFO,"VIP_GPIO_INOUT: %lx\n", data);
dsp_configure_i2s_port(t, 0, 0, 0);
@@ -1989,7 +2008,7 @@ void DumpRageTheatreRegs(TheatrePtr t)
for(i=0;i<0x900;i+=4)
{
RT_regr(i, &data);
- xf86DrvMsg(t->VIP->scrnIndex, X_INFO, "register 0x%04x is equal to 0x%08x\n", i, data);
+ xf86DrvMsg(t->VIP->scrnIndex, X_INFO, "register 0x%04x is equal to 0x%08lx\n", i, data);
}
}
@@ -2189,21 +2208,18 @@ void DumpRageTheatreRegsByName(TheatrePtr t)
{ "Y_FALL_CNTL ", 0x01cc },
{ "Y_RISE_CNTL ", 0x01d0 },
{ "Y_SAW_TOOTH_CNTL ", 0x01d4 },
- {NULL, NULL}
+ {NULL, 0}
};
for(i=0; rt_reg_list[i].name!=NULL;i++){
RT_regr(rt_reg_list[i].addr, &data);
- xf86DrvMsg(t->VIP->scrnIndex, X_INFO, "register (0x%04x) %s is equal to 0x%08x\n", rt_reg_list[i].addr, rt_reg_list[i].name, data);
+ xf86DrvMsg(t->VIP->scrnIndex, X_INFO, "register (0x%04lx) %s is equal to 0x%08lx\n", rt_reg_list[i].addr, rt_reg_list[i].name, data);
}
}
void ResetTheatreRegsForNoTVout(TheatrePtr t)
{
- int i;
- CARD32 data;
-
RT_regw(VIP_CLKOUT_CNTL, 0x0);
RT_regw(VIP_HCOUNT, 0x0);
RT_regw(VIP_VCOUNT, 0x0);
@@ -2218,9 +2234,6 @@ void ResetTheatreRegsForNoTVout(TheatrePtr t)
void ResetTheatreRegsForTVout(TheatrePtr t)
{
- int i;
- CARD32 data;
-
/* RT_regw(VIP_HW_DEBUG, 0x200); */
/* RT_regw(VIP_INT_CNTL, 0x0);
RT_regw(VIP_GPIO_INOUT, 0x10090000);
@@ -2235,7 +2248,7 @@ void ResetTheatreRegsForTVout(TheatrePtr t)
RT_regw(VIP_VCOUNT, 0x151);
#endif
RT_regw(VIP_DFCOUNT, 0x01);
-/* RT_regw(VIP_CLOCK_SEL_CNTL, 0xb7); /* versus 0x237 <-> 0x2b7 */
+/* RT_regw(VIP_CLOCK_SEL_CNTL, 0xb7); versus 0x237 <-> 0x2b7 */
RT_regw(VIP_CLOCK_SEL_CNTL, 0x2b7); /* versus 0x237 <-> 0x2b7 */
RT_regw(VIP_VIN_PLL_CNTL, 0x60a6039);
/* RT_regw(VIP_PLL_CNTL1, 0xacacac74); */