Skip to content
Browse files

Merge remote-tracking branch 'origin/gdev-axe'

  • Loading branch information...
2 parents 3865611 + a6f20b6 commit c67210ab23898e0f86729fc1b238a44ec2e9978f @shinpei0208 shinpei0208 committed
Showing with 73 additions and 2 deletions.
  1. +16 −2 lib/user/nvrm/nvrm_gdev.c
  2. +30 −0 nvrm/ioctl.c
  3. +21 −0 nvrm/mthd.c
  4. +3 −0 nvrm/nvrm.h
  5. +3 −0 nvrm/nvrm_priv.h
View
18 lib/user/nvrm/nvrm_gdev.c
@@ -37,6 +37,8 @@ int gdev_raw_query(struct gdev_device *gdev, uint32_t type, uint64_t *result)
{
struct nvrm_device *dev = gdev->priv;
uint32_t chip_major, chip_minor;
+ uint16_t vendor_id, device_id;
+ uint64_t fb_size;
int count;
switch (type) {
@@ -46,8 +48,10 @@ int gdev_raw_query(struct gdev_device *gdev, uint32_t type, uint64_t *result)
*result = count;
break;
case GDEV_QUERY_DEVICE_MEM_SIZE:
- /* XXX */
- goto fail;
+ if (nvrm_device_get_fb_size(dev, &fb_size))
+ goto fail;
+ *result = fb_size;
+ break;
case GDEV_QUERY_DMA_MEM_SIZE:
/* XXX */
goto fail;
@@ -56,6 +60,16 @@ int gdev_raw_query(struct gdev_device *gdev, uint32_t type, uint64_t *result)
goto fail;
*result = chip_major | chip_minor;
break;
+ case GDEV_QUERY_PCI_VENDOR:
+ if (nvrm_device_get_vendor_id(dev, &vendor_id))
+ goto fail;
+ *result = vendor_id;
+ break;
+ case GDEV_QUERY_PCI_DEVICE:
+ if (nvrm_device_get_device_id(dev, &device_id))
+ goto fail;
+ *result = device_id;
+ break;
default:
goto fail;
}
View
30 nvrm/ioctl.c
@@ -141,6 +141,36 @@ int nvrm_ioctl_card_info(struct nvrm_context *ctx) {
return 0;
}
+int nvrm_ioctl_get_fb_size(struct nvrm_context *ctx, int idx, uint64_t *size) {
+ struct nvrm_ioctl_card_info arg = { {
+ { 0xffffffff },
+ } };
+ if (ioctl(ctx->fd_ctl, NVRM_IOCTL_CARD_INFO, &arg) < 0)
+ return -1;
+ *size = arg.card[idx].fb_size;
+ return 0;
+}
+
+int nvrm_ioctl_get_vendor_id(struct nvrm_context *ctx, int idx, uint16_t *id) {
+ struct nvrm_ioctl_card_info arg = { {
+ { 0xffffffff },
+ } };
+ if (ioctl(ctx->fd_ctl, NVRM_IOCTL_CARD_INFO, &arg) < 0)
+ return -1;
+ *id = arg.card[idx].vendor_id;
+ return 0;
+}
+
+int nvrm_ioctl_get_device_id(struct nvrm_context *ctx, int idx, uint16_t *id) {
+ struct nvrm_ioctl_card_info arg = { {
+ { 0xffffffff },
+ } };
+ if (ioctl(ctx->fd_ctl, NVRM_IOCTL_CARD_INFO, &arg) < 0)
+ return -1;
+ *id = arg.card[idx].device_id;
+ return 0;
+}
+
int nvrm_ioctl_env_info(struct nvrm_context *ctx, uint32_t *pat_supported) {
struct nvrm_ioctl_env_info arg = {
};
View
21 nvrm/mthd.c
@@ -64,6 +64,27 @@ int nvrm_device_get_chipset(struct nvrm_device *dev, uint32_t *major, uint32_t *
return 0;
}
+int nvrm_device_get_fb_size(struct nvrm_device *dev, uint64_t *fb_size) {
+ int res = nvrm_ioctl_get_fb_size(dev->ctx, dev->idx, fb_size);
+ if (res)
+ return res;
+ return 0;
+}
+
+int nvrm_device_get_vendor_id(struct nvrm_device *dev, uint16_t *vendor_id) {
+ int res = nvrm_ioctl_get_vendor_id(dev->ctx, dev->idx, vendor_id);
+ if (res)
+ return res;
+ return 0;
+}
+
+int nvrm_device_get_device_id(struct nvrm_device *dev, uint16_t *device_id) {
+ int res = nvrm_ioctl_get_device_id(dev->ctx, dev->idx, device_id);
+ if (res)
+ return res;
+ return 0;
+}
+
int nvrm_device_get_gpc_mask(struct nvrm_device *dev, uint32_t *mask) {
struct nvrm_mthd_subdevice_get_gpc_mask arg = {
};
View
3 nvrm/nvrm.h
@@ -41,6 +41,9 @@ int nvrm_num_devices(struct nvrm_context *ctx);
struct nvrm_device *nvrm_device_open(struct nvrm_context *ctx, int idx);
void nvrm_device_close(struct nvrm_device *dev);
int nvrm_device_get_chipset(struct nvrm_device *dev, uint32_t *major, uint32_t *minor, uint32_t *stepping);
+int nvrm_device_get_fb_size(struct nvrm_device *dev, uint64_t *fb_size);
+int nvrm_device_get_vendor_id(struct nvrm_device *dev, uint16_t *vendor_id);
+int nvrm_device_get_device_id(struct nvrm_device *dev, uint16_t *device_id);
int nvrm_device_get_gpc_mask(struct nvrm_device *dev, uint32_t *mask);
int nvrm_device_get_gpc_tp_mask(struct nvrm_device *dev, int gpc_id, uint32_t *mask);
int nvrm_device_get_total_tp_count(struct nvrm_device *dev, int *count);
View
3 nvrm/nvrm_priv.h
@@ -104,6 +104,9 @@ int nvrm_ioctl_create(struct nvrm_context *ctx, uint32_t parent, uint32_t handle
int nvrm_ioctl_destroy(struct nvrm_context *ctx, uint32_t parent, uint32_t handle);
int nvrm_ioctl_unk4d(struct nvrm_context *ctx, uint32_t handle, const char *str);
int nvrm_ioctl_card_info(struct nvrm_context *ctx);
+int nvrm_ioctl_get_fb_size(struct nvrm_context *ctx, int idx, uint64_t *size);
+int nvrm_ioctl_get_vendor_id(struct nvrm_context *ctx, int idx, uint16_t *id);
+int nvrm_ioctl_get_device_id(struct nvrm_context *ctx, int idx, uint16_t *id);
int nvrm_ioctl_env_info(struct nvrm_context *ctx, uint32_t *pat_supported);
int nvrm_ioctl_check_version_str(struct nvrm_context *ctx, uint32_t cmd, const char *vernum);
int nvrm_ioctl_memory(struct nvrm_context *ctx, uint32_t parent, uint32_t vspace, uint32_t handle, uint32_t flags1, uint32_t flags2, uint64_t base, uint64_t size);

0 comments on commit c67210a

Please sign in to comment.
Something went wrong with that request. Please try again.