drm/ast: Split device initialization per HW generation
Subsystems (3)
Thomas Zimmermann
maintainerv2 cover drm/ast: Split device initialization per HW generation
Split ast_device_create() and its helpers into individual helpers for each supported hardware generation. Adds some duplicated code, but simplifies maintenance and support of additional hardware.
Patches 1 to 4 move some code around and prepare for the split.
Patches 5 to 11 each add device initialization for a hardware generation. The code is duplicated from existing code and stripped from unnecesary calls. More specialization is possible in later patches.
Patch 12 removes the original, now unused, code.
Tested on AST2100, AST2300, AST2500 and AST2600.
v2:
- clean up the widescreen-detection logic (Jocelyn)
Thomas Zimmermann (12):
drm/ast: Move display-clock tables to per-Gen source files drm/ast: Move mode-detection helpers to Gen2 source files drm/ast: Split ast_detect_tx_chip() per chip generation drm/ast: Prepare per-Gen device initialization drm/ast: Move Gen1 device initialization into separate helper drm/ast: Move Gen2 device initialization into separate helper drm/ast: Move Gen3 device initialization into separate helper drm/ast: Move Gen4 device initialization into separate helper drm/ast: Move Gen5 device initialization into separate helper drm/ast: Move Gen6 device initialization into separate helper drm/ast: Move Gen7 device initialization into separate helper drm/ast: Remove generic device initialization
drivers/gpu/drm/ast/Makefile | 3 +- drivers/gpu/drm/ast/ast_2000.c | 101 ++++++++++++ drivers/gpu/drm/ast/ast_2100.c | 85 ++++++++++ drivers/gpu/drm/ast/ast_2200.c | 85 ++++++++++ drivers/gpu/drm/ast/ast_2300.c | 128 +++++++++++++++ drivers/gpu/drm/ast/ast_2400.c | 93 +++++++++++ drivers/gpu/drm/ast/ast_2500.c | 98 +++++++++++ drivers/gpu/drm/ast/ast_2600.c | 63 ++++++++ drivers/gpu/drm/ast/ast_drv.c | 67 +++++++- drivers/gpu/drm/ast/ast_drv.h | 75 ++++++++- drivers/gpu/drm/ast/ast_main.c | 268 ------------------------------- drivers/gpu/drm/ast/ast_mode.c | 4 +- drivers/gpu/drm/ast/ast_tables.h | 60 ------- 13 files changed, 788 insertions(+), 342 deletions(-) create mode 100644 drivers/gpu/drm/ast/ast_2200.c create mode 100644 drivers/gpu/drm/ast/ast_2400.c delete mode 100644 drivers/gpu/drm/ast/ast_main.c
Signature · 1 line
2.51.0
Thomas Zimmermann
maintainerPATCH v2 1/12 drm/ast: Move display-clock tables to per-Gen source files
Move display-clock tables to the appropriate per-Gen source files. The tables are almost identical, except for mode entries 0x17 and 0x1a. Rename to tables to match common style.
--- drivers/gpu/drm/ast/ast_2000.c | 34 ++++++++++++++++++ drivers/gpu/drm/ast/ast_2500.c | 34 ++++++++++++++++++ drivers/gpu/drm/ast/ast_drv.h | 2 ++ drivers/gpu/drm/ast/ast_mode.c | 4 +-- drivers/gpu/drm/ast/ast_tables.h | 60 -------------------------------- 5 files changed, 72 insertions(+), 62 deletions(-)
drivers/gpu/drm/ast/ast_2000.c +34 -0
@@ -147,3 +147,37 @@ int ast_2000_post(struct ast_device *ast)return 0 ; } + +/* +* Mode setting +*/ + +const struct ast_vbios_dclk_info ast_2000_dclk_table[] = { + {0x2c ,0xe7 ,0x03 },/* 00: VCLK25_175 */ + {0x95 ,0x62 ,0x03 },/* 01: VCLK28_322 */ + {0x67 ,0x63 ,0x01 },/* 02: VCLK31_5 */ + {0x76 ,0x63 ,0x01 },/* 03: VCLK36 */ + {0xee ,0x67 ,0x01 },/* 04: VCLK40 */ + {0x82 ,0x62 ,0x01 },/* 05: VCLK49_5 */ + {0xc6 ,0x64 ,0x01 },/* 06: VCLK50 */ + {0x94 ,0x62 ,0x01 },/* 07: VCLK56_25 */ + {0x80 ,0x64 ,0x00 },/* 08: VCLK65 */ + {0x7b ,0x63 ,0x00 },/* 09: VCLK75 */ + {0x67 ,0x62 ,0x00 },/* 0a: VCLK78_75 */ + {0x7c ,0x62 ,0x00 },/* 0b: VCLK94_5 */ + {0x8e ,0x62 ,0x00 },/* 0c: VCLK108 */ + {0x85 ,0x24 ,0x00 },/* 0d: VCLK135 */ + {0x67 ,0x22 ,0x00 },/* 0e: VCLK157_5 */ + {0x6a ,0x22 ,0x00 },/* 0f: VCLK162 */ + {0x4d ,0x4c ,0x80 },/* 10: VCLK154 */ + {0x68 ,0x6f ,0x80 },/* 11: VCLK83.5 */ + {0x28 ,0x49 ,0x80 },/* 12: VCLK106.5 */ + {0x37 ,0x49 ,0x80 },/* 13: VCLK146.25 */ + {0x1f ,0x45 ,0x80 },/* 14: VCLK148.5 */ + {0x47 ,0x6c ,0x80 },/* 15: VCLK71 */ + {0x25 ,0x65 ,0x80 },/* 16: VCLK88.75 */ + {0x77 ,0x58 ,0x80 },/* 17: VCLK119 */ + {0x32 ,0x67 ,0x80 },/* 18: VCLK85_5 */ + {0x6a ,0x6d ,0x80 },/* 19: VCLK97_75 */ + {0x3b ,0x2c ,0x81 },/* 1a: VCLK118_25 */ +};
drivers/gpu/drm/ast/ast_2500.c +34 -0
@@ -567,3 +567,37 @@ int ast_2500_post(struct ast_device *ast)return 0 ; } + +/* +* Mode setting +*/ + +const struct ast_vbios_dclk_info ast_2500_dclk_table[] = { + {0x2c ,0xe7 ,0x03 },/* 00: VCLK25_175 */ + {0x95 ,0x62 ,0x03 },/* 01: VCLK28_322 */ + {0x67 ,0x63 ,0x01 },/* 02: VCLK31_5 */ + {0x76 ,0x63 ,0x01 },/* 03: VCLK36 */ + {0xee ,0x67 ,0x01 },/* 04: VCLK40 */ + {0x82 ,0x62 ,0x01 },/* 05: VCLK49_5 */ + {0xc6 ,0x64 ,0x01 },/* 06: VCLK50 */ + {0x94 ,0x62 ,0x01 },/* 07: VCLK56_25 */ + {0x80 ,0x64 ,0x00 },/* 08: VCLK65 */ + {0x7b ,0x63 ,0x00 },/* 09: VCLK75 */ + {0x67 ,0x62 ,0x00 },/* 0a: VCLK78_75 */ + {0x7c ,0x62 ,0x00 },/* 0b: VCLK94_5 */ + {0x8e ,0x62 ,0x00 },/* 0c: VCLK108 */ + {0x85 ,0x24 ,0x00 },/* 0d: VCLK135 */ + {0x67 ,0x22 ,0x00 },/* 0e: VCLK157_5 */ + {0x6a ,0x22 ,0x00 },/* 0f: VCLK162 */ + {0x4d ,0x4c ,0x80 },/* 10: VCLK154 */ + {0x68 ,0x6f ,0x80 },/* 11: VCLK83.5 */ + {0x28 ,0x49 ,0x80 },/* 12: VCLK106.5 */ + {0x37 ,0x49 ,0x80 },/* 13: VCLK146.25 */ + {0x1f ,0x45 ,0x80 },/* 14: VCLK148.5 */ + {0x47 ,0x6c ,0x80 },/* 15: VCLK71 */ + {0x25 ,0x65 ,0x80 },/* 16: VCLK88.75 */ + {0x58 ,0x01 ,0x42 },/* 17: VCLK119 */ + {0x32 ,0x67 ,0x80 },/* 18: VCLK85_5 */ + {0x6a ,0x6d ,0x80 },/* 19: VCLK97_75 */ + {0x44 ,0x20 ,0x43 },/* 1a: VCLK118_25 */ +};
drivers/gpu/drm/ast/ast_drv.h +2 -0
@@ -417,6 +417,7 @@ int ast_mm_init(struct ast_device *ast);/* ast_2000.c */ int ast_2000_post (struct ast_device *ast); +extern const struct ast_vbios_dclk_info ast_2000_dclk_table[];/* ast_2100.c */ int ast_2100_post (struct ast_device *ast);
@@ -427,6 +428,7 @@ int ast_2300_post(struct ast_device *ast);/* ast_2500.c */ void ast_2500_patch_ahb (void __iomem *regs);int ast_2500_post (struct ast_device *ast); +extern const struct ast_vbios_dclk_info ast_2500_dclk_table[];/* ast_2600.c */ int ast_2600_post (struct ast_device *ast);
drivers/gpu/drm/ast/ast_mode.c +2 -2
@@ -373,9 +373,9 @@ static void ast_set_dclk_reg(struct ast_device *ast,const struct ast_vbios_dclk_info *clk_info;if (IS_AST_GEN6 (ast) ||IS_AST_GEN7 (ast)) - clk_info = &dclk_table_ast2500[vmode->dclk_index]; + clk_info = &ast_2500_dclk_table[vmode->dclk_index];else - clk_info = &dclk_table[vmode->dclk_index]; + clk_info = &ast_2000_dclk_table[vmode->dclk_index];ast_set_index_reg_mask (ast,AST_IO_VGACRI ,0xc0 ,0x00 , clk_info->param1);ast_set_index_reg_mask (ast,AST_IO_VGACRI ,0xc1 ,0x00 , clk_info->param2);
drivers/gpu/drm/ast/ast_tables.h +0 -60
66 lines not on this page · raw message
Signature · 1 line
2.51.0
Thomas Zimmermann
maintainerPATCH v2 2/12 drm/ast: Move mode-detection helpers to Gen2 source files
In reply to Thomas ZimmermannWide-screen modes are only available on Gen2 and later. Move the detection helpers to the appropriate source file.
--- drivers/gpu/drm/ast/ast_2100.c | 31 +++++++++++++++++++++++++++++++ drivers/gpu/drm/ast/ast_drv.h | 2 ++ drivers/gpu/drm/ast/ast_main.c | 27 --------------------------- 3 files changed, 33 insertions(+), 27 deletions(-)
drivers/gpu/drm/ast/ast_2100.c +31 -0
@@ -386,3 +386,34 @@ int ast_2100_post(struct ast_device *ast)return 0 ; } + +/* +* Widescreen detection +*/ + +/* Try to detect WSXGA+ on Gen2+ */ +bool __ast_2100_detect_wsxga_p (struct ast_device *ast) +{ +u8 vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 ); + +if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC )) +return true; +if (vgacrd0 &AST_IO_VGACRD0_IKVM_WIDESCREEN ) +return true; + +return false; +} + +/* Try to detect WUXGA on Gen2+ */ +bool __ast_2100_detect_wuxga (struct ast_device *ast) +{ +u8 vgacrd1; + +if (ast->support_fullhd) { + vgacrd1 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd1 ); +if (!(vgacrd1 &AST_IO_VGACRD1_SUPPORTS_WUXGA )) +return true; + } + +return false; +}
drivers/gpu/drm/ast/ast_drv.h +2 -0
@@ -421,6 +421,8 @@ extern const struct ast_vbios_dclk_info ast_2000_dclk_table[];/* ast_2100.c */ int ast_2100_post (struct ast_device *ast); +bool __ast_2100_detect_wsxga_p (struct ast_device *ast); +bool __ast_2100_detect_wuxga (struct ast_device *ast);/* ast_2300.c */ int ast_2300_post (struct ast_device *ast);
drivers/gpu/drm/ast/ast_main.c +0 -27
@@ -36,33 +36,6 @@#include "ast_drv.h" -/* Try to detect WSXGA+ on Gen2+ */ -static bool __ast_2100_detect_wsxga_p (struct ast_device *ast) -{ -u8 vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 ); - -if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC )) -return true; -if (vgacrd0 &AST_IO_VGACRD0_IKVM_WIDESCREEN ) -return true; - -return false; -} - -/* Try to detect WUXGA on Gen2+ */ -static bool __ast_2100_detect_wuxga (struct ast_device *ast) -{ -u8 vgacrd1; - -if (ast->support_fullhd) { - vgacrd1 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd1 ); -if (!(vgacrd1 &AST_IO_VGACRD1_SUPPORTS_WUXGA )) -return true; - } - -return false; -} -static void ast_detect_widescreen (struct ast_device *ast) { ast->support_wsxga_p = false;
Signature · 1 line
2.51.0
Thomas Zimmermann
maintainerPATCH v2 3/12 drm/ast: Split ast_detect_tx_chip() per chip generation
In reply to Thomas ZimmermannGen4 and later models detect the TX chip from VGACRD1, while earlier models detect from VGACRA3. Split up the detection helper into two separate helpers. Use SZ_ constants instead of plain numbers.
Then inline the call into its only caller ast_device_create(). When ast_device_create() gets split up per Gen, either call will remain.
--- drivers/gpu/drm/ast/ast_2000.c | 26 ++++++++++ drivers/gpu/drm/ast/ast_2300.c | 68 ++++++++++++++++++++++++ drivers/gpu/drm/ast/ast_drv.c | 15 ++++++ drivers/gpu/drm/ast/ast_drv.h | 5 ++ drivers/gpu/drm/ast/ast_main.c | 94 ++-------------------------------- 5 files changed, 119 insertions(+), 89 deletions(-)
drivers/gpu/drm/ast/ast_2000.c +26 -0
@@ -181,3 +181,29 @@ const struct ast_vbios_dclk_info ast_2000_dclk_table[] = { {0x6a, 0x6d, 0x80}, /* 19: VCLK97_75 */ {0x3b, 0x2c, 0x81}, /* 1a: VCLK118_25 */ }; + +/* +* Device initialization +*/ + +void ast_2000_detect_tx_chip (struct ast_device *ast,bool need_post) +{ +enum ast_tx_chip tx_chip =AST_TX_NONE ; +u8 vgacra3; + +/* +* VGACRA3 Enhanced Color Mode Register, check if DVO is already +* enabled, in that case, assume we have a SIL164 TMDS transmitter +* +* Don't make that assumption if we the chip wasn't enabled and +* is at power-on reset, otherwise we'll incorrectly "detect" a +* SIL164 when there is none. +*/ +if (!need_post) { + vgacra3 =ast_get_index_reg_mask (ast,AST_IO_VGACRI ,0xa3 ,0xff ); +if (vgacra3 &AST_IO_VGACRA3_DVO_ENABLED ) + tx_chip =AST_TX_SIL164 ; + } + +__ast_device_set_tx_chip (ast, tx_chip); +}
drivers/gpu/drm/ast/ast_2300.c +68 -0
77 lines not on this page · raw message
drivers/gpu/drm/ast/ast_drv.c +15 -0
@@ -37,6 +37,7 @@#include <drm/drm_fbdev_shmem.h> #include <drm/drm_gem_shmem_helper.h> #include <drm/drm_module.h> +#include <drm/drm_print.h> #include <drm/drm_probe_helper.h> #include "ast_drv.h"
@@ -46,6 +47,20 @@ static int ast_modeset = -1;MODULE_PARM_DESC (modeset,"Disable/Enable modesetting" );module_param_named (modeset, ast_modeset, int,0400 ); +void __ast_device_set_tx_chip (struct ast_device *ast,enum ast_tx_chip tx_chip) +{ +static const char *const info_str[] = { +"analog VGA" , +"Sil164 TMDS transmitter" , +"DP501 DisplayPort transmitter" , +"ASPEED DisplayPort transmitter" , + }; + +drm_info (&ast->base,"Using %s\n" , info_str[tx_chip]); + + ast->tx_chip = tx_chip; +} +/* * DRM driver */
drivers/gpu/drm/ast/ast_drv.h +5 -0
@@ -415,9 +415,13 @@ struct ast_crtc_state {int ast_mm_init (struct ast_device *ast); +/* ast_drv.c */ +void __ast_device_set_tx_chip (struct ast_device *ast,enum ast_tx_chip tx_chip); +/* ast_2000.c */ int ast_2000_post (struct ast_device *ast);extern const struct ast_vbios_dclk_info ast_2000_dclk_table[]; +void ast_2000_detect_tx_chip (struct ast_device *ast,bool need_post);/* ast_2100.c */ int ast_2100_post (struct ast_device *ast);
@@ -426,6 +430,7 @@ bool __ast_2100_detect_wuxga(struct ast_device *ast);/* ast_2300.c */ int ast_2300_post (struct ast_device *ast); +void ast_2300_detect_tx_chip (struct ast_device *ast);/* ast_2500.c */ void ast_2500_patch_ahb (void __iomem *regs);
drivers/gpu/drm/ast/ast_main.c +5 -89
106 lines not on this page · raw message
Signature · 1 line
2.51.0
Thomas Zimmermann
maintainerPATCH v2 4/12 drm/ast: Prepare per-Gen device initialization
In reply to Thomas ZimmermannSwitch device creation by hardware Gen. Return the value from the call to ast_detect_chip(). All generations are still initialized by ast_device_create().
Also add ast_device_init() for setting some common fields in struct ast_device.
--- drivers/gpu/drm/ast/ast_drv.c | 25 ++++++++++++++++++++++--- drivers/gpu/drm/ast/ast_drv.h | 5 +++++ drivers/gpu/drm/ast/ast_main.c | 5 +---- 3 files changed, 28 insertions(+), 7 deletions(-)
drivers/gpu/drm/ast/ast_drv.c +22 -3
@@ -47,6 +47,18 @@ static int ast_modeset = -1;MODULE_PARM_DESC (modeset,"Disable/Enable modesetting" );module_param_named (modeset, ast_modeset, int,0400 ); +void ast_device_init (struct ast_device *ast, +enum ast_chip chip, +enum ast_config_mode config_mode, +void __iomem *regs, +void __iomem *ioregs) +{ + ast->chip = chip; + ast->config_mode = config_mode; + ast->regs = regs; + ast->ioregs = ioregs; +} +void __ast_device_set_tx_chip (struct ast_device *ast,enum ast_tx_chip tx_chip) {static const char *const info_str[] = {
@@ -281,7 +293,7 @@ static int ast_detect_chip(struct pci_dev *pdev, *chip_out = chip; *config_mode_out = config_mode; -return 0 ; +return __AST_CHIP_GEN (chip); }static int ast_pci_probe (struct pci_dev *pdev,const struct pci_device_id *ent)
@@ -292,6 +304,7 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)void __iomem *ioregs;enum ast_config_mode config_mode;enum ast_chip chip; +unsigned int chip_gen;struct drm_device *drm;bool need_post = false;
@@ -364,10 +377,16 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)return ret; ret =ast_detect_chip (pdev, regs, ioregs, &chip, &config_mode); -if (ret) +if (ret <0 )return ret; + chip_gen = ret; - drm =ast_device_create (pdev, &ast_driver, chip, config_mode, regs, ioregs, need_post); +switch (chip_gen) { +default : + drm =ast_device_create (pdev, &ast_driver, chip, config_mode, regs, ioregs, + need_post); +break ; + }if (IS_ERR (drm))return PTR_ERR (drm);pci_set_drvdata (pdev, drm);
drivers/gpu/drm/ast/ast_drv.h +5 -0
@@ -416,6 +416,11 @@ struct ast_crtc_state {int ast_mm_init (struct ast_device *ast);/* ast_drv.c */ +void ast_device_init (struct ast_device *ast, +enum ast_chip chip, +enum ast_config_mode config_mode, +void __iomem *regs, +void __iomem *ioregs);void __ast_device_set_tx_chip (struct ast_device *ast,enum ast_tx_chip tx_chip);/* ast_2000.c */
drivers/gpu/drm/ast/ast_main.c +1 -4
@@ -112,10 +112,7 @@ struct drm_device *ast_device_create(struct pci_dev *pdev,return ERR_CAST (ast); dev = &ast->base; - ast->chip = chip; - ast->config_mode = config_mode; - ast->regs = regs; - ast->ioregs = ioregs; +ast_device_init (ast, chip, config_mode, regs, ioregs);if (AST_GEN (ast) >=4 )ast_2300_detect_tx_chip (ast);
Signature · 1 line
2.51.0
Thomas Zimmermann
maintainerPATCH v2 5/12 drm/ast: Move Gen1 device initialization into separate helper
In reply to Thomas ZimmermannSplit off device initialization for Gen1 hardware into the helper ast_2000_device_create(). The new function is a duplicate of their counterpart in ast_main.c, but stripped from most non-Gen1 support.
Simplifies maintenance as the driver's number of supported hardware generations grows.
v2:
- remove unnecessary widescreen-detection logic
--- drivers/gpu/drm/ast/ast_2000.c | 41 ++++++++++++++++++++++++++++++++++ drivers/gpu/drm/ast/ast_drv.c | 4 ++++ drivers/gpu/drm/ast/ast_drv.h | 7 ++++++ 3 files changed, 52 insertions(+)
drivers/gpu/drm/ast/ast_2000.c +41 -0
@@ -27,6 +27,9 @@*/ #include <linux/delay.h> +#include <linux/pci.h> + +#include <drm/drm_drv.h> #include "ast_drv.h" #include "ast_post.h"
@@ -207,3 +210,41 @@ void ast_2000_detect_tx_chip(struct ast_device *ast, bool need_post)__ast_device_set_tx_chip (ast, tx_chip); } + +struct drm_device *ast_2000_device_create (struct pci_dev *pdev, +const struct drm_driver *drv, +enum ast_chip chip, +enum ast_config_mode config_mode, +void __iomem *regs, +void __iomem *ioregs, +bool need_post) +{ +struct drm_device *dev; +struct ast_device *ast; +int ret; + + ast = devm_drm_dev_alloc(&pdev->dev, drv, struct ast_device, base); +if (IS_ERR (ast)) +return ERR_CAST (ast); + dev = &ast->base; + +ast_device_init (ast, chip, config_mode, regs, ioregs); + +ast_2000_detect_tx_chip (ast, need_post); + +if (need_post) { + ret =ast_post_gpu (ast); +if (ret) +return ERR_PTR (ret); + } + + ret =ast_mm_init (ast); +if (ret) +return ERR_PTR (ret); + + ret =ast_mode_config_init (ast); +if (ret) +return ERR_PTR (ret); + +return dev; +}
drivers/gpu/drm/ast/ast_drv.c +4 -0
@@ -382,6 +382,10 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) chip_gen = ret;switch (chip_gen) { +case 1 : + drm =ast_2000_device_create (pdev, &ast_driver, chip, config_mode, + regs, ioregs, need_post); +break ;default : drm =ast_device_create (pdev, &ast_driver, chip, config_mode, regs, ioregs, need_post);
drivers/gpu/drm/ast/ast_drv.h +7 -0
@@ -427,6 +427,13 @@ void __ast_device_set_tx_chip(struct ast_device *ast, enum ast_tx_chip tx_chip);int ast_2000_post (struct ast_device *ast);extern const struct ast_vbios_dclk_info ast_2000_dclk_table[];void ast_2000_detect_tx_chip (struct ast_device *ast,bool need_post); +struct drm_device *ast_2000_device_create (struct pci_dev *pdev, +const struct drm_driver *drv, +enum ast_chip chip, +enum ast_config_mode config_mode, +void __iomem *regs, +void __iomem *ioregs, +bool need_post);/* ast_2100.c */ int ast_2100_post (struct ast_device *ast);
Signature · 1 line
2.51.0
Thomas Zimmermann
maintainerPATCH v2 6/12 drm/ast: Move Gen2 device initialization into separate helper
In reply to Thomas ZimmermannSplit off device initialization for Gen2 hardware into the helpers ast_2100_device_create() and ast_2100_detect_wide_screen(). The new functions are duplicates of their counterparts in ast_main.c, but stripped from most non-Gen2 support.
Simplifies maintenance as the driver's number of supported hardware generations grows.
v2:
- simplify widescreen-detection logic (Jocelyn)
--- drivers/gpu/drm/ast/ast_2100.c | 54 ++++++++++++++++++++++++++++++++++ drivers/gpu/drm/ast/ast_drv.c | 4 +++ drivers/gpu/drm/ast/ast_drv.h | 7 +++++ 3 files changed, 65 insertions(+)
drivers/gpu/drm/ast/ast_2100.c +54 -0
@@ -27,6 +27,9 @@*/ #include <linux/delay.h> +#include <linux/pci.h> + +#include <drm/drm_drv.h> #include "ast_drv.h" #include "ast_post.h"
@@ -417,3 +420,54 @@ bool __ast_2100_detect_wuxga(struct ast_device *ast)return false; } + +static void ast_2100_detect_widescreen (struct ast_device *ast) +{ +if (__ast_2100_detect_wsxga_p (ast)) { + ast->support_wsxga_p = true; +if (ast->chip ==AST2100 ) + ast->support_fullhd = true; + } +if (__ast_2100_detect_wuxga (ast)) + ast->support_wuxga = true; +} + +struct drm_device *ast_2100_device_create (struct pci_dev *pdev, +const struct drm_driver *drv, +enum ast_chip chip, +enum ast_config_mode config_mode, +void __iomem *regs, +void __iomem *ioregs, +bool need_post) +{ +struct drm_device *dev; +struct ast_device *ast; +int ret; + + ast = devm_drm_dev_alloc(&pdev->dev, drv, struct ast_device, base); +if (IS_ERR (ast)) +return ERR_CAST (ast); + dev = &ast->base; + +ast_device_init (ast, chip, config_mode, regs, ioregs); + +ast_2000_detect_tx_chip (ast, need_post); + +if (need_post) { + ret =ast_post_gpu (ast); +if (ret) +return ERR_PTR (ret); + } + + ret =ast_mm_init (ast); +if (ret) +return ERR_PTR (ret); + +ast_2100_detect_widescreen (ast); + + ret =ast_mode_config_init (ast); +if (ret) +return ERR_PTR (ret); + +return dev; +}
drivers/gpu/drm/ast/ast_drv.c +4 -0
@@ -386,6 +386,10 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) drm =ast_2000_device_create (pdev, &ast_driver, chip, config_mode, regs, ioregs, need_post);break ; +case 2 : + drm =ast_2100_device_create (pdev, &ast_driver, chip, config_mode, + regs, ioregs, need_post); +break ;default : drm =ast_device_create (pdev, &ast_driver, chip, config_mode, regs, ioregs, need_post);
drivers/gpu/drm/ast/ast_drv.h +7 -0
@@ -439,6 +439,13 @@ struct drm_device *ast_2000_device_create(struct pci_dev *pdev,int ast_2100_post (struct ast_device *ast);bool __ast_2100_detect_wsxga_p (struct ast_device *ast);bool __ast_2100_detect_wuxga (struct ast_device *ast); +struct drm_device *ast_2100_device_create (struct pci_dev *pdev, +const struct drm_driver *drv, +enum ast_chip chip, +enum ast_config_mode config_mode, +void __iomem *regs, +void __iomem *ioregs, +bool need_post);/* ast_2300.c */ int ast_2300_post (struct ast_device *ast);
Signature · 1 line
2.51.0
Thomas Zimmermann
maintainerPATCH v2 7/12 drm/ast: Move Gen3 device initialization into separate helper
In reply to Thomas ZimmermannSplit off device initialization for Gen3 hardware into the helpers ast_2200_device_create() and ast_2200_detect_wide_screen(). The new functions are duplicates of their counterparts in ast_main.c, but stripped from most non-Gen3 support.
Simplifies maintenance as the driver's number of supported hardware generations grows.
v2:
- simplify widescreen-detection logic
--- drivers/gpu/drm/ast/Makefile | 1 + drivers/gpu/drm/ast/ast_2200.c | 85 ++++++++++++++++++++++++++++++++++ drivers/gpu/drm/ast/ast_drv.c | 4 ++ drivers/gpu/drm/ast/ast_drv.h | 9 ++++ 4 files changed, 99 insertions(+) create mode 100644 drivers/gpu/drm/ast/ast_2200.c
drivers/gpu/drm/ast/Makefile +1 -0
@@ -6,6 +6,7 @@ ast-y := \ ast_2000.o \ ast_2100.o \ + ast_2200.o \ ast_2300.o \ ast_2500.o \ ast_2600.o \
drivers/gpu/drm/ast/ast_2200.c new file +85 -0
85 lines not on this page · raw message
drivers/gpu/drm/ast/ast_drv.c +4 -0
@@ -390,6 +390,10 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) drm =ast_2100_device_create (pdev, &ast_driver, chip, config_mode, regs, ioregs, need_post);break ; +case 3 : + drm =ast_2200_device_create (pdev, &ast_driver, chip, config_mode, + regs, ioregs, need_post); +break ;default : drm =ast_device_create (pdev, &ast_driver, chip, config_mode, regs, ioregs, need_post);
drivers/gpu/drm/ast/ast_drv.h +9 -0
@@ -447,6 +447,15 @@ struct drm_device *ast_2100_device_create(struct pci_dev *pdev,void __iomem *ioregs, bool need_post); +/* ast_2200.c */ +struct drm_device *ast_2200_device_create (struct pci_dev *pdev, +const struct drm_driver *drv, +enum ast_chip chip, +enum ast_config_mode config_mode, +void __iomem *regs, +void __iomem *ioregs, +bool need_post); +/* ast_2300.c */ int ast_2300_post (struct ast_device *ast);void ast_2300_detect_tx_chip (struct ast_device *ast);
Signature · 1 line
2.51.0
Thomas Zimmermann
maintainerPATCH v2 8/12 drm/ast: Move Gen4 device initialization into separate helper
In reply to Thomas ZimmermannSplit off device initialization for Gen4 hardware into the helpers ast_2300_device_create() and ast_2300_detect_wide_screen(). The new functions are duplicates of their counterparts in ast_main.c, but stripped from most non-Gen4 support.
Simplifies maintenance as the driver's number of supported hardware generations grows.
v2:
- simplify widescreen-detection logic
--- drivers/gpu/drm/ast/ast_2300.c | 60 ++++++++++++++++++++++++++++++++++ drivers/gpu/drm/ast/ast_drv.c | 4 +++ drivers/gpu/drm/ast/ast_drv.h | 7 ++++ 3 files changed, 71 insertions(+)
drivers/gpu/drm/ast/ast_2300.c +60 -0
@@ -27,8 +27,10 @@*/ #include <linux/delay.h> +#include <linux/pci.h> #include <linux/sizes.h> +#include <drm/drm_drv.h> #include <drm/drm_managed.h> #include <drm/drm_print.h>
@@ -1394,3 +1396,61 @@ void ast_2300_detect_tx_chip(struct ast_device *ast)__ast_device_set_tx_chip (ast, tx_chip); } + +static void ast_2300_detect_widescreen (struct ast_device *ast) +{ +if (__ast_2100_detect_wsxga_p (ast) || ast->chip ==AST1300 ) { + ast->support_wsxga_p = true; + ast->support_fullhd = true; + } +if (__ast_2100_detect_wuxga (ast)) + ast->support_wuxga = true; +} + +struct drm_device *ast_2300_device_create (struct pci_dev *pdev, +const struct drm_driver *drv, +enum ast_chip chip, +enum ast_config_mode config_mode, +void __iomem *regs, +void __iomem *ioregs, +bool need_post) +{ +struct drm_device *dev; +struct ast_device *ast; +int ret; + + ast = devm_drm_dev_alloc(&pdev->dev, drv, struct ast_device, base); +if (IS_ERR (ast)) +return ERR_CAST (ast); + dev = &ast->base; + +ast_device_init (ast, chip, config_mode, regs, ioregs); + +ast_2300_detect_tx_chip (ast); + +if (need_post) { + ret =ast_post_gpu (ast); +if (ret) +return ERR_PTR (ret); + } + + ret =ast_mm_init (ast); +if (ret) +return ERR_PTR (ret); + +/* map reserved buffer */ + ast->dp501_fw_buf =NULL ; +if (ast->vram_size <pci_resource_len (pdev,0 )) { + ast->dp501_fw_buf =pci_iomap_range (pdev,0 , ast->vram_size,0 ); +if (!ast->dp501_fw_buf) +drm_info (dev,"failed to map reserved buffer!\n" ); + } + +ast_2300_detect_widescreen (ast); + + ret =ast_mode_config_init (ast); +if (ret) +return ERR_PTR (ret); + +return dev; +}
drivers/gpu/drm/ast/ast_drv.c +4 -0
@@ -394,6 +394,10 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) drm =ast_2200_device_create (pdev, &ast_driver, chip, config_mode, regs, ioregs, need_post);break ; +case 4 : + drm =ast_2300_device_create (pdev, &ast_driver, chip, config_mode, + regs, ioregs, need_post); +break ;default : drm =ast_device_create (pdev, &ast_driver, chip, config_mode, regs, ioregs, need_post);
drivers/gpu/drm/ast/ast_drv.h +7 -0
@@ -459,6 +459,13 @@ struct drm_device *ast_2200_device_create(struct pci_dev *pdev,/* ast_2300.c */ int ast_2300_post (struct ast_device *ast);void ast_2300_detect_tx_chip (struct ast_device *ast); +struct drm_device *ast_2300_device_create (struct pci_dev *pdev, +const struct drm_driver *drv, +enum ast_chip chip, +enum ast_config_mode config_mode, +void __iomem *regs, +void __iomem *ioregs, +bool need_post);/* ast_2500.c */ void ast_2500_patch_ahb (void __iomem *regs);
Signature · 1 line
2.51.0
Thomas Zimmermann
maintainerPATCH v2 9/12 drm/ast: Move Gen5 device initialization into separate helper
In reply to Thomas ZimmermannSplit off device initialization for Gen5 hardware into the helpers ast_2400_device_create() and ast_2400_detect_wide_screen(). The new functions are duplicates of their counterparts in ast_main.c, but stripped from most non-Gen5 support.
Simplifies maintenance as the driver's number of supported hardware generations grows.
v2:
- simplify widescreen-detection logic
--- drivers/gpu/drm/ast/Makefile | 1 + drivers/gpu/drm/ast/ast_2400.c | 93 ++++++++++++++++++++++++++++++++++ drivers/gpu/drm/ast/ast_drv.c | 4 ++ drivers/gpu/drm/ast/ast_drv.h | 9 ++++ 4 files changed, 107 insertions(+) create mode 100644 drivers/gpu/drm/ast/ast_2400.c
drivers/gpu/drm/ast/Makefile +1 -0
@@ -8,6 +8,7 @@ ast-y := \ ast_2100.o \ ast_2200.o \ ast_2300.o \ + ast_2400.o \ ast_2500.o \ ast_2600.o \ ast_cursor.o \
drivers/gpu/drm/ast/ast_2400.c new file +93 -0
93 lines not on this page · raw message
drivers/gpu/drm/ast/ast_drv.c +4 -0
@@ -398,6 +398,10 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) drm =ast_2300_device_create (pdev, &ast_driver, chip, config_mode, regs, ioregs, need_post);break ; +case 5 : + drm =ast_2400_device_create (pdev, &ast_driver, chip, config_mode, + regs, ioregs, need_post); +break ;default : drm =ast_device_create (pdev, &ast_driver, chip, config_mode, regs, ioregs, need_post);
drivers/gpu/drm/ast/ast_drv.h +9 -0
@@ -467,6 +467,15 @@ struct drm_device *ast_2300_device_create(struct pci_dev *pdev,void __iomem *ioregs, bool need_post); +/* ast_2400.c */ +struct drm_device *ast_2400_device_create (struct pci_dev *pdev, +const struct drm_driver *drv, +enum ast_chip chip, +enum ast_config_mode config_mode, +void __iomem *regs, +void __iomem *ioregs, +bool need_post); +/* ast_2500.c */ void ast_2500_patch_ahb (void __iomem *regs);int ast_2500_post (struct ast_device *ast);
Signature · 1 line
2.51.0
Thomas Zimmermann
maintainerPATCH v2 10/12 drm/ast: Move Gen6 device initialization into separate helper
In reply to Thomas ZimmermannSplit off device initialization for Gen6 hardware into the helpers ast_2500_device_create() and ast_2500_detect_wide_screen(). The new functions are duplicates of their counterparts in ast_main.c, but stripped from most non-Gen6 support.
Simplifies maintenance as the driver's number of supported hardware generations grows.
v2:
- simplify widescreen-detection logic
--- drivers/gpu/drm/ast/ast_2500.c | 64 ++++++++++++++++++++++++++++++++++ drivers/gpu/drm/ast/ast_drv.c | 4 +++ drivers/gpu/drm/ast/ast_drv.h | 7 ++++ 3 files changed, 75 insertions(+)
drivers/gpu/drm/ast/ast_2500.c +64 -0
@@ -27,7 +27,9 @@*/ #include <linux/delay.h> +#include <linux/pci.h> +#include <drm/drm_drv.h> #include <drm/drm_print.h> #include "ast_drv.h"
@@ -601,3 +603,65 @@ const struct ast_vbios_dclk_info ast_2500_dclk_table[] = { {0x6a, 0x6d, 0x80}, /* 19: VCLK97_75 */ {0x44, 0x20, 0x43}, /* 1a: VCLK118_25 */ }; + +/* +* Device initialization +*/ + +static void ast_2500_detect_widescreen (struct ast_device *ast) +{ +if (__ast_2100_detect_wsxga_p (ast) || ast->chip ==AST2510 ) { + ast->support_wsxga_p = true; + ast->support_fullhd = true; + } +if (__ast_2100_detect_wuxga (ast)) + ast->support_wuxga = true; +} + +struct drm_device *ast_2500_device_create (struct pci_dev *pdev, +const struct drm_driver *drv, +enum ast_chip chip, +enum ast_config_mode config_mode, +void __iomem *regs, +void __iomem *ioregs, +bool need_post) +{ +struct drm_device *dev; +struct ast_device *ast; +int ret; + + ast = devm_drm_dev_alloc(&pdev->dev, drv, struct ast_device, base); +if (IS_ERR (ast)) +return ERR_CAST (ast); + dev = &ast->base; + +ast_device_init (ast, chip, config_mode, regs, ioregs); + +ast_2300_detect_tx_chip (ast); + +if (need_post) { + ret =ast_post_gpu (ast); +if (ret) +return ERR_PTR (ret); + } + + ret =ast_mm_init (ast); +if (ret) +return ERR_PTR (ret); + +/* map reserved buffer */ + ast->dp501_fw_buf =NULL ; +if (ast->vram_size <pci_resource_len (pdev,0 )) { + ast->dp501_fw_buf =pci_iomap_range (pdev,0 , ast->vram_size,0 ); +if (!ast->dp501_fw_buf) +drm_info (dev,"failed to map reserved buffer!\n" ); + } + +ast_2500_detect_widescreen (ast); + + ret =ast_mode_config_init (ast); +if (ret) +return ERR_PTR (ret); + +return dev; +}
drivers/gpu/drm/ast/ast_drv.c +4 -0
@@ -402,6 +402,10 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) drm =ast_2400_device_create (pdev, &ast_driver, chip, config_mode, regs, ioregs, need_post);break ; +case 6 : + drm =ast_2500_device_create (pdev, &ast_driver, chip, config_mode, + regs, ioregs, need_post); +break ;default : drm =ast_device_create (pdev, &ast_driver, chip, config_mode, regs, ioregs, need_post);
drivers/gpu/drm/ast/ast_drv.h +7 -0
@@ -480,6 +480,13 @@ struct drm_device *ast_2400_device_create(struct pci_dev *pdev,void ast_2500_patch_ahb (void __iomem *regs);int ast_2500_post (struct ast_device *ast);extern const struct ast_vbios_dclk_info ast_2500_dclk_table[]; +struct drm_device *ast_2500_device_create (struct pci_dev *pdev, +const struct drm_driver *drv, +enum ast_chip chip, +enum ast_config_mode config_mode, +void __iomem *regs, +void __iomem *ioregs, +bool need_post);/* ast_2600.c */ int ast_2600_post (struct ast_device *ast);
Signature · 1 line
2.51.0
Thomas Zimmermann
maintainerPATCH v2 11/12 drm/ast: Move Gen7 device initialization into separate helper
In reply to Thomas ZimmermannSplit off device initialization for Gen7 hardware into the helpers ast_2600_device_create() and ast_2600_detect_wide_screen(). The new functions are duplicates of their counterparts in ast_main.c, but stripped from most non-Gen7 support.
Simplifies maintenance as the driver's number of supported hardware generations grows.
--- drivers/gpu/drm/ast/ast_2600.c | 63 ++++++++++++++++++++++++++++++++++ drivers/gpu/drm/ast/ast_drv.c | 4 +++ drivers/gpu/drm/ast/ast_drv.h | 7 ++++ 3 files changed, 74 insertions(+)
drivers/gpu/drm/ast/ast_2600.c +63 -0
@@ -26,6 +26,10 @@* Authors: Dave Airlie <[email protected]> */ +#include <linux/pci.h> + +#include <drm/drm_drv.h> +#include "ast_drv.h" #include "ast_post.h"
@@ -42,3 +46,62 @@ int ast_2600_post(struct ast_device *ast)return 0 ; } + +/* +* Device initialization +*/ + +static void ast_2600_detect_widescreen (struct ast_device *ast) +{ + ast->support_wsxga_p = true; + ast->support_fullhd = true; +if (__ast_2100_detect_wuxga (ast)) + ast->support_wuxga = true; +} + +struct drm_device *ast_2600_device_create (struct pci_dev *pdev, +const struct drm_driver *drv, +enum ast_chip chip, +enum ast_config_mode config_mode, +void __iomem *regs, +void __iomem *ioregs, +bool need_post) +{ +struct drm_device *dev; +struct ast_device *ast; +int ret; + + ast = devm_drm_dev_alloc(&pdev->dev, drv, struct ast_device, base); +if (IS_ERR (ast)) +return ERR_CAST (ast); + dev = &ast->base; + +ast_device_init (ast, chip, config_mode, regs, ioregs); + +ast_2300_detect_tx_chip (ast); + +switch (ast->tx_chip) { +case AST_TX_ASTDP : + ret =ast_post_gpu (ast); +break ; +default : + ret =0 ; +if (need_post) + ret =ast_post_gpu (ast); +break ; + } +if (ret) +return ERR_PTR (ret); + + ret =ast_mm_init (ast); +if (ret) +return ERR_PTR (ret); + +ast_2600_detect_widescreen (ast); + + ret =ast_mode_config_init (ast); +if (ret) +return ERR_PTR (ret); + +return dev; +}
drivers/gpu/drm/ast/ast_drv.c +4 -0
@@ -406,6 +406,10 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) drm =ast_2500_device_create (pdev, &ast_driver, chip, config_mode, regs, ioregs, need_post);break ; +case 7 : + drm =ast_2600_device_create (pdev, &ast_driver, chip, config_mode, + regs, ioregs, need_post); +break ;default : drm =ast_device_create (pdev, &ast_driver, chip, config_mode, regs, ioregs, need_post);
drivers/gpu/drm/ast/ast_drv.h +7 -0
@@ -490,6 +490,13 @@ struct drm_device *ast_2500_device_create(struct pci_dev *pdev,/* ast_2600.c */ int ast_2600_post (struct ast_device *ast); +struct drm_device *ast_2600_device_create (struct pci_dev *pdev, +const struct drm_driver *drv, +enum ast_chip chip, +enum ast_config_mode config_mode, +void __iomem *regs, +void __iomem *ioregs, +bool need_post);/* ast post */ int ast_post_gpu (struct ast_device *ast);
Signature · 1 line
2.51.0
Thomas Zimmermann
maintainerPATCH v2 12/12 drm/ast: Remove generic device initialization
In reply to Thomas ZimmermannThe code in ast_main.c has been split into several helpers in other source files. Delete the source file. With the generic device init gone, fail probing on unknown hardware generations.
--- drivers/gpu/drm/ast/Makefile | 1 - drivers/gpu/drm/ast/ast_drv.c | 5 +- drivers/gpu/drm/ast/ast_drv.h | 8 -- drivers/gpu/drm/ast/ast_main.c | 154 --------------------------------- 4 files changed, 2 insertions(+), 166 deletions(-) delete mode 100644 drivers/gpu/drm/ast/ast_main.c
drivers/gpu/drm/ast/Makefile +0 -1
@@ -16,7 +16,6 @@ ast-y := \ ast_dp501.o \ ast_dp.o \ ast_drv.o \ - ast_main.o \ ast_mm.o \ ast_mode.o \ ast_post.o \
drivers/gpu/drm/ast/ast_drv.c +2 -3
@@ -411,9 +411,8 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) regs, ioregs, need_post);break ;default : - drm =ast_device_create (pdev, &ast_driver, chip, config_mode, regs, ioregs, - need_post); -break ; +dev_err (&pdev->dev,"Gen%d not supported\n" , chip_gen); +return -ENODEV ; }if (IS_ERR (drm))return PTR_ERR (drm);
drivers/gpu/drm/ast/ast_drv.h +0 -8
@@ -217,14 +217,6 @@ static inline struct ast_device *to_ast_device(struct drm_device *dev) return container_of(dev, struct ast_device, base); } -struct drm_device *ast_device_create (struct pci_dev *pdev, -const struct drm_driver *drv, -enum ast_chip chip, -enum ast_config_mode config_mode, -void __iomem *regs, -void __iomem *ioregs, -bool need_post); -static inline unsigned long __ast_gen (struct ast_device *ast) {return __AST_CHIP_GEN (ast->chip);
drivers/gpu/drm/ast/ast_main.c deleted +0 -154
154 lines not on this page · raw message
Signature · 1 line
2.51.0