aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/nouveau/nouveau_mem.c
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2012-01-17 18:02:28 -0500
committerBen Skeggs <bskeggs@redhat.com>2012-03-13 03:08:06 -0400
commit085028ce3bf7136c5ab2eeb8bf012024d88905c8 (patch)
tree95d9a304926158b075401c541afec3c17dc8acf6 /drivers/gpu/drm/nouveau/nouveau_mem.c
parentfd99fd6100d3b7aaa8dc76888a38bbb15e8041bc (diff)
drm/nouveau/pm: embed timings into perflvl structs
Signed-off-by: Ben Skeggs <bskeggs@redhat.com> Signed-off-by: Martin Peres <martin.peres@labri.fr>
Diffstat (limited to 'drivers/gpu/drm/nouveau/nouveau_mem.c')
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_mem.c82
1 files changed, 39 insertions, 43 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_mem.c b/drivers/gpu/drm/nouveau/nouveau_mem.c
index 33de77211639..cc46811e2d37 100644
--- a/drivers/gpu/drm/nouveau/nouveau_mem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_mem.c
@@ -812,63 +812,59 @@ nouveau_mem_gddr5_mr(struct drm_device *dev, u32 freq,
812 return 0; 812 return 0;
813} 813}
814 814
815struct nouveau_pm_memtiming * 815int
816nouveau_mem_timing(struct drm_device *dev, u32 freq) 816nouveau_mem_timing_calc(struct drm_device *dev, u32 freq,
817 struct nouveau_pm_memtiming *t)
817{ 818{
818 struct drm_nouveau_private *dev_priv = dev->dev_private; 819 struct drm_nouveau_private *dev_priv = dev->dev_private;
819 struct nouveau_pm_engine *pm = &dev_priv->engine.pm; 820 struct nouveau_pm_engine *pm = &dev_priv->engine.pm;
820 struct nouveau_pm_memtiming *boot = &pm->boot_timing; 821 struct nouveau_pm_memtiming *boot = &pm->boot.timing;
821 struct nouveau_pm_memtiming *t;
822 struct nouveau_pm_tbl_entry *e; 822 struct nouveau_pm_tbl_entry *e;
823 u8 ver, len, *ptr; 823 u8 ver, len, *ptr;
824 int ret; 824 int ret;
825 825
826 ptr = nouveau_perf_timing(dev, freq, &ver, &len); 826 ptr = nouveau_perf_timing(dev, freq, &ver, &len);
827 if (!ptr || ptr[0] == 0x00) 827 if (!ptr || ptr[0] == 0x00) {
828 return boot; 828 *t = *boot;
829 return 0;
830 }
829 e = (struct nouveau_pm_tbl_entry *)ptr; 831 e = (struct nouveau_pm_tbl_entry *)ptr;
830 832
831 t = kzalloc(sizeof(*t), GFP_KERNEL); 833 t->tCWL = boot->tCWL;
832 if (t) {
833 t->tCWL = boot->tCWL;
834
835 switch (dev_priv->card_type) {
836 case NV_40:
837 ret = nv40_mem_timing_calc(dev, freq, e, len, boot, t);
838 break;
839 case NV_50:
840 ret = nv50_mem_timing_calc(dev, freq, e, len, boot, t);
841 break;
842 case NV_C0:
843 ret = nvc0_mem_timing_calc(dev, freq, e, len, boot, t);
844 break;
845 default:
846 ret = -ENODEV;
847 break;
848 }
849 834
850 switch (dev_priv->vram_type * !ret) { 835 switch (dev_priv->card_type) {
851 case NV_MEM_TYPE_GDDR3: 836 case NV_40:
852 ret = nouveau_mem_gddr3_mr(dev, freq, e, len, boot, t); 837 ret = nv40_mem_timing_calc(dev, freq, e, len, boot, t);
853 break; 838 break;
854 case NV_MEM_TYPE_GDDR5: 839 case NV_50:
855 ret = nouveau_mem_gddr5_mr(dev, freq, e, len, boot, t); 840 ret = nv50_mem_timing_calc(dev, freq, e, len, boot, t);
856 break; 841 break;
857 case NV_MEM_TYPE_DDR2: 842 case NV_C0:
858 ret = nouveau_mem_ddr2_mr(dev, freq, e, len, boot, t); 843 ret = nvc0_mem_timing_calc(dev, freq, e, len, boot, t);
859 break; 844 break;
860 case NV_MEM_TYPE_DDR3: 845 default:
861 ret = nouveau_mem_ddr3_mr(dev, freq, e, len, boot, t); 846 ret = -ENODEV;
862 break; 847 break;
863 } 848 }
864 849
865 if (ret) { 850 switch (dev_priv->vram_type * !ret) {
866 kfree(t); 851 case NV_MEM_TYPE_GDDR3:
867 t = NULL; 852 ret = nouveau_mem_gddr3_mr(dev, freq, e, len, boot, t);
868 } 853 break;
854 case NV_MEM_TYPE_GDDR5:
855 ret = nouveau_mem_gddr5_mr(dev, freq, e, len, boot, t);
856 break;
857 case NV_MEM_TYPE_DDR2:
858 ret = nouveau_mem_ddr2_mr(dev, freq, e, len, boot, t);
859 break;
860 case NV_MEM_TYPE_DDR3:
861 ret = nouveau_mem_ddr3_mr(dev, freq, e, len, boot, t);
862 break;
863 default:
864 ret = -EINVAL;
869 } 865 }
870 866
871 return t; 867 return ret;
872} 868}
873 869
874void 870void