[PATCH r128] Improve handling of monitor and output types
Alex Deucher
alexdeucher at gmail.com
Wed Aug 6 09:21:44 PDT 2014
On Mon, Aug 4, 2014 at 6:32 PM, Connor Behan <connor.behan at gmail.com> wrote:
> Checking for OUTPUT_DVI is not the same as checking for MT_DFP. There
> might be r128 cards with a DVI-I connector. These have the capability of
> driving an MT_CRT so we now check the monitor type before programming
> DAC or TMDS registers.
>
> This patch also removes R128ConnectorType and R128BIOSConnector because
> they were not doing much. These data structures are more useful for the
> radeon driver where there is a much wider range of cards.
>
> Signed-off-by: Connor Behan <connor.behan at gmail.com>
Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
> ---
> src/r128.h | 1 -
> src/r128_driver.c | 2 +-
> src/r128_output.c | 160 ++++++++++++++++++++----------------------------------
> src/r128_probe.h | 16 ------
> 4 files changed, 60 insertions(+), 119 deletions(-)
>
> diff --git a/src/r128.h b/src/r128.h
> index 6df1b51..d8748b7 100644
> --- a/src/r128.h
> +++ b/src/r128.h
> @@ -504,7 +504,6 @@ typedef struct {
> Bool DDC;
>
> Bool VGAAccess;
> - R128BIOSConnector BiosConnector[R128_MAX_BIOS_CONNECTOR];
>
> /****** Added for dualhead support *******************/
> BOOL IsSecondary; /* second Screen */
> diff --git a/src/r128_driver.c b/src/r128_driver.c
> index c541bfa..ce38b4e 100644
> --- a/src/r128_driver.c
> +++ b/src/r128_driver.c
> @@ -3225,7 +3225,7 @@ void R128InitRMXRegisters(R128SavePtr orig, R128SavePtr save,
> save->fp_h_sync_strt_wid = save->crtc_h_sync_strt_wid;
> save->fp_v_sync_strt_wid = save->crtc_v_sync_strt_wid;
>
> - if (r128_output->type != OUTPUT_DVI && r128_output->type != OUTPUT_LVDS)
> + if (r128_output->MonType != MT_DFP && r128_output->MonType != MT_LCD)
> return;
>
> if (r128_output->PanelXRes == 0 || r128_output->PanelYRes == 0) {
> diff --git a/src/r128_output.c b/src/r128_output.c
> index 7bb2e2a..757ef9b 100644
> --- a/src/r128_output.c
> +++ b/src/r128_output.c
> @@ -90,21 +90,21 @@ static void r128_mode_set(xf86OutputPtr output, DisplayModePtr mode, DisplayMode
> if (r128_crtc->crtc_id == 0)
> R128InitRMXRegisters(&info->SavedReg, &info->ModeReg, output, adjusted_mode);
>
> - if (r128_output->type == OUTPUT_DVI)
> + if (r128_output->MonType == MT_DFP)
> R128InitFPRegisters(&info->SavedReg, &info->ModeReg, output);
> - else if (r128_output->type == OUTPUT_LVDS)
> + else if (r128_output->MonType == MT_LCD)
> R128InitLVDSRegisters(&info->SavedReg, &info->ModeReg, output);
> - else if (r128_output->type == OUTPUT_VGA)
> + else if (r128_output->MonType == MT_CRT)
> R128InitDACRegisters(&info->SavedReg, &info->ModeReg, output);
>
> if (r128_crtc->crtc_id == 0)
> R128RestoreRMXRegisters(pScrn, &info->ModeReg);
>
> - if (r128_output->type == OUTPUT_DVI)
> + if (r128_output->MonType == MT_DFP)
> R128RestoreFPRegisters(pScrn, &info->ModeReg);
> - else if (r128_output->type == OUTPUT_LVDS)
> + else if (r128_output->MonType == MT_LCD)
> R128RestoreLVDSRegisters(pScrn, &info->ModeReg);
> - else if (r128_output->type == OUTPUT_VGA)
> + else if (r128_output->MonType == MT_CRT)
> R128RestoreDACRegisters(pScrn, &info->ModeReg);
> }
>
> @@ -375,133 +375,91 @@ static Bool R128I2CInit(xf86OutputPtr output, I2CBusPtr *bus_ptr, char *name)
> return TRUE;
> }
>
> -void R128SetOutputType(ScrnInfoPtr pScrn, R128OutputPrivatePtr r128_output)
> -{
> - R128OutputType output = OUTPUT_NONE;
> -
> - switch (r128_output->ConnectorType) {
> - case CONNECTOR_VGA:
> - output = OUTPUT_VGA;
> - break;
> - case CONNECTOR_LVDS:
> - output = OUTPUT_LVDS;
> - break;
> - case CONNECTOR_DVI_D:
> - case CONNECTOR_DVI_I:
> - case CONNECTOR_DVI_A:
> - output = OUTPUT_DVI;
> - break;
> - default:
> - output = OUTPUT_NONE;
> - }
> -
> - r128_output->type = output;
> -}
> -
> -void R128SetupGenericConnectors(ScrnInfoPtr pScrn)
> +void R128SetupGenericConnectors(ScrnInfoPtr pScrn, R128OutputType *otypes)
> {
> R128InfoPtr info = R128PTR(pScrn);
> R128EntPtr pR128Ent = R128EntPriv(pScrn);
>
> if (!pR128Ent->HasCRTC2 && !info->isDFP) {
> - info->BiosConnector[0].ConnectorType = CONNECTOR_VGA;
> - info->BiosConnector[0].valid = TRUE;
> + otypes[0] = OUTPUT_VGA;
> return;
> } else if (!pR128Ent->HasCRTC2) {
> - info->BiosConnector[0].ConnectorType = CONNECTOR_DVI_D;
> - info->BiosConnector[0].valid = TRUE;
> + otypes[0] = OUTPUT_DVI;
> return;
> }
>
> - info->BiosConnector[0].ConnectorType = CONNECTOR_LVDS;
> - info->BiosConnector[0].valid = TRUE;
> -
> - info->BiosConnector[1].ConnectorType = CONNECTOR_VGA;
> - info->BiosConnector[1].valid = TRUE;
> + otypes[0] = OUTPUT_LVDS;
> + otypes[1] = OUTPUT_VGA;
> }
>
> Bool R128SetupConnectors(ScrnInfoPtr pScrn)
> {
> R128InfoPtr info = R128PTR(pScrn);
> R128EntPtr pR128Ent = R128EntPriv(pScrn);
> - xf86OutputPtr output;
> +
> + R128OutputType otypes[R128_MAX_BIOS_CONNECTOR];
> + xf86OutputPtr output;
> int num_vga = 0;
> int num_dvi = 0;
> int i;
>
> - for (i = 0; i < R128_MAX_BIOS_CONNECTOR; i++) {
> - info->BiosConnector[i].valid = FALSE;
> - info->BiosConnector[i].ConnectorType = CONNECTOR_NONE;
> - }
> -
> /* XXX: Can we make R128GetConnectorInfoFromBIOS()? */
> - R128SetupGenericConnectors(pScrn);
> + R128SetupGenericConnectors(pScrn, otypes);
>
> for (i = 0; i < R128_MAX_BIOS_CONNECTOR; i++) {
> - if (info->BiosConnector[i].valid) {
> - if ((info->BiosConnector[i].ConnectorType == CONNECTOR_DVI_D) ||
> - (info->BiosConnector[i].ConnectorType == CONNECTOR_DVI_I) ||
> - (info->BiosConnector[i].ConnectorType == CONNECTOR_DVI_A)) {
> - num_dvi++;
> - } else if (info->BiosConnector[i].ConnectorType == CONNECTOR_VGA) {
> - num_vga++;
> - }
> - }
> + if (otypes[i] == OUTPUT_VGA)
> + num_vga++;
> + else if (otypes[i] == OUTPUT_DVI)
> + num_dvi++;
> }
>
> for (i = 0; i < R128_MAX_BIOS_CONNECTOR; i++) {
> - if (info->BiosConnector[i].valid) {
> - R128I2CBusRec i2c;
> - R128OutputPrivatePtr r128_output;
> - R128ConnectorType conntype = info->BiosConnector[i].ConnectorType;
> + if (otypes[i] == OUTPUT_NONE) continue;
>
> - if (conntype == CONNECTOR_NONE)
> - continue;
> + R128I2CBusRec i2c;
> + R128OutputPrivatePtr r128_output;
>
> - r128_output = xnfcalloc(sizeof(R128OutputPrivateRec), 1);
> - if (!r128_output) return FALSE;
> + r128_output = xnfcalloc(sizeof(R128OutputPrivateRec), 1);
> + if (!r128_output) return FALSE;
>
> - r128_output->MonType = MT_UNKNOWN;
> - r128_output->ConnectorType = conntype;
> - r128_output->num = i;
> + r128_output->MonType = MT_UNKNOWN;
> + r128_output->type = otypes[i];
> + r128_output->num = i;
>
> - if (conntype == CONNECTOR_LVDS) {
> - output = R128OutputCreate(pScrn, "LVDS", 0);
> - } else if (conntype == CONNECTOR_VGA) {
> - output = R128OutputCreate(pScrn, "VGA-%d", --num_vga);
> - } else {
> - output = R128OutputCreate(pScrn, "DVI-%d", --num_dvi);
> - }
> + if (otypes[i] == OUTPUT_LVDS) {
> + output = R128OutputCreate(pScrn, "LVDS", 0);
> + } else if (otypes[i] == OUTPUT_VGA) {
> + output = R128OutputCreate(pScrn, "VGA-%d", --num_vga);
> + } else {
> + output = R128OutputCreate(pScrn, "DVI-%d", --num_dvi);
> + }
>
> - if (!output) return FALSE;
> - output->interlaceAllowed = TRUE;
> - output->doubleScanAllowed = TRUE;
> - output->driver_private = r128_output;
> - output->possible_clones = 0;
> - if (conntype == CONNECTOR_LVDS || !pR128Ent->HasCRTC2)
> - output->possible_crtcs = 1;
> - else
> - output->possible_crtcs = 2;
> -
> - if (conntype != CONNECTOR_LVDS && info->DDC) {
> - i2c.ddc_reg = R128_GPIO_MONID;
> - i2c.put_clk_mask = R128_GPIO_MONID_EN_3;
> - i2c.get_clk_mask = R128_GPIO_MONID_Y_3;
> - if (conntype == CONNECTOR_VGA) {
> - i2c.put_data_mask = R128_GPIO_MONID_EN_1;
> - i2c.get_data_mask = R128_GPIO_MONID_Y_1;
> - } else {
> - i2c.put_data_mask = R128_GPIO_MONID_EN_0;
> - i2c.get_data_mask = R128_GPIO_MONID_Y_0;
> - }
> - r128_output->ddc_i2c = i2c;
> - R128I2CInit(output, &r128_output->pI2CBus, output->name);
> - } else if (conntype == CONNECTOR_LVDS) {
> - r128_output->PanelXRes = info->PanelXRes;
> - r128_output->PanelYRes = info->PanelYRes;
> + if (!output) return FALSE;
> + output->interlaceAllowed = TRUE;
> + output->doubleScanAllowed = TRUE;
> + output->driver_private = r128_output;
> + output->possible_clones = 0;
> + if (otypes[i] == OUTPUT_LVDS || !pR128Ent->HasCRTC2)
> + output->possible_crtcs = 1;
> + else
> + output->possible_crtcs = 2;
> +
> + if (otypes[i] != OUTPUT_LVDS && info->DDC) {
> + i2c.ddc_reg = R128_GPIO_MONID;
> + i2c.put_clk_mask = R128_GPIO_MONID_EN_3;
> + i2c.get_clk_mask = R128_GPIO_MONID_Y_3;
> + if (otypes[i] == OUTPUT_VGA) {
> + i2c.put_data_mask = R128_GPIO_MONID_EN_1;
> + i2c.get_data_mask = R128_GPIO_MONID_Y_1;
> + } else {
> + i2c.put_data_mask = R128_GPIO_MONID_EN_0;
> + i2c.get_data_mask = R128_GPIO_MONID_Y_0;
> }
> -
> - R128SetOutputType(pScrn, r128_output);
> + r128_output->ddc_i2c = i2c;
> + R128I2CInit(output, &r128_output->pI2CBus, output->name);
> + } else if (otypes[i] == OUTPUT_LVDS) {
> + r128_output->PanelXRes = info->PanelXRes;
> + r128_output->PanelYRes = info->PanelYRes;
> }
> }
>
> diff --git a/src/r128_probe.h b/src/r128_probe.h
> index 433463b..fef210d 100644
> --- a/src/r128_probe.h
> +++ b/src/r128_probe.h
> @@ -112,16 +112,6 @@ typedef enum
>
> typedef enum
> {
> - CONNECTOR_NONE,
> - CONNECTOR_VGA,
> - CONNECTOR_DVI_I,
> - CONNECTOR_DVI_D,
> - CONNECTOR_DVI_A,
> - CONNECTOR_LVDS
> -} R128ConnectorType;
> -
> -typedef enum
> -{
> OUTPUT_NONE,
> OUTPUT_VGA,
> OUTPUT_DVI,
> @@ -144,15 +134,9 @@ typedef struct _R128CrtcPrivateRec {
> uint8_t lut_r[256], lut_g[256], lut_b[256];
> } R128CrtcPrivateRec, *R128CrtcPrivatePtr;
>
> -typedef struct {
> - R128ConnectorType ConnectorType;
> - Bool valid;
> -} R128BIOSConnector;
> -
> typedef struct _R128OutputPrivateRec {
> int num;
> R128OutputType type;
> - R128ConnectorType ConnectorType;
> R128MonitorType MonType;
> I2CBusPtr pI2CBus;
> R128I2CBusRec ddc_i2c;
> --
> 2.0.2
>
> _______________________________________________
> xorg-driver-ati mailing list
> xorg-driver-ati at lists.x.org
> http://lists.x.org/mailman/listinfo/xorg-driver-ati
More information about the xorg-driver-ati
mailing list