Lines Matching refs:mdev_state
90 struct mdev_state { struct
112 static void mdpy_create_config_space(struct mdev_state *mdev_state) in mdpy_create_config_space() argument
114 STORE_LE16((u16 *) &mdev_state->vconfig[PCI_VENDOR_ID], in mdpy_create_config_space()
116 STORE_LE16((u16 *) &mdev_state->vconfig[PCI_DEVICE_ID], in mdpy_create_config_space()
118 STORE_LE16((u16 *) &mdev_state->vconfig[PCI_SUBSYSTEM_VENDOR_ID], in mdpy_create_config_space()
120 STORE_LE16((u16 *) &mdev_state->vconfig[PCI_SUBSYSTEM_ID], in mdpy_create_config_space()
123 STORE_LE16((u16 *) &mdev_state->vconfig[PCI_COMMAND], in mdpy_create_config_space()
125 STORE_LE16((u16 *) &mdev_state->vconfig[PCI_STATUS], in mdpy_create_config_space()
127 STORE_LE16((u16 *) &mdev_state->vconfig[PCI_CLASS_DEVICE], in mdpy_create_config_space()
129 mdev_state->vconfig[PCI_CLASS_REVISION] = 0x01; in mdpy_create_config_space()
131 STORE_LE32((u32 *) &mdev_state->vconfig[PCI_BASE_ADDRESS_0], in mdpy_create_config_space()
135 mdev_state->bar_mask = ~(mdev_state->memsize) + 1; in mdpy_create_config_space()
138 mdev_state->vconfig[PCI_CAPABILITY_LIST] = MDPY_VENDORCAP_OFFSET; in mdpy_create_config_space()
139 mdev_state->vconfig[MDPY_VENDORCAP_OFFSET + 0] = 0x09; /* vendor cap */ in mdpy_create_config_space()
140 mdev_state->vconfig[MDPY_VENDORCAP_OFFSET + 1] = 0x00; /* next ptr */ in mdpy_create_config_space()
141 mdev_state->vconfig[MDPY_VENDORCAP_OFFSET + 2] = MDPY_VENDORCAP_SIZE; in mdpy_create_config_space()
142 STORE_LE32((u32 *) &mdev_state->vconfig[MDPY_FORMAT_OFFSET], in mdpy_create_config_space()
143 mdev_state->type->format); in mdpy_create_config_space()
144 STORE_LE32((u32 *) &mdev_state->vconfig[MDPY_WIDTH_OFFSET], in mdpy_create_config_space()
145 mdev_state->type->width); in mdpy_create_config_space()
146 STORE_LE32((u32 *) &mdev_state->vconfig[MDPY_HEIGHT_OFFSET], in mdpy_create_config_space()
147 mdev_state->type->height); in mdpy_create_config_space()
150 static void handle_pci_cfg_write(struct mdev_state *mdev_state, u16 offset, in handle_pci_cfg_write() argument
153 struct device *dev = mdev_dev(mdev_state->mdev); in handle_pci_cfg_write()
161 cfg_addr = (cfg_addr & mdev_state->bar_mask); in handle_pci_cfg_write()
168 cfg_addr |= (mdev_state->vconfig[offset] & in handle_pci_cfg_write()
170 STORE_LE32(&mdev_state->vconfig[offset], cfg_addr); in handle_pci_cfg_write()
178 struct mdev_state *mdev_state = mdev_get_drvdata(mdev); in mdev_access() local
182 mutex_lock(&mdev_state->ops_lock); in mdev_access()
186 handle_pci_cfg_write(mdev_state, pos, buf, count); in mdev_access()
188 memcpy(buf, (mdev_state->vconfig + pos), count); in mdev_access()
192 MDPY_MEMORY_BAR_OFFSET + mdev_state->memsize)) { in mdev_access()
195 memcpy(mdev_state->memblk, buf, count); in mdev_access()
197 memcpy(buf, mdev_state->memblk, count); in mdev_access()
210 mutex_unlock(&mdev_state->ops_lock); in mdev_access()
217 struct mdev_state *mdev_state = mdev_get_drvdata(mdev); in mdpy_reset() local
221 stride = mdev_state->type->width * mdev_state->type->bytepp; in mdpy_reset()
222 for (i = 0; i < mdev_state->type->height; i++) in mdpy_reset()
223 memset(mdev_state->memblk + i * stride, in mdpy_reset()
224 i * 255 / mdev_state->type->height, in mdpy_reset()
233 struct mdev_state *mdev_state; in mdpy_create() local
239 mdev_state = kzalloc(sizeof(struct mdev_state), GFP_KERNEL); in mdpy_create()
240 if (mdev_state == NULL) in mdpy_create()
243 mdev_state->vconfig = kzalloc(MDPY_CONFIG_SPACE_SIZE, GFP_KERNEL); in mdpy_create()
244 if (mdev_state->vconfig == NULL) { in mdpy_create()
245 kfree(mdev_state); in mdpy_create()
253 mdev_state->memblk = vmalloc_user(fbsize); in mdpy_create()
254 if (!mdev_state->memblk) { in mdpy_create()
255 kfree(mdev_state->vconfig); in mdpy_create()
256 kfree(mdev_state); in mdpy_create()
262 mutex_init(&mdev_state->ops_lock); in mdpy_create()
263 mdev_state->mdev = mdev; in mdpy_create()
264 mdev_set_drvdata(mdev, mdev_state); in mdpy_create()
266 mdev_state->type = type; in mdpy_create()
267 mdev_state->memsize = fbsize; in mdpy_create()
268 mdpy_create_config_space(mdev_state); in mdpy_create()
277 struct mdev_state *mdev_state = mdev_get_drvdata(mdev); in mdpy_remove() local
283 vfree(mdev_state->memblk); in mdpy_remove()
284 kfree(mdev_state->vconfig); in mdpy_remove()
285 kfree(mdev_state); in mdpy_remove()
409 struct mdev_state *mdev_state = mdev_get_drvdata(mdev); in mdpy_mmap() local
415 if (vma->vm_end - vma->vm_start > mdev_state->memsize) in mdpy_mmap()
421 mdev_state->memblk, 0, in mdpy_mmap()
429 struct mdev_state *mdev_state; in mdpy_get_region_info() local
431 mdev_state = mdev_get_drvdata(mdev); in mdpy_get_region_info()
432 if (!mdev_state) in mdpy_get_region_info()
449 region_info->size = mdev_state->memsize; in mdpy_get_region_info()
482 struct mdev_state *mdev_state = mdev_get_drvdata(mdev); in mdpy_query_gfx_plane() local
494 plane->drm_format = mdev_state->type->format; in mdpy_query_gfx_plane()
495 plane->width = mdev_state->type->width; in mdpy_query_gfx_plane()
496 plane->height = mdev_state->type->height; in mdpy_query_gfx_plane()
497 plane->stride = (mdev_state->type->width * in mdpy_query_gfx_plane()
498 mdev_state->type->bytepp); in mdpy_query_gfx_plane()
499 plane->size = mdev_state->memsize; in mdpy_query_gfx_plane()
517 struct mdev_state *mdev_state; in mdpy_ioctl() local
519 mdev_state = mdev_get_drvdata(mdev); in mdpy_ioctl()
538 memcpy(&mdev_state->dev_info, &info, sizeof(info)); in mdpy_ioctl()
580 (info.index >= mdev_state->dev_info.num_irqs)) in mdpy_ioctl()
643 struct mdev_state *mdev_state = mdev_get_drvdata(mdev); in resolution_show() local
646 mdev_state->type->width, in resolution_show()
647 mdev_state->type->height); in resolution_show()