[Spice-devel] [spice-protocol PATCH 35/46] qxlhw: qxl_surface: add and use qxlhw_get_n_surfaces
Alon Levy
alevy at redhat.com
Tue Apr 10 04:50:31 PDT 2012
---
src/qxl_surface.c | 3 +--
src/qxlhw.c | 5 +++++
src/qxlhw.h | 5 +++++
src/qxlhw_pci.c | 8 ++++++++
4 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/src/qxl_surface.c b/src/qxl_surface.c
index dbfc7fe..0ce9877 100644
--- a/src/qxl_surface.c
+++ b/src/qxl_surface.c
@@ -127,9 +127,8 @@ struct surface_cache_t
static Bool
surface_cache_init (surface_cache_t *cache, qxl_screen_t *qxl)
{
- struct QXLRom *rom = qxlhw_pci_get_rom(qxl->hw);
- int n_surfaces = rom->n_surfaces;
int i;
+ int n_surfaces = qxlhw_get_n_surfaces(qxl->hw);
cache->all_surfaces = calloc (n_surfaces, sizeof (qxl_surface_t));
if (!cache->all_surfaces)
diff --git a/src/qxlhw.c b/src/qxlhw.c
index 6172e6c..5ad7c43 100644
--- a/src/qxlhw.c
+++ b/src/qxlhw.c
@@ -79,6 +79,11 @@ void qxlhw_create_primary_surface(struct qxlhw *base, QXLSurfaceCreate *create)
base->create_primary_surface(base, create);
}
+int qxlhw_get_n_surfaces(struct qxlhw *base)
+{
+ return base->get_n_surfaces(base);
+}
+
void qxlhw_push_surface_cmd(struct qxlhw *base, QXLSurfaceCmd* base_cmd)
{
base->push_surface_cmd(base, base_cmd);
diff --git a/src/qxlhw.h b/src/qxlhw.h
index 4ecbe64..c8e0bdf 100644
--- a/src/qxlhw.h
+++ b/src/qxlhw.h
@@ -17,6 +17,9 @@ struct qxlhw {
Bool (*map_memory)(struct qxlhw *base, int scrnIndex);
void (*unmap_memory)(struct qxlhw *base, int scrnIndex);
+ /* capabilities check / accessors */
+ int (*get_n_surfaces)(struct qxlhw *base);
+
/* memory handling callbacks */
void *(*data_alloc)(struct qxlhw *base, unsigned long size);
void (*data_free)(struct qxlhw *base, void *p);
@@ -78,6 +81,8 @@ Bool qxlhw_handle_oom(struct qxlhw *base);
*/
void qxlhw_create_primary_surface(struct qxlhw *base, QXLSurfaceCreate *create);
+int qxlhw_get_n_surfaces(struct qxlhw *base);
+
/* note that allocation of these commands is completely in qxlhw_pci.c,
* and not visible in qxl_surface.c */
void qxlhw_push_surface_cmd(struct qxlhw *base, QXLSurfaceCmd *base_cmd);
diff --git a/src/qxlhw_pci.c b/src/qxlhw_pci.c
index 6d53d99..e216152 100644
--- a/src/qxlhw_pci.c
+++ b/src/qxlhw_pci.c
@@ -646,6 +646,13 @@ static void qxlhw_pci_create_primary_surface(struct qxlhw *base, QXLSurfaceCreat
#endif
}
+static int qxlhw_pci_get_n_surfaces(struct qxlhw *base)
+{
+ struct qxlhw_pci *hw = (struct qxlhw_pci *)base;
+
+ return hw->rom->n_surfaces;
+}
+
static struct QXLSurfaceCmd *
make_surface_cmd (struct qxlhw_pci *hw, QXLSurfaceCmd *base)
{
@@ -897,6 +904,7 @@ struct qxlhw *create_qxlhw_pci(qxl_screen_t *qxl, ScrnInfoPtr pScrn)
base->data_alloc = qxlhw_pci_data_alloc;
base->data_free = qxlhw_pci_data_free;
base->create_primary_surface = qxlhw_pci_create_primary_surface;
+ base->get_n_surfaces = qxlhw_pci_get_n_surfaces;
base->surface_alloc = qxlhw_pci_surface_alloc;
base->surface_free = qxlhw_pci_surface_free;
base->push_surface_cmd = qxlhw_pci_push_surface_cmd;
--
1.7.9.3
More information about the Spice-devel
mailing list