Brian | aa59a93 | 2008-02-26 20:15:14 -0700 | [diff] [blame^] | 1 | /************************************************************************** |
| 2 | * |
| 3 | * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. |
| 4 | * All Rights Reserved. |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 7 | * copy of this software and associated documentation files (the |
| 8 | * "Software"), to deal in the Software without restriction, including |
| 9 | * without limitation the rights to use, copy, modify, merge, publish, |
| 10 | * distribute, sub license, and/or sell copies of the Software, and to |
| 11 | * permit persons to whom the Software is furnished to do so, subject to |
| 12 | * the following conditions: |
| 13 | * |
| 14 | * The above copyright notice and this permission notice (including the |
| 15 | * next paragraph) shall be included in all copies or substantial portions |
| 16 | * of the Software. |
| 17 | * |
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 19 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. |
| 21 | * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR |
| 22 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| 23 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| 24 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 25 | * |
| 26 | **************************************************************************/ |
| 27 | |
| 28 | |
| 29 | #include "pipe/p_util.h" |
| 30 | #include "pipe/p_winsys.h" |
| 31 | |
| 32 | #include "i915_reg.h" |
| 33 | #include "i915_screen.h" |
| 34 | #include "i915_texture.h" |
| 35 | |
| 36 | |
| 37 | static const char * |
| 38 | i915_get_vendor( struct pipe_screen *pscreen ) |
| 39 | { |
| 40 | return "Tungsten Graphics, Inc."; |
| 41 | } |
| 42 | |
| 43 | |
| 44 | static const char * |
| 45 | i915_get_name( struct pipe_screen *pscreen ) |
| 46 | { |
| 47 | static char buffer[128]; |
| 48 | const char *chipset; |
| 49 | |
| 50 | switch (i915_screen(pscreen)->pci_id) { |
| 51 | case PCI_CHIP_I915_G: |
| 52 | chipset = "915G"; |
| 53 | break; |
| 54 | case PCI_CHIP_I915_GM: |
| 55 | chipset = "915GM"; |
| 56 | break; |
| 57 | case PCI_CHIP_I945_G: |
| 58 | chipset = "945G"; |
| 59 | break; |
| 60 | case PCI_CHIP_I945_GM: |
| 61 | chipset = "945GM"; |
| 62 | break; |
| 63 | case PCI_CHIP_I945_GME: |
| 64 | chipset = "945GME"; |
| 65 | break; |
| 66 | case PCI_CHIP_G33_G: |
| 67 | chipset = "G33"; |
| 68 | break; |
| 69 | case PCI_CHIP_Q35_G: |
| 70 | chipset = "Q35"; |
| 71 | break; |
| 72 | case PCI_CHIP_Q33_G: |
| 73 | chipset = "Q33"; |
| 74 | break; |
| 75 | default: |
| 76 | chipset = "unknown"; |
| 77 | break; |
| 78 | } |
| 79 | |
| 80 | sprintf(buffer, "i915 (chipset: %s)", chipset); |
| 81 | return buffer; |
| 82 | } |
| 83 | |
| 84 | |
| 85 | |
| 86 | static void |
| 87 | i915_destroy_screen( struct pipe_screen *screen ) |
| 88 | { |
| 89 | FREE(screen); |
| 90 | } |
| 91 | |
| 92 | |
| 93 | /** |
| 94 | * Create a new i915_screen object |
| 95 | */ |
| 96 | struct pipe_screen * |
| 97 | i915_create_screen(struct pipe_winsys *winsys, uint pci_id) |
| 98 | { |
| 99 | struct i915_screen *i915screen = CALLOC_STRUCT(i915_screen); |
| 100 | |
| 101 | if (!i915screen) |
| 102 | return NULL; |
| 103 | |
| 104 | switch (pci_id) { |
| 105 | case PCI_CHIP_I915_G: |
| 106 | case PCI_CHIP_I915_GM: |
| 107 | i915screen->is_i945 = FALSE; |
| 108 | break; |
| 109 | |
| 110 | case PCI_CHIP_I945_G: |
| 111 | case PCI_CHIP_I945_GM: |
| 112 | case PCI_CHIP_I945_GME: |
| 113 | case PCI_CHIP_G33_G: |
| 114 | case PCI_CHIP_Q33_G: |
| 115 | case PCI_CHIP_Q35_G: |
| 116 | i915screen->is_i945 = TRUE; |
| 117 | break; |
| 118 | |
| 119 | default: |
| 120 | winsys->printf(winsys, |
| 121 | "%s: unknown pci id 0x%x, cannot create screen\n", |
| 122 | __FUNCTION__, pci_id); |
| 123 | return NULL; |
| 124 | } |
| 125 | |
| 126 | i915screen->pci_id = pci_id; |
| 127 | |
| 128 | i915screen->screen.winsys = winsys; |
| 129 | |
| 130 | i915screen->screen.destroy = i915_destroy_screen; |
| 131 | |
| 132 | i915screen->screen.get_name = i915_get_name; |
| 133 | i915screen->screen.get_vendor = i915_get_vendor; |
| 134 | |
| 135 | i915_init_screen_string_functions(&i915screen->screen); |
| 136 | i915_init_screen_texture_functions(&i915screen->screen); |
| 137 | |
| 138 | return &i915screen->screen; |
| 139 | } |