drm/ast: Split device initialization per HW generation
Subsystems (3)
Thomas Zimmermann
maintainercover 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.
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 | 110 +++++++++++++ drivers/gpu/drm/ast/ast_2100.c | 86 ++++++++++ drivers/gpu/drm/ast/ast_2200.c | 86 ++++++++++ drivers/gpu/drm/ast/ast_2300.c | 130 +++++++++++++++ drivers/gpu/drm/ast/ast_2400.c | 95 +++++++++++ drivers/gpu/drm/ast/ast_2500.c | 100 ++++++++++++ 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, 805 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 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
Re: [PATCH 01/12] drm/ast: Move display-clock tables to per-Gen source files
Quoted 3 lines · Thomas Zimmermann
Move display-clock tables to the appropriate per-Gen source files. The tables are almost identical, except for mode entries
0x17and0x1a. Rename to tables to match common style.
Thanks, it looks good to me.
Quoted 201 lines
Signed-off-by Thomas Zimmermann <[email protected]>--- 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@@ -33,66 +33,6 @@#define HiCModeIndex 3#define TrueCModeIndex 4 -static const struct ast_vbios_dclk_info 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 */ -}; - -static const struct ast_vbios_dclk_info dclk_table_ast2500[] = { - {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 */ -}; -static const struct ast_vbios_stdtable vbios_stdtable[] = {/* MD_2_3_400 */ {
Thomas Zimmermann
maintainerPATCH 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
Re: [PATCH 02/12] drm/ast: Move mode-detection helpers to Gen2 source files
Quoted 2 lines · Thomas Zimmermann
Wide-screen modes are only available on Gen2 and later. Move the detection helpers to the appropriate source file.
Thanks, it looks good to me.
Quoted 98 lines
Signed-off-by Thomas Zimmermann <[email protected]>--- 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;
Thomas Zimmermann
maintainerPATCH 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
Re: [PATCH 03/12] drm/ast: Split ast_detect_tx_chip() per chip generation
Quoted 6 lines · Thomas Zimmermann
Gen4 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(). Whenast_device_create()gets split up per Gen, either call will remain.
Thanks, it looks good to me.
Quoted 298 lines
Signed-off-by Thomas Zimmermann <[email protected]>--- 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@@ -27,6 +27,10 @@*/ #include <linux/delay.h> +#include <linux/sizes.h> + +#include <drm/drm_managed.h> +#include <drm/drm_print.h> #include "ast_drv.h" #include "ast_post.h" @@ -1326,3 +1330,67 @@ int ast_2300_post(struct ast_device *ast)return 0 ; } + +/* +* Device initialization +*/ + +void ast_2300_detect_tx_chip (struct ast_device *ast) +{ +enum ast_tx_chip tx_chip =AST_TX_NONE ; +struct drm_device *dev = &ast->base; +u8 vgacrd1; + +/* +* On AST GEN4+, look at the configuration set by the SoC in +* the SOC scratch register #1 bits 11:8 (interestingly marked +* as "reserved" in the spec) +*/ + vgacrd1 =ast_get_index_reg_mask (ast,AST_IO_VGACRI ,0xd1 , +AST_IO_VGACRD1_TX_TYPE_MASK ); +switch (vgacrd1) { +/* +* GEN4 to GEN6 +*/ +case AST_IO_VGACRD1_TX_SIL164_VBIOS : + tx_chip =AST_TX_SIL164 ; +break ; +case AST_IO_VGACRD1_TX_DP501_VBIOS : + ast->dp501_fw_addr =drmm_kzalloc (dev,SZ_32K ,GFP_KERNEL ); +if (ast->dp501_fw_addr) { +/* backup firmware */ +if (ast_backup_fw (ast, ast->dp501_fw_addr,SZ_32K )) { +drmm_kfree (dev, ast->dp501_fw_addr); + ast->dp501_fw_addr =NULL ; + } + } + fallthrough; +case AST_IO_VGACRD1_TX_FW_EMBEDDED_FW : + tx_chip =AST_TX_DP501 ; +break ; +/* +* GEN7+ +*/ +case AST_IO_VGACRD1_TX_ASTDP : + tx_chip =AST_TX_ASTDP ; +break ; +/* +* Several of the listed TX chips are not explicitly supported +* by the ast driver. If these exist in real-world devices, they +* are most likely reported as VGA or SIL164 outputs. We warn here +* to get bug reports for these devices. If none come in for some +* time, we can begin to fail device probing on these values. +*/ +case AST_IO_VGACRD1_TX_ITE66121_VBIOS : +drm_warn (dev,"ITE IT66121 detected, 0x%x, Gen%lu\n" , vgacrd1,AST_GEN (ast)); +break ; +case AST_IO_VGACRD1_TX_CH7003_VBIOS : +drm_warn (dev,"Chrontel CH7003 detected, 0x%x, Gen%lu\n" , vgacrd1,AST_GEN (ast)); +break ; +case AST_IO_VGACRD1_TX_ANX9807_VBIOS : +drm_warn (dev,"Analogix ANX9807 detected, 0x%x, Gen%lu\n" , vgacrd1,AST_GEN (ast)); +break ; + } + +__ast_device_set_tx_chip (ast, tx_chip); +}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@@ -95,94 +95,6 @@ static void ast_detect_widescreen(struct ast_device *ast) } } -static void ast_detect_tx_chip (struct ast_device *ast,bool need_post) -{ -static const char *const info_str[] = { -"analog VGA" , -"Sil164 TMDS transmitter" , -"DP501 DisplayPort transmitter" , -"ASPEED DisplayPort transmitter" , - }; - -struct drm_device *dev = &ast->base; -u8 vgacra3, vgacrd1; - -/* Check 3rd Tx option (digital output afaik) */ - ast->tx_chip =AST_TX_NONE ; - -if (AST_GEN (ast) <=3 ) { -/* -* 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 ) - ast->tx_chip =AST_TX_SIL164 ; - } - }else { -/* -* On AST GEN4+, look at the configuration set by the SoC in -* the SOC scratch register #1 bits 11:8 (interestingly marked -* as "reserved" in the spec) -*/ - vgacrd1 =ast_get_index_reg_mask (ast,AST_IO_VGACRI ,0xd1 , -AST_IO_VGACRD1_TX_TYPE_MASK ); -switch (vgacrd1) { -/* -* GEN4 to GEN6 -*/ -case AST_IO_VGACRD1_TX_SIL164_VBIOS : - ast->tx_chip =AST_TX_SIL164 ; -break ; -case AST_IO_VGACRD1_TX_DP501_VBIOS : - ast->dp501_fw_addr =drmm_kzalloc (dev,32 *1024 ,GFP_KERNEL ); -if (ast->dp501_fw_addr) { -/* backup firmware */ -if (ast_backup_fw (ast, ast->dp501_fw_addr,32 *1024 )) { -drmm_kfree (dev, ast->dp501_fw_addr); - ast->dp501_fw_addr =NULL ; - } - } - fallthrough; -case AST_IO_VGACRD1_TX_FW_EMBEDDED_FW : - ast->tx_chip =AST_TX_DP501 ; -break ; -/* -* GEN7+ -*/ -case AST_IO_VGACRD1_TX_ASTDP : - ast->tx_chip =AST_TX_ASTDP ; -break ; -/* -* Several of the listed TX chips are not explicitly supported -* by the ast driver. If these exist in real-world devices, they -* are most likely reported as VGA or SIL164 outputs. We warn here -* to get bug reports for these devices. If none come in for some -* time, we can begin to fail device probing on these values. -*/ -case AST_IO_VGACRD1_TX_ITE66121_VBIOS : -drm_warn (dev,"ITE IT66121 detected, 0x%x, Gen%lu\n" , - vgacrd1,AST_GEN (ast)); -break ; -case AST_IO_VGACRD1_TX_CH7003_VBIOS : -drm_warn (dev,"Chrontel CH7003 detected, 0x%x, Gen%lu\n" , - vgacrd1,AST_GEN (ast)); -break ; -case AST_IO_VGACRD1_TX_ANX9807_VBIOS : -drm_warn (dev,"Analogix ANX9807 detected, 0x%x, Gen%lu\n" , - vgacrd1,AST_GEN (ast)); -break ; - } - } - -drm_info (dev,"Using %s\n" , info_str[ast->tx_chip]); -} - struct drm_device *ast_device_create(struct pci_dev *pdev, const struct drm_driver *drv, enum ast_chip chip,@@ -205,7 +117,11 @@ struct drm_device *ast_device_create(struct pci_dev *pdev, ast->regs = regs; ast->ioregs = ioregs; -ast_detect_tx_chip (ast, need_post); +if (AST_GEN (ast) >=4 ) +ast_2300_detect_tx_chip (ast); +else +ast_2000_detect_tx_chip (ast, need_post); +switch (ast->tx_chip) {case AST_TX_ASTDP : ret =ast_post_gpu (ast);
Thomas Zimmermann
maintainerPATCH 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
Re: [PATCH 04/12] drm/ast: Prepare per-Gen device initialization
Quoted 6 lines · Thomas Zimmermann
Switch device creation by hardware Gen. Return the value from the call to
ast_detect_chip(). All generations are still initialized byast_device_create().Also add
ast_device_init()for setting some common fields in structast_device.
Thanks, it looks good to me.
Quoted 99 lines
Signed-off-by Thomas Zimmermann <[email protected]>--- 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);
Thomas Zimmermann
maintainerPATCH 5/12 drm/ast: Move Gen1 device initialization into separate helper
In reply to Thomas ZimmermannSplit off device initialization for Gen1 hardware into the helpers ast_2000_device_create() and ast_2000_detect_wide_screen(). The new functions are duplicates form their counterparts in ast_main.c, but stripped from most non-Gen1 support.
Simplifies maintenance as the driver's number of supported hardware generations grows.
--- drivers/gpu/drm/ast/ast_2000.c | 50 ++++++++++++++++++++++++++++++++++ drivers/gpu/drm/ast/ast_drv.c | 4 +++ drivers/gpu/drm/ast/ast_drv.h | 7 +++++ 3 files changed, 61 insertions(+)
drivers/gpu/drm/ast/ast_2000.c +50 -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,50 @@ void ast_2000_detect_tx_chip(struct ast_device *ast, bool need_post)__ast_device_set_tx_chip (ast, tx_chip); } + +static void ast_2000_detect_widescreen (struct ast_device *ast) +{ + ast->support_wsxga_p = false; + ast->support_fullhd = false; + ast->support_wuxga = false; +} + +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); + +ast_2000_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
@@ -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
Re: [PATCH 05/12] drm/ast: Move Gen1 device initialization into separate helper
Quoted 7 lines · Thomas Zimmermann
Split off device initialization for Gen1 hardware into the helpers
ast_2000_device_create()andast_2000_detect_wide_screen(). The new functions are duplicates form their counterparts inast_main.c, but stripped from most non-Gen1 support.Simplifies maintenance as the driver's number of supported hardware generations grows.
Thanks, it looks good to me.
Quoted 106 lines
Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_2000.c | 50 ++++++++++++++++++++++++++++++++++ drivers/gpu/drm/ast/ast_drv.c | 4 +++ drivers/gpu/drm/ast/ast_drv.h | 7 +++++ 3 files changed, 61 insertions(+)drivers/gpu/drm/ast/ast_2000.c +50
-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,50 @@ void ast_2000_detect_tx_chip(struct ast_device *ast, bool need_post)__ast_device_set_tx_chip (ast, tx_chip); } + +static void ast_2000_detect_widescreen (struct ast_device *ast) +{ + ast->support_wsxga_p = false; + ast->support_fullhd = false; + ast->support_wuxga = false; +} + +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); + +ast_2000_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@@ -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);
Thomas Zimmermann
maintainerPATCH 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 form 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.
--- drivers/gpu/drm/ast/ast_2100.c | 55 ++++++++++++++++++++++++++++++++++ drivers/gpu/drm/ast/ast_drv.c | 4 +++ drivers/gpu/drm/ast/ast_drv.h | 7 +++++ 3 files changed, 66 insertions(+)
drivers/gpu/drm/ast/ast_2100.c +55 -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,55 @@ 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->support_wsxga_p) { +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
Re: [PATCH 06/12] drm/ast: Move Gen2 device initialization into separate helper
Quoted 7 lines · Thomas Zimmermann
Split off device initialization for Gen2 hardware into the helpers
ast_2100_device_create()andast_2100_detect_wide_screen(). The new functions are duplicates form their counterparts inast_main.c, but stripped from most non-Gen2 support.Simplifies maintenance as the driver's number of supported hardware generations grows.
I've a few cosmetic suggestions below:
Quoted 25 lines
Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_2100.c | 55 ++++++++++++++++++++++++++++++++++ drivers/gpu/drm/ast/ast_drv.c | 4 +++ drivers/gpu/drm/ast/ast_drv.h | 7 +++++ 3 files changed, 66 insertions(+)drivers/gpu/drm/ast/ast_2100.c +3
-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,55 @@ bool __ast_2100_detect_wuxga(struct ast_device *ast)return false;
drivers/gpu/drm/ast/ast_2100.c bool __ast_2100_detect_wuxga(struct ast_device *ast) · line 431
Quoted 10 lines
drivers/gpu/drm/ast/ast_2100.c +9
-0} + +static void ast_2100_detect_widescreen (struct ast_device *ast) +{ +if (__ast_2100_detect_wsxga_p (ast)) + ast->support_wsxga_p = true; +if (ast->support_wsxga_p) { +if (ast->chip ==AST2100 ) + ast->support_fullhd = true; + }
That looks a bit awkward
I would prefer either:
if (__ast_2100_detect_wsxga_p(ast)) {
ast->support_wsxga_p = true;
if (ast->chip == AST2100)
ast->support_fullhd = true;
}or
ast->support_wsxga_p = __ast_2100_detect_wsxga_p(ast) ast->support_fullhd = ast->support_wsxga_p && (ast->chip == AST2100);
drivers/gpu/drm/ast/ast_2100.c bool __ast_2100_detect_wuxga(struct ast_device *ast) · line 433
Quoted 2 lines
drivers/gpu/drm/ast/ast_2100.c +2
-0+if (__ast_2100_detect_wuxga (ast)) + ast->support_wuxga = true;
This can also be simplified as:
ast->support_wuxga = __ast_2100_detect_wuxga(ast);
Quoted 74 lines
drivers/gpu/drm/ast/ast_2100.c +41
-0+} + +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);
Thomas Zimmermann
maintainerRe: [PATCH 06/12] drm/ast: Move Gen2 device initialization into separate helper
Hi
Am 19.09.25 um 10:01 schrieb Jocelyn Falempe:
Quoted 49 lines · Thomas Zimmermann
Quoted 7 lines
Split off device initialization for Gen2 hardware into the helpers
ast_2100_device_create()andast_2100_detect_wide_screen(). The new functions are duplicates form their counterparts inast_main.c, but stripped from most non-Gen2 support.Simplifies maintenance as the driver's number of supported hardware generations grows.
I've a few cosmetic suggestions below:
Reviewed-by Jocelyn Falempe <[email protected]>Quoted 23 lines
Signed-off-by Thomas Zimmermann <[email protected]>---
drivers/gpu/drm/ast/ast_2100.c| 55 ++++++++++++++++++++++++++++++++++ drivers/gpu/drm/ast/ast_drv.c | 4 +++ drivers/gpu/drm/ast/ast_drv.h | 7 +++++3 files changed, 66 insertions(+)drivers/gpu/drm/ast/ast_2100.c +3
-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,55 @@ bool __ast_2100_detect_wuxga(struct ast_device *ast) return false;drivers/gpu/drm/ast/ast_2100.c bool __ast_2100_detect_wuxga(struct ast_device · line 431
Quoted 10 lines
drivers/gpu/drm/ast/ast_2100.c +9
-0} + +static void ast_2100_detect_widescreen (struct ast_device *ast) +{ + if (__ast_2100_detect_wsxga_p(ast)) + ast->support_wsxga_p = true; + if (ast->support_wsxga_p) { + if (ast->chip == AST2100) + ast->support_fullhd = true; + }That looks a bit awkward
Quoted 7 lines
I would prefer either:
if (
__ast_2100_detect_wsxga_p(ast)) {
ast->support_wsxga_p = true;
if (ast->chip== AST2100)
ast->support_fullhd= true;
}
Thanks for reviewing. Makes sense to streamline this. I took the code as-is from the existing sources.
Best regards
Thomas
Quoted 90 lines
or
ast->support_wsxga_p=__ast_2100_detect_wsxga_p(ast)ast->support_fullhd=ast->support_wsxga_p&& (ast->chip== AST2100);drivers/gpu/drm/ast/ast_2100.c bool __ast_2100_detect_wuxga(struct ast_device *ast) · line 433
Quoted 2 lines
drivers/gpu/drm/ast/ast_2100.c +2
-0+ if (__ast_2100_detect_wuxga(ast)) + ast->support_wuxga = true;This can also be simplified as:
ast->support_wuxga=__ast_2100_detect_wuxga(ast);Quoted 76 lines
drivers/gpu/drm/ast/ast_2100.c +41
-0+} + +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(structpci_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 · 7 lines
-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nuernberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman HRB 36809 (AG Nuernberg)
Thomas Zimmermann
maintainerPATCH 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 form 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.
--- drivers/gpu/drm/ast/Makefile | 1 + drivers/gpu/drm/ast/ast_2200.c | 86 ++++++++++++++++++++++++++++++++++ drivers/gpu/drm/ast/ast_drv.c | 4 ++ drivers/gpu/drm/ast/ast_drv.h | 9 ++++ 4 files changed, 100 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 +86 -0
86 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
Re: [PATCH 07/12] drm/ast: Move Gen3 device initialization into separate helper
Quoted 8 lines · Thomas Zimmermann
Split off device initialization for Gen3 hardware into the helpers
ast_2200_device_create()andast_2200_detect_wide_screen(). The new functions are duplicates form their counterparts inast_main.c, but stripped from most non-Gen3 support.Simplifies maintenance as the driver's number of supported hardware generations grows.
Thanks, it looks good to me.
Quoted 148 lines
Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/Makefile | 1 + drivers/gpu/drm/ast/ast_2200.c | 86 ++++++++++++++++++++++++++++++++++ drivers/gpu/drm/ast/ast_drv.c | 4 ++ drivers/gpu/drm/ast/ast_drv.h | 9 ++++ 4 files changed, 100 insertions(+)create mode 100644
drivers/gpu/drm/ast/ast_2200.cdrivers/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 +86
-0@@ -0,0 +1,86 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright 2012 Red Hat Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the +* "Software"), to deal in the Software without restriction, including +* without limitation the rights to use, copy, modify, merge, publish, +* distribute, sub license, and/or sell copies of the Software, and to +* permit persons to whom the Software is furnished to do so, subject to +* the following conditions: +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, +* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +* USE OR OTHER DEALINGS IN THE SOFTWARE. +* +* The above copyright notice and this permission notice (including the +* next paragraph) shall be included in all copies or substantial portions +* of the Software. +*/ +/* +* Authors: Dave Airlie <[email protected]> +*/ + +#include <linux/pci.h> + +#include <drm/drm_drv.h> + +#include "ast_drv.h" + +static void ast_2200_detect_widescreen (struct ast_device *ast) +{ +if (__ast_2100_detect_wsxga_p (ast)) + ast->support_wsxga_p = true; +if (ast->support_wsxga_p) { +if (ast->chip ==AST2200 ) + ast->support_fullhd = true; + } +if (__ast_2100_detect_wuxga (ast)) + ast->support_wuxga = true; +} + +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) +{ +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_2200_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@@ -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);
Thomas Zimmermann
maintainerPATCH 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 form 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.
--- drivers/gpu/drm/ast/ast_2300.c | 62 ++++++++++++++++++++++++++++++++++ drivers/gpu/drm/ast/ast_drv.c | 4 +++ drivers/gpu/drm/ast/ast_drv.h | 7 ++++ 3 files changed, 73 insertions(+)
drivers/gpu/drm/ast/ast_2300.c +62 -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,63 @@ 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->support_wsxga_p = true; +else if (ast->chip ==AST1300 ) + ast->support_wsxga_p = true; +if (ast->support_wsxga_p) + 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
Re: [PATCH 08/12] drm/ast: Move Gen4 device initialization into separate helper
Quoted 7 lines · Thomas Zimmermann
Split off device initialization for Gen4 hardware into the helpers
ast_2300_device_create()andast_2300_detect_wide_screen(). The new functions are duplicates form their counterparts inast_main.c, but stripped from most non-Gen4 support.Simplifies maintenance as the driver's number of supported hardware generations grows.
Thanks, it looks good to me.
Quoted 120 lines
Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_2300.c | 62 ++++++++++++++++++++++++++++++++++ drivers/gpu/drm/ast/ast_drv.c | 4 +++ drivers/gpu/drm/ast/ast_drv.h | 7 ++++ 3 files changed, 73 insertions(+)drivers/gpu/drm/ast/ast_2300.c +62
-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,63 @@ 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->support_wsxga_p = true; +else if (ast->chip ==AST1300 ) + ast->support_wsxga_p = true; +if (ast->support_wsxga_p) + 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);
Thomas Zimmermann
maintainerPATCH 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 form 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.
--- drivers/gpu/drm/ast/Makefile | 1 + drivers/gpu/drm/ast/ast_2400.c | 95 ++++++++++++++++++++++++++++++++++ drivers/gpu/drm/ast/ast_drv.c | 4 ++ drivers/gpu/drm/ast/ast_drv.h | 9 ++++ 4 files changed, 109 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 +95 -0
95 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
Re: [PATCH 09/12] drm/ast: Move Gen5 device initialization into separate helper
Quoted 8 lines · Thomas Zimmermann
Split off device initialization for Gen5 hardware into the helpers
ast_2400_device_create()andast_2400_detect_wide_screen(). The new functions are duplicates form their counterparts inast_main.c, but stripped from most non-Gen5 support.Simplifies maintenance as the driver's number of supported hardware generations grows.
Thanks, it looks good to me.
Quoted 157 lines
Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/Makefile | 1 + drivers/gpu/drm/ast/ast_2400.c | 95 ++++++++++++++++++++++++++++++++++ drivers/gpu/drm/ast/ast_drv.c | 4 ++ drivers/gpu/drm/ast/ast_drv.h | 9 ++++ 4 files changed, 109 insertions(+)create mode 100644
drivers/gpu/drm/ast/ast_2400.cdrivers/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 +95
-0@@ -0,0 +1,95 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright 2012 Red Hat Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the +* "Software"), to deal in the Software without restriction, including +* without limitation the rights to use, copy, modify, merge, publish, +* distribute, sub license, and/or sell copies of the Software, and to +* permit persons to whom the Software is furnished to do so, subject to +* the following conditions: +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, +* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +* USE OR OTHER DEALINGS IN THE SOFTWARE. +* +* The above copyright notice and this permission notice (including the +* next paragraph) shall be included in all copies or substantial portions +* of the Software. +* +*/ +/* +* Authors: Dave Airlie <[email protected]> +*/ + +#include <linux/pci.h> + +#include <drm/drm_drv.h> +#include <drm/drm_print.h> + +#include "ast_drv.h" + +static void ast_2400_detect_widescreen (struct ast_device *ast) +{ +if (__ast_2100_detect_wsxga_p (ast)) + ast->support_wsxga_p = true; +else if (ast->chip ==AST1400 ) + ast->support_wsxga_p = true; +if (ast->support_wsxga_p) + ast->support_fullhd = true; +if (__ast_2100_detect_wuxga (ast)) + ast->support_wuxga = true; +} + +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) +{ +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_2400_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@@ -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);
Thomas Zimmermann
maintainerPATCH 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 form 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.
--- drivers/gpu/drm/ast/ast_2500.c | 66 ++++++++++++++++++++++++++++++++++ drivers/gpu/drm/ast/ast_drv.c | 4 +++ drivers/gpu/drm/ast/ast_drv.h | 7 ++++ 3 files changed, 77 insertions(+)
drivers/gpu/drm/ast/ast_2500.c +66 -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,67 @@ 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->support_wsxga_p = true; +else if (ast->chip ==AST2510 ) + ast->support_wsxga_p = true; +if (ast->support_wsxga_p) + 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
Re: [PATCH 10/12] drm/ast: Move Gen6 device initialization into separate helper
Quoted 8 lines · Thomas Zimmermann
Split off device initialization for Gen6 hardware into the helpers
ast_2500_device_create()andast_2500_detect_wide_screen(). The new functions are duplicates form their counterparts inast_main.c, but stripped from most non-Gen6 support.Simplifies maintenance as the driver's number of supported hardware generations grows.
Thanks, it looks good to me.
Quoted 122 lines
Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_2500.c | 66 ++++++++++++++++++++++++++++++++++ drivers/gpu/drm/ast/ast_drv.c | 4 +++ drivers/gpu/drm/ast/ast_drv.h | 7 ++++ 3 files changed, 77 insertions(+)drivers/gpu/drm/ast/ast_2500.c +66
-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,67 @@ 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->support_wsxga_p = true; +else if (ast->chip ==AST2510 ) + ast->support_wsxga_p = true; +if (ast->support_wsxga_p) + 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);
Thomas Zimmermann
maintainerPATCH 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 form 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
Re: [PATCH 11/12] drm/ast: Move Gen7 device initialization into separate helper
Quoted 8 lines · Thomas Zimmermann
Split off device initialization for Gen7 hardware into the helpers
ast_2600_device_create()andast_2600_detect_wide_screen(). The new functions are duplicates form their counterparts inast_main.c, but stripped from most non-Gen7 support.Simplifies maintenance as the driver's number of supported hardware generations grows.
Thanks, it looks good to me.
Quoted 118 lines
Signed-off-by Thomas Zimmermann <[email protected]>--- 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);
Thomas Zimmermann
maintainerPATCH 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
Re: [PATCH 12/12] drm/ast: Remove generic device initialization
Quoted 4 lines · Thomas Zimmermann
The code in
ast_main.chas 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.
Thanks, it looks good to me.
Quoted 216 lines
Signed-off-by Thomas Zimmermann <[email protected]>--- 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.cdrivers/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@@ -1,154 +0,0 @@ -/* -* Copyright 2012 Red Hat Inc. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the -* "Software"), to deal in the Software without restriction, including -* without limitation the rights to use, copy, modify, merge, publish, -* distribute, sub license, and/or sell copies of the Software, and to -* permit persons to whom the Software is furnished to do so, subject to -* the following conditions: -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL -* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, -* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -* USE OR OTHER DEALINGS IN THE SOFTWARE. -* -* The above copyright notice and this permission notice (including the -* next paragraph) shall be included in all copies or substantial portions -* of the Software. -* -*/ -/* -* Authors: Dave Airlie <[email protected]> -*/ - -#include <linux/of.h> -#include <linux/pci.h> - -#include <drm/drm_atomic_helper.h> -#include <drm/drm_drv.h> -#include <drm/drm_gem.h> -#include <drm/drm_managed.h> - -#include "ast_drv.h" - -static void ast_detect_widescreen (struct ast_device *ast) -{ - ast->support_wsxga_p = false; - ast->support_fullhd = false; - ast->support_wuxga = false; - -if (AST_GEN (ast) >=7 ) { - ast->support_wsxga_p = true; - ast->support_fullhd = true; -if (__ast_2100_detect_wuxga (ast)) - ast->support_wuxga = true; - }else if (AST_GEN (ast) >=6 ) { -if (__ast_2100_detect_wsxga_p (ast)) - ast->support_wsxga_p = true; -else if (ast->chip ==AST2510 ) - ast->support_wsxga_p = true; -if (ast->support_wsxga_p) - ast->support_fullhd = true; -if (__ast_2100_detect_wuxga (ast)) - ast->support_wuxga = true; - }else if (AST_GEN (ast) >=5 ) { -if (__ast_2100_detect_wsxga_p (ast)) - ast->support_wsxga_p = true; -else if (ast->chip ==AST1400 ) - ast->support_wsxga_p = true; -if (ast->support_wsxga_p) - ast->support_fullhd = true; -if (__ast_2100_detect_wuxga (ast)) - ast->support_wuxga = true; - }else if (AST_GEN (ast) >=4 ) { -if (__ast_2100_detect_wsxga_p (ast)) - ast->support_wsxga_p = true; -else if (ast->chip ==AST1300 ) - ast->support_wsxga_p = true; -if (ast->support_wsxga_p) - ast->support_fullhd = true; -if (__ast_2100_detect_wuxga (ast)) - ast->support_wuxga = true; - }else if (AST_GEN (ast) >=3 ) { -if (__ast_2100_detect_wsxga_p (ast)) - ast->support_wsxga_p = true; -if (ast->support_wsxga_p) { -if (ast->chip ==AST2200 ) - ast->support_fullhd = true; - } -if (__ast_2100_detect_wuxga (ast)) - ast->support_wuxga = true; - }else if (AST_GEN (ast) >=2 ) { -if (__ast_2100_detect_wsxga_p (ast)) - ast->support_wsxga_p = true; -if (ast->support_wsxga_p) { -if (ast->chip ==AST2100 ) - ast->support_fullhd = true; - } -if (__ast_2100_detect_wuxga (ast)) - ast->support_wuxga = true; - } -} - -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) -{ -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); - -if (AST_GEN (ast) >=4 ) -ast_2300_detect_tx_chip (ast); -else -ast_2000_detect_tx_chip (ast, need_post); - -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); - -/* 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_detect_widescreen (ast); - - ret =ast_mode_config_init (ast); -if (ret) -return ERR_PTR (ret); - -return dev; -}