Re: [PATCH v3 1/5] drm/rockchip: Add basic drm driver
On 2014年09月23日 15:48, Daniel Vetter wrote: On Mon, Sep 22, 2014 at 09:32:19AM +0800, Mark yao wrote: On 2014年09月20日 08:03, Rob Clark wrote: On Fri, Sep 19, 2014 at 1:47 AM, Mark yao wrote: diff --git a/include/uapi/drm/rockchip_drm.h b/include/uapi/drm/rockchip_drm.h new file mode 100644 index 000..8f8e60e --- /dev/null +++ b/include/uapi/drm/rockchip_drm.h @@ -0,0 +1,97 @@ +/* + * + * Copyright (c) Fuzhou Rockchip Electronics Co.Ltd + * Authors: + * Mark Yao + * + * base on exynos_drm.h + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#ifndef _UAPI_ROCKCHIP_DRM_H +#define _UAPI_ROCKCHIP_DRM_H + +#include + +/** + * User-desired buffer creation information structure. + * + * @size: user-desired memory allocation size. + * @flags: user request for setting memory type or cache attributes. + * @handle: returned a handle to created gem object. + * - this handle will be set by gem module of kernel side. + */ +struct drm_rockchip_gem_create { + uint64_t size; + uint32_t flags; + uint32_t handle; +}; + +/** + * A structure for getting buffer offset. + * + * @handle: a pointer to gem object created. + * @pad: just padding to be 64-bit aligned. + * @offset: relatived offset value of the memory region allocated. + * - this value should be set by user. + */ +struct drm_rockchip_gem_map_off { + uint32_t handle; + uint32_t pad; + uint64_t offset; +}; + +/** + * A structure for mapping buffer. + * + * @handle: a handle to gem object created. + * @pad: just padding to be 64-bit aligned. + * @size: memory size to be mapped. + * @mapped: having user virtual address mmaped. + * - this variable would be filled by rockchip gem module + * of kernel side with user virtual address which is allocated + * by do_mmap(). + */ +struct drm_rockchip_gem_mmap { + uint32_t handle; + uint32_t pad; + uint64_t size; + uint64_t mapped; +}; Could we do without the mmap ioctl? It has been a source of problems in other drivers, and the ioctl to get mmap offset, plus normal mmap() on drm device file should be sufficient BR, -R OK, I will try to move the special mmap ioctl and use drm generic mmap interface. Actually you probably should drop all this and just implement the dummy object support for now. Until you have proper hw accel there's no reason to expose a driver-private gem create/mmap interface at all. A pure kms driver really shouldn't have it's on uapi/foo_drm.h file. -Daniel right, I will try to do it. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v3 1/5] drm/rockchip: Add basic drm driver
On Mon, Sep 22, 2014 at 09:32:19AM +0800, Mark yao wrote: > On 2014年09月20日 08:03, Rob Clark wrote: > >On Fri, Sep 19, 2014 at 1:47 AM, Mark yao wrote: > >>diff --git a/include/uapi/drm/rockchip_drm.h > >>b/include/uapi/drm/rockchip_drm.h > >>new file mode 100644 > >>index 000..8f8e60e > >>--- /dev/null > >>+++ b/include/uapi/drm/rockchip_drm.h > >>@@ -0,0 +1,97 @@ > >>+/* > >>+ * > >>+ * Copyright (c) Fuzhou Rockchip Electronics Co.Ltd > >>+ * Authors: > >>+ * Mark Yao > >>+ * > >>+ * base on exynos_drm.h > >>+ * > >>+ * This program is free software; you can redistribute it and/or modify it > >>+ * under the terms of the GNU General Public License as published by the > >>+ * Free Software Foundation; either version 2 of the License, or (at your > >>+ * option) any later version. > >>+ */ > >>+ > >>+#ifndef _UAPI_ROCKCHIP_DRM_H > >>+#define _UAPI_ROCKCHIP_DRM_H > >>+ > >>+#include > >>+ > >>+/** > >>+ * User-desired buffer creation information structure. > >>+ * > >>+ * @size: user-desired memory allocation size. > >>+ * @flags: user request for setting memory type or cache attributes. > >>+ * @handle: returned a handle to created gem object. > >>+ * - this handle will be set by gem module of kernel side. > >>+ */ > >>+struct drm_rockchip_gem_create { > >>+ uint64_t size; > >>+ uint32_t flags; > >>+ uint32_t handle; > >>+}; > >>+ > >>+/** > >>+ * A structure for getting buffer offset. > >>+ * > >>+ * @handle: a pointer to gem object created. > >>+ * @pad: just padding to be 64-bit aligned. > >>+ * @offset: relatived offset value of the memory region allocated. > >>+ * - this value should be set by user. > >>+ */ > >>+struct drm_rockchip_gem_map_off { > >>+ uint32_t handle; > >>+ uint32_t pad; > >>+ uint64_t offset; > >>+}; > >>+ > >>+/** > >>+ * A structure for mapping buffer. > >>+ * > >>+ * @handle: a handle to gem object created. > >>+ * @pad: just padding to be 64-bit aligned. > >>+ * @size: memory size to be mapped. > >>+ * @mapped: having user virtual address mmaped. > >>+ * - this variable would be filled by rockchip gem module > >>+ * of kernel side with user virtual address which is allocated > >>+ * by do_mmap(). > >>+ */ > >>+struct drm_rockchip_gem_mmap { > >>+ uint32_t handle; > >>+ uint32_t pad; > >>+ uint64_t size; > >>+ uint64_t mapped; > >>+}; > >Could we do without the mmap ioctl? It has been a source of problems > >in other drivers, and the ioctl to get mmap offset, plus normal mmap() > >on drm device file should be sufficient > > > >BR, > >-R > OK, I will try to move the special mmap ioctl and use drm generic mmap > interface. Actually you probably should drop all this and just implement the dummy object support for now. Until you have proper hw accel there's no reason to expose a driver-private gem create/mmap interface at all. A pure kms driver really shouldn't have it's on uapi/foo_drm.h file. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v3 1/5] drm/rockchip: Add basic drm driver
On Mon, Sep 22, 2014 at 09:32:19AM +0800, Mark yao wrote: On 2014年09月20日 08:03, Rob Clark wrote: On Fri, Sep 19, 2014 at 1:47 AM, Mark yao mark@rock-chips.com wrote: diff --git a/include/uapi/drm/rockchip_drm.h b/include/uapi/drm/rockchip_drm.h new file mode 100644 index 000..8f8e60e --- /dev/null +++ b/include/uapi/drm/rockchip_drm.h @@ -0,0 +1,97 @@ +/* + * + * Copyright (c) Fuzhou Rockchip Electronics Co.Ltd + * Authors: + * Mark Yao y...@rock-chips.com + * + * base on exynos_drm.h + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#ifndef _UAPI_ROCKCHIP_DRM_H +#define _UAPI_ROCKCHIP_DRM_H + +#include drm/drm.h + +/** + * User-desired buffer creation information structure. + * + * @size: user-desired memory allocation size. + * @flags: user request for setting memory type or cache attributes. + * @handle: returned a handle to created gem object. + * - this handle will be set by gem module of kernel side. + */ +struct drm_rockchip_gem_create { + uint64_t size; + uint32_t flags; + uint32_t handle; +}; + +/** + * A structure for getting buffer offset. + * + * @handle: a pointer to gem object created. + * @pad: just padding to be 64-bit aligned. + * @offset: relatived offset value of the memory region allocated. + * - this value should be set by user. + */ +struct drm_rockchip_gem_map_off { + uint32_t handle; + uint32_t pad; + uint64_t offset; +}; + +/** + * A structure for mapping buffer. + * + * @handle: a handle to gem object created. + * @pad: just padding to be 64-bit aligned. + * @size: memory size to be mapped. + * @mapped: having user virtual address mmaped. + * - this variable would be filled by rockchip gem module + * of kernel side with user virtual address which is allocated + * by do_mmap(). + */ +struct drm_rockchip_gem_mmap { + uint32_t handle; + uint32_t pad; + uint64_t size; + uint64_t mapped; +}; Could we do without the mmap ioctl? It has been a source of problems in other drivers, and the ioctl to get mmap offset, plus normal mmap() on drm device file should be sufficient BR, -R OK, I will try to move the special mmap ioctl and use drm generic mmap interface. Actually you probably should drop all this and just implement the dummy object support for now. Until you have proper hw accel there's no reason to expose a driver-private gem create/mmap interface at all. A pure kms driver really shouldn't have it's on uapi/foo_drm.h file. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v3 1/5] drm/rockchip: Add basic drm driver
On 2014年09月23日 15:48, Daniel Vetter wrote: On Mon, Sep 22, 2014 at 09:32:19AM +0800, Mark yao wrote: On 2014年09月20日 08:03, Rob Clark wrote: On Fri, Sep 19, 2014 at 1:47 AM, Mark yao mark@rock-chips.com wrote: diff --git a/include/uapi/drm/rockchip_drm.h b/include/uapi/drm/rockchip_drm.h new file mode 100644 index 000..8f8e60e --- /dev/null +++ b/include/uapi/drm/rockchip_drm.h @@ -0,0 +1,97 @@ +/* + * + * Copyright (c) Fuzhou Rockchip Electronics Co.Ltd + * Authors: + * Mark Yao y...@rock-chips.com + * + * base on exynos_drm.h + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#ifndef _UAPI_ROCKCHIP_DRM_H +#define _UAPI_ROCKCHIP_DRM_H + +#include drm/drm.h + +/** + * User-desired buffer creation information structure. + * + * @size: user-desired memory allocation size. + * @flags: user request for setting memory type or cache attributes. + * @handle: returned a handle to created gem object. + * - this handle will be set by gem module of kernel side. + */ +struct drm_rockchip_gem_create { + uint64_t size; + uint32_t flags; + uint32_t handle; +}; + +/** + * A structure for getting buffer offset. + * + * @handle: a pointer to gem object created. + * @pad: just padding to be 64-bit aligned. + * @offset: relatived offset value of the memory region allocated. + * - this value should be set by user. + */ +struct drm_rockchip_gem_map_off { + uint32_t handle; + uint32_t pad; + uint64_t offset; +}; + +/** + * A structure for mapping buffer. + * + * @handle: a handle to gem object created. + * @pad: just padding to be 64-bit aligned. + * @size: memory size to be mapped. + * @mapped: having user virtual address mmaped. + * - this variable would be filled by rockchip gem module + * of kernel side with user virtual address which is allocated + * by do_mmap(). + */ +struct drm_rockchip_gem_mmap { + uint32_t handle; + uint32_t pad; + uint64_t size; + uint64_t mapped; +}; Could we do without the mmap ioctl? It has been a source of problems in other drivers, and the ioctl to get mmap offset, plus normal mmap() on drm device file should be sufficient BR, -R OK, I will try to move the special mmap ioctl and use drm generic mmap interface. Actually you probably should drop all this and just implement the dummy object support for now. Until you have proper hw accel there's no reason to expose a driver-private gem create/mmap interface at all. A pure kms driver really shouldn't have it's on uapi/foo_drm.h file. -Daniel right, I will try to do it. -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v3 1/5] drm/rockchip: Add basic drm driver
On 2014年09月20日 08:03, Rob Clark wrote: On Fri, Sep 19, 2014 at 1:47 AM, Mark yao wrote: diff --git a/include/uapi/drm/rockchip_drm.h b/include/uapi/drm/rockchip_drm.h new file mode 100644 index 000..8f8e60e --- /dev/null +++ b/include/uapi/drm/rockchip_drm.h @@ -0,0 +1,97 @@ +/* + * + * Copyright (c) Fuzhou Rockchip Electronics Co.Ltd + * Authors: + * Mark Yao + * + * base on exynos_drm.h + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#ifndef _UAPI_ROCKCHIP_DRM_H +#define _UAPI_ROCKCHIP_DRM_H + +#include + +/** + * User-desired buffer creation information structure. + * + * @size: user-desired memory allocation size. + * @flags: user request for setting memory type or cache attributes. + * @handle: returned a handle to created gem object. + * - this handle will be set by gem module of kernel side. + */ +struct drm_rockchip_gem_create { + uint64_t size; + uint32_t flags; + uint32_t handle; +}; + +/** + * A structure for getting buffer offset. + * + * @handle: a pointer to gem object created. + * @pad: just padding to be 64-bit aligned. + * @offset: relatived offset value of the memory region allocated. + * - this value should be set by user. + */ +struct drm_rockchip_gem_map_off { + uint32_t handle; + uint32_t pad; + uint64_t offset; +}; + +/** + * A structure for mapping buffer. + * + * @handle: a handle to gem object created. + * @pad: just padding to be 64-bit aligned. + * @size: memory size to be mapped. + * @mapped: having user virtual address mmaped. + * - this variable would be filled by rockchip gem module + * of kernel side with user virtual address which is allocated + * by do_mmap(). + */ +struct drm_rockchip_gem_mmap { + uint32_t handle; + uint32_t pad; + uint64_t size; + uint64_t mapped; +}; Could we do without the mmap ioctl? It has been a source of problems in other drivers, and the ioctl to get mmap offset, plus normal mmap() on drm device file should be sufficient BR, -R OK, I will try to move the special mmap ioctl and use drm generic mmap interface. +/** + * A structure to gem information. + * + * @handle: a handle to gem object created. + * @flags: flag value including memory type and cache attribute and + * this value would be set by driver. + * @size: size to memory region allocated by gem and this size would + * be set by driver. + */ +struct drm_rockchip_gem_info { + uint32_t handle; + uint32_t flags; + uint64_t size; +}; + +#define DRM_ROCKCHIP_GEM_CREATE0x00 +#define DRM_ROCKCHIP_GEM_MAP_OFFSET0x01 +#define DRM_ROCKCHIP_GEM_MMAP 0x02 +#define DRM_ROCKCHIP_GEM_GET 0x04 + +#define DRM_IOCTL_ROCKCHIP_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + \ + DRM_ROCKCHIP_GEM_CREATE, struct drm_rockchip_gem_create) + +#define DRM_IOCTL_ROCKCHIP_GEM_MAP_OFFSET DRM_IOWR(DRM_COMMAND_BASE + \ + DRM_ROCKCHIP_GEM_MAP_OFFSET, struct drm_rockchip_gem_map_off) + +#define DRM_IOCTL_ROCKCHIP_GEM_MMAPDRM_IOWR(DRM_COMMAND_BASE + \ + DRM_ROCKCHIP_GEM_MMAP, struct drm_rockchip_gem_mmap) + +#define DRM_IOCTL_ROCKCHIP_GEM_GET DRM_IOWR(DRM_COMMAND_BASE + \ + DRM_ROCKCHIP_GEM_GET, struct drm_rockchip_gem_info) +#endif /* _UAPI_ROCKCHIP_DRM_H */ -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v3 1/5] drm/rockchip: Add basic drm driver
On 2014年09月19日 21:04, David Herrmann wrote: Hi On Fri, Sep 19, 2014 at 7:47 AM, Mark yao wrote: [snip] +static int rockchip_drm_bind(struct device *dev) +{ + return drm_platform_init(_drm_driver, to_platform_device(dev)); Please avoid drm_platform_*() usage. We're about to drop all the drm_bus midlayers. See the tegra driver how to do it, but basically just this: OK, I will do it. struct drm_device *ddev; ddev = drm_dev_alloc(_drm_driver, _platform_device(dev)->dev); if (!ddev) return -ENOMEM; r = drm_dev_set_unique(ddev, dev_name(>dev)); if (r < 0) { drm_dev_unref(ddev); return r; } r = drm_dev_register(ddev); if (r < 0) { drm_dev_unref(ddev); return r; } +} + +static void rockchip_drm_unbind(struct device *dev) +{ + drm_put_dev(dev_get_drvdata(dev)); Please use: struct drm_device *ddev = dev_get_drvdata(dev); drm_dev_unregister(ddev); drm_dev_unref(ddev); Thanks David -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v3 1/5] drm/rockchip: Add basic drm driver
On 2014年09月19日 21:04, David Herrmann wrote: Hi On Fri, Sep 19, 2014 at 7:47 AM, Mark yao mark@rock-chips.com wrote: [snip] +static int rockchip_drm_bind(struct device *dev) +{ + return drm_platform_init(rockchip_drm_driver, to_platform_device(dev)); Please avoid drm_platform_*() usage. We're about to drop all the drm_bus midlayers. See the tegra driver how to do it, but basically just this: OK, I will do it. struct drm_device *ddev; ddev = drm_dev_alloc(rockchip_drm_driver, to_platform_device(dev)-dev); if (!ddev) return -ENOMEM; r = drm_dev_set_unique(ddev, dev_name(ddev-dev)); if (r 0) { drm_dev_unref(ddev); return r; } r = drm_dev_register(ddev); if (r 0) { drm_dev_unref(ddev); return r; } +} + +static void rockchip_drm_unbind(struct device *dev) +{ + drm_put_dev(dev_get_drvdata(dev)); Please use: struct drm_device *ddev = dev_get_drvdata(dev); drm_dev_unregister(ddev); drm_dev_unref(ddev); Thanks David -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v3 1/5] drm/rockchip: Add basic drm driver
On 2014年09月20日 08:03, Rob Clark wrote: On Fri, Sep 19, 2014 at 1:47 AM, Mark yao mark@rock-chips.com wrote: diff --git a/include/uapi/drm/rockchip_drm.h b/include/uapi/drm/rockchip_drm.h new file mode 100644 index 000..8f8e60e --- /dev/null +++ b/include/uapi/drm/rockchip_drm.h @@ -0,0 +1,97 @@ +/* + * + * Copyright (c) Fuzhou Rockchip Electronics Co.Ltd + * Authors: + * Mark Yao y...@rock-chips.com + * + * base on exynos_drm.h + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#ifndef _UAPI_ROCKCHIP_DRM_H +#define _UAPI_ROCKCHIP_DRM_H + +#include drm/drm.h + +/** + * User-desired buffer creation information structure. + * + * @size: user-desired memory allocation size. + * @flags: user request for setting memory type or cache attributes. + * @handle: returned a handle to created gem object. + * - this handle will be set by gem module of kernel side. + */ +struct drm_rockchip_gem_create { + uint64_t size; + uint32_t flags; + uint32_t handle; +}; + +/** + * A structure for getting buffer offset. + * + * @handle: a pointer to gem object created. + * @pad: just padding to be 64-bit aligned. + * @offset: relatived offset value of the memory region allocated. + * - this value should be set by user. + */ +struct drm_rockchip_gem_map_off { + uint32_t handle; + uint32_t pad; + uint64_t offset; +}; + +/** + * A structure for mapping buffer. + * + * @handle: a handle to gem object created. + * @pad: just padding to be 64-bit aligned. + * @size: memory size to be mapped. + * @mapped: having user virtual address mmaped. + * - this variable would be filled by rockchip gem module + * of kernel side with user virtual address which is allocated + * by do_mmap(). + */ +struct drm_rockchip_gem_mmap { + uint32_t handle; + uint32_t pad; + uint64_t size; + uint64_t mapped; +}; Could we do without the mmap ioctl? It has been a source of problems in other drivers, and the ioctl to get mmap offset, plus normal mmap() on drm device file should be sufficient BR, -R OK, I will try to move the special mmap ioctl and use drm generic mmap interface. +/** + * A structure to gem information. + * + * @handle: a handle to gem object created. + * @flags: flag value including memory type and cache attribute and + * this value would be set by driver. + * @size: size to memory region allocated by gem and this size would + * be set by driver. + */ +struct drm_rockchip_gem_info { + uint32_t handle; + uint32_t flags; + uint64_t size; +}; + +#define DRM_ROCKCHIP_GEM_CREATE0x00 +#define DRM_ROCKCHIP_GEM_MAP_OFFSET0x01 +#define DRM_ROCKCHIP_GEM_MMAP 0x02 +#define DRM_ROCKCHIP_GEM_GET 0x04 + +#define DRM_IOCTL_ROCKCHIP_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + \ + DRM_ROCKCHIP_GEM_CREATE, struct drm_rockchip_gem_create) + +#define DRM_IOCTL_ROCKCHIP_GEM_MAP_OFFSET DRM_IOWR(DRM_COMMAND_BASE + \ + DRM_ROCKCHIP_GEM_MAP_OFFSET, struct drm_rockchip_gem_map_off) + +#define DRM_IOCTL_ROCKCHIP_GEM_MMAPDRM_IOWR(DRM_COMMAND_BASE + \ + DRM_ROCKCHIP_GEM_MMAP, struct drm_rockchip_gem_mmap) + +#define DRM_IOCTL_ROCKCHIP_GEM_GET DRM_IOWR(DRM_COMMAND_BASE + \ + DRM_ROCKCHIP_GEM_GET, struct drm_rockchip_gem_info) +#endif /* _UAPI_ROCKCHIP_DRM_H */ -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v3 1/5] drm/rockchip: Add basic drm driver
On Fri, Sep 19, 2014 at 1:47 AM, Mark yao wrote: > diff --git a/include/uapi/drm/rockchip_drm.h b/include/uapi/drm/rockchip_drm.h > new file mode 100644 > index 000..8f8e60e > --- /dev/null > +++ b/include/uapi/drm/rockchip_drm.h > @@ -0,0 +1,97 @@ > +/* > + * > + * Copyright (c) Fuzhou Rockchip Electronics Co.Ltd > + * Authors: > + * Mark Yao > + * > + * base on exynos_drm.h > + * > + * This program is free software; you can redistribute it and/or modify it > + * under the terms of the GNU General Public License as published by the > + * Free Software Foundation; either version 2 of the License, or (at your > + * option) any later version. > + */ > + > +#ifndef _UAPI_ROCKCHIP_DRM_H > +#define _UAPI_ROCKCHIP_DRM_H > + > +#include > + > +/** > + * User-desired buffer creation information structure. > + * > + * @size: user-desired memory allocation size. > + * @flags: user request for setting memory type or cache attributes. > + * @handle: returned a handle to created gem object. > + * - this handle will be set by gem module of kernel side. > + */ > +struct drm_rockchip_gem_create { > + uint64_t size; > + uint32_t flags; > + uint32_t handle; > +}; > + > +/** > + * A structure for getting buffer offset. > + * > + * @handle: a pointer to gem object created. > + * @pad: just padding to be 64-bit aligned. > + * @offset: relatived offset value of the memory region allocated. > + * - this value should be set by user. > + */ > +struct drm_rockchip_gem_map_off { > + uint32_t handle; > + uint32_t pad; > + uint64_t offset; > +}; > + > +/** > + * A structure for mapping buffer. > + * > + * @handle: a handle to gem object created. > + * @pad: just padding to be 64-bit aligned. > + * @size: memory size to be mapped. > + * @mapped: having user virtual address mmaped. > + * - this variable would be filled by rockchip gem module > + * of kernel side with user virtual address which is allocated > + * by do_mmap(). > + */ > +struct drm_rockchip_gem_mmap { > + uint32_t handle; > + uint32_t pad; > + uint64_t size; > + uint64_t mapped; > +}; Could we do without the mmap ioctl? It has been a source of problems in other drivers, and the ioctl to get mmap offset, plus normal mmap() on drm device file should be sufficient BR, -R > +/** > + * A structure to gem information. > + * > + * @handle: a handle to gem object created. > + * @flags: flag value including memory type and cache attribute and > + * this value would be set by driver. > + * @size: size to memory region allocated by gem and this size would > + * be set by driver. > + */ > +struct drm_rockchip_gem_info { > + uint32_t handle; > + uint32_t flags; > + uint64_t size; > +}; > + > +#define DRM_ROCKCHIP_GEM_CREATE0x00 > +#define DRM_ROCKCHIP_GEM_MAP_OFFSET0x01 > +#define DRM_ROCKCHIP_GEM_MMAP 0x02 > +#define DRM_ROCKCHIP_GEM_GET 0x04 > + > +#define DRM_IOCTL_ROCKCHIP_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + \ > + DRM_ROCKCHIP_GEM_CREATE, struct drm_rockchip_gem_create) > + > +#define DRM_IOCTL_ROCKCHIP_GEM_MAP_OFFSET DRM_IOWR(DRM_COMMAND_BASE + \ > + DRM_ROCKCHIP_GEM_MAP_OFFSET, struct drm_rockchip_gem_map_off) > + > +#define DRM_IOCTL_ROCKCHIP_GEM_MMAPDRM_IOWR(DRM_COMMAND_BASE + \ > + DRM_ROCKCHIP_GEM_MMAP, struct drm_rockchip_gem_mmap) > + > +#define DRM_IOCTL_ROCKCHIP_GEM_GET DRM_IOWR(DRM_COMMAND_BASE + \ > + DRM_ROCKCHIP_GEM_GET, struct drm_rockchip_gem_info) > +#endif /* _UAPI_ROCKCHIP_DRM_H */ -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v3 1/5] drm/rockchip: Add basic drm driver
Hi On Fri, Sep 19, 2014 at 7:47 AM, Mark yao wrote: [snip] > +static int rockchip_drm_bind(struct device *dev) > +{ > + return drm_platform_init(_drm_driver, > to_platform_device(dev)); Please avoid drm_platform_*() usage. We're about to drop all the drm_bus midlayers. See the tegra driver how to do it, but basically just this: struct drm_device *ddev; ddev = drm_dev_alloc(_drm_driver, _platform_device(dev)->dev); if (!ddev) return -ENOMEM; r = drm_dev_set_unique(ddev, dev_name(>dev)); if (r < 0) { drm_dev_unref(ddev); return r; } r = drm_dev_register(ddev); if (r < 0) { drm_dev_unref(ddev); return r; } > +} > + > +static void rockchip_drm_unbind(struct device *dev) > +{ > + drm_put_dev(dev_get_drvdata(dev)); Please use: struct drm_device *ddev = dev_get_drvdata(dev); drm_dev_unregister(ddev); drm_dev_unref(ddev); Thanks David -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v3 1/5] drm/rockchip: Add basic drm driver
Hi On Fri, Sep 19, 2014 at 7:47 AM, Mark yao mark@rock-chips.com wrote: [snip] +static int rockchip_drm_bind(struct device *dev) +{ + return drm_platform_init(rockchip_drm_driver, to_platform_device(dev)); Please avoid drm_platform_*() usage. We're about to drop all the drm_bus midlayers. See the tegra driver how to do it, but basically just this: struct drm_device *ddev; ddev = drm_dev_alloc(rockchip_drm_driver, to_platform_device(dev)-dev); if (!ddev) return -ENOMEM; r = drm_dev_set_unique(ddev, dev_name(ddev-dev)); if (r 0) { drm_dev_unref(ddev); return r; } r = drm_dev_register(ddev); if (r 0) { drm_dev_unref(ddev); return r; } +} + +static void rockchip_drm_unbind(struct device *dev) +{ + drm_put_dev(dev_get_drvdata(dev)); Please use: struct drm_device *ddev = dev_get_drvdata(dev); drm_dev_unregister(ddev); drm_dev_unref(ddev); Thanks David -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v3 1/5] drm/rockchip: Add basic drm driver
On Fri, Sep 19, 2014 at 1:47 AM, Mark yao mark@rock-chips.com wrote: diff --git a/include/uapi/drm/rockchip_drm.h b/include/uapi/drm/rockchip_drm.h new file mode 100644 index 000..8f8e60e --- /dev/null +++ b/include/uapi/drm/rockchip_drm.h @@ -0,0 +1,97 @@ +/* + * + * Copyright (c) Fuzhou Rockchip Electronics Co.Ltd + * Authors: + * Mark Yao y...@rock-chips.com + * + * base on exynos_drm.h + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#ifndef _UAPI_ROCKCHIP_DRM_H +#define _UAPI_ROCKCHIP_DRM_H + +#include drm/drm.h + +/** + * User-desired buffer creation information structure. + * + * @size: user-desired memory allocation size. + * @flags: user request for setting memory type or cache attributes. + * @handle: returned a handle to created gem object. + * - this handle will be set by gem module of kernel side. + */ +struct drm_rockchip_gem_create { + uint64_t size; + uint32_t flags; + uint32_t handle; +}; + +/** + * A structure for getting buffer offset. + * + * @handle: a pointer to gem object created. + * @pad: just padding to be 64-bit aligned. + * @offset: relatived offset value of the memory region allocated. + * - this value should be set by user. + */ +struct drm_rockchip_gem_map_off { + uint32_t handle; + uint32_t pad; + uint64_t offset; +}; + +/** + * A structure for mapping buffer. + * + * @handle: a handle to gem object created. + * @pad: just padding to be 64-bit aligned. + * @size: memory size to be mapped. + * @mapped: having user virtual address mmaped. + * - this variable would be filled by rockchip gem module + * of kernel side with user virtual address which is allocated + * by do_mmap(). + */ +struct drm_rockchip_gem_mmap { + uint32_t handle; + uint32_t pad; + uint64_t size; + uint64_t mapped; +}; Could we do without the mmap ioctl? It has been a source of problems in other drivers, and the ioctl to get mmap offset, plus normal mmap() on drm device file should be sufficient BR, -R +/** + * A structure to gem information. + * + * @handle: a handle to gem object created. + * @flags: flag value including memory type and cache attribute and + * this value would be set by driver. + * @size: size to memory region allocated by gem and this size would + * be set by driver. + */ +struct drm_rockchip_gem_info { + uint32_t handle; + uint32_t flags; + uint64_t size; +}; + +#define DRM_ROCKCHIP_GEM_CREATE0x00 +#define DRM_ROCKCHIP_GEM_MAP_OFFSET0x01 +#define DRM_ROCKCHIP_GEM_MMAP 0x02 +#define DRM_ROCKCHIP_GEM_GET 0x04 + +#define DRM_IOCTL_ROCKCHIP_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + \ + DRM_ROCKCHIP_GEM_CREATE, struct drm_rockchip_gem_create) + +#define DRM_IOCTL_ROCKCHIP_GEM_MAP_OFFSET DRM_IOWR(DRM_COMMAND_BASE + \ + DRM_ROCKCHIP_GEM_MAP_OFFSET, struct drm_rockchip_gem_map_off) + +#define DRM_IOCTL_ROCKCHIP_GEM_MMAPDRM_IOWR(DRM_COMMAND_BASE + \ + DRM_ROCKCHIP_GEM_MMAP, struct drm_rockchip_gem_mmap) + +#define DRM_IOCTL_ROCKCHIP_GEM_GET DRM_IOWR(DRM_COMMAND_BASE + \ + DRM_ROCKCHIP_GEM_GET, struct drm_rockchip_gem_info) +#endif /* _UAPI_ROCKCHIP_DRM_H */ -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v3 1/5] drm/rockchip: Add basic drm driver
This patch adds the basic structure of a DRM Driver for Rockchip Socs. Signed-off-by: Mark yao --- Changes in v2: - use the component framework to defer main drm driver probe until all VOP devices have been probed. - use dma-mapping API with ARM_DMA_USE_IOMMU, create dma mapping by master device and each vop device can shared the drm dma mapping. - use drm_crtc_init_with_planes and drm_universal_plane_init. - remove unnecessary middle layers. - add cursor set, move funcs to rockchip drm crtc. - use vop reset at first init - reference framebuffer when used and unreference when swap out vop Changes in v3: - change "crtc->fb" to "crtc->primary-fb" Adviced by Daniel Vetter - init cursor plane with universal api, remove unnecessary cursor set,move drivers/gpu/drm/Kconfig |2 + drivers/gpu/drm/Makefile |1 + drivers/gpu/drm/rockchip/Kconfig | 19 + drivers/gpu/drm/rockchip/Makefile | 10 + drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 502 + drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 120 +++ drivers/gpu/drm/rockchip/rockchip_drm_fb.c| 201 drivers/gpu/drm/rockchip/rockchip_drm_fb.h| 28 + drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c | 231 + drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h | 20 + drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 405 drivers/gpu/drm/rockchip/rockchip_drm_gem.h | 76 ++ drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 1372 + drivers/gpu/drm/rockchip/rockchip_drm_vop.h | 187 include/uapi/drm/rockchip_drm.h | 97 ++ 15 files changed, 3271 insertions(+) create mode 100644 drivers/gpu/drm/rockchip/Kconfig create mode 100644 drivers/gpu/drm/rockchip/Makefile create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_drv.c create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_drv.h create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fb.c create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fb.h create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_gem.c create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_gem.h create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_vop.c create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_vop.h create mode 100644 include/uapi/drm/rockchip_drm.h diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index b066bb3..7c4c3c6 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -171,6 +171,8 @@ config DRM_SAVAGE source "drivers/gpu/drm/exynos/Kconfig" +source "drivers/gpu/drm/rockchip/Kconfig" + source "drivers/gpu/drm/vmwgfx/Kconfig" source "drivers/gpu/drm/gma500/Kconfig" diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index 4a55d59..d03387a 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -52,6 +52,7 @@ obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/ obj-$(CONFIG_DRM_VIA) +=via/ obj-$(CONFIG_DRM_NOUVEAU) +=nouveau/ obj-$(CONFIG_DRM_EXYNOS) +=exynos/ +obj-$(CONFIG_DRM_ROCKCHIP) +=rockchip/ obj-$(CONFIG_DRM_GMA500) += gma500/ obj-$(CONFIG_DRM_UDL) += udl/ obj-$(CONFIG_DRM_AST) += ast/ diff --git a/drivers/gpu/drm/rockchip/Kconfig b/drivers/gpu/drm/rockchip/Kconfig new file mode 100644 index 000..7146c80 --- /dev/null +++ b/drivers/gpu/drm/rockchip/Kconfig @@ -0,0 +1,19 @@ +config DRM_ROCKCHIP + tristate "DRM Support for Rockchip" + depends on DRM && ROCKCHIP_IOMMU + select ARM_DMA_USE_IOMMU + select IOMMU_API + select DRM_KMS_HELPER + select DRM_KMS_FB_HELPER + select DRM_PANEL + select FB_CFB_FILLRECT + select FB_CFB_COPYAREA + select FB_CFB_IMAGEBLIT + select VT_HW_CONSOLE_BINDING if FRAMEBUFFER_CONSOLE + select VIDEOMODE_HELPERS + help + Choose this option if you have a Rockchip soc chipset. + This driver provides kernel mode setting and buffer + management to userspace. This driver does not provides + 2D or 3D acceleration; acceleration is performed by other + IP found on the SoC. diff --git a/drivers/gpu/drm/rockchip/Makefile b/drivers/gpu/drm/rockchip/Makefile new file mode 100644 index 000..6e6d468 --- /dev/null +++ b/drivers/gpu/drm/rockchip/Makefile @@ -0,0 +1,10 @@ +# +# Makefile for the drm device driver. This driver provides support for the +# Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher. + +ccflags-y := -Iinclude/drm -Idrivers/gpu/drm/rockchip + +rockchipdrm-y := rockchip_drm_drv.o rockchip_drm_fb.o rockchip_drm_fbdev.o \ + rockchip_drm_gem.o rockchip_drm_vop.o + +obj-$(CONFIG_DRM_ROCKCHIP) += rockchipdrm.o diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c new file mode 100644 index 000..f84dcd8 ---
[PATCH v3 1/5] drm/rockchip: Add basic drm driver
This patch adds the basic structure of a DRM Driver for Rockchip Socs. Signed-off-by: Mark yao mark@rock-chips.com --- Changes in v2: - use the component framework to defer main drm driver probe until all VOP devices have been probed. - use dma-mapping API with ARM_DMA_USE_IOMMU, create dma mapping by master device and each vop device can shared the drm dma mapping. - use drm_crtc_init_with_planes and drm_universal_plane_init. - remove unnecessary middle layers. - add cursor set, move funcs to rockchip drm crtc. - use vop reset at first init - reference framebuffer when used and unreference when swap out vop Changes in v3: - change crtc-fb to crtc-primary-fb Adviced by Daniel Vetter - init cursor plane with universal api, remove unnecessary cursor set,move drivers/gpu/drm/Kconfig |2 + drivers/gpu/drm/Makefile |1 + drivers/gpu/drm/rockchip/Kconfig | 19 + drivers/gpu/drm/rockchip/Makefile | 10 + drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 502 + drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 120 +++ drivers/gpu/drm/rockchip/rockchip_drm_fb.c| 201 drivers/gpu/drm/rockchip/rockchip_drm_fb.h| 28 + drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c | 231 + drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h | 20 + drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 405 drivers/gpu/drm/rockchip/rockchip_drm_gem.h | 76 ++ drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 1372 + drivers/gpu/drm/rockchip/rockchip_drm_vop.h | 187 include/uapi/drm/rockchip_drm.h | 97 ++ 15 files changed, 3271 insertions(+) create mode 100644 drivers/gpu/drm/rockchip/Kconfig create mode 100644 drivers/gpu/drm/rockchip/Makefile create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_drv.c create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_drv.h create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fb.c create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fb.h create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_gem.c create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_gem.h create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_vop.c create mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_vop.h create mode 100644 include/uapi/drm/rockchip_drm.h diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index b066bb3..7c4c3c6 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -171,6 +171,8 @@ config DRM_SAVAGE source drivers/gpu/drm/exynos/Kconfig +source drivers/gpu/drm/rockchip/Kconfig + source drivers/gpu/drm/vmwgfx/Kconfig source drivers/gpu/drm/gma500/Kconfig diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index 4a55d59..d03387a 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -52,6 +52,7 @@ obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/ obj-$(CONFIG_DRM_VIA) +=via/ obj-$(CONFIG_DRM_NOUVEAU) +=nouveau/ obj-$(CONFIG_DRM_EXYNOS) +=exynos/ +obj-$(CONFIG_DRM_ROCKCHIP) +=rockchip/ obj-$(CONFIG_DRM_GMA500) += gma500/ obj-$(CONFIG_DRM_UDL) += udl/ obj-$(CONFIG_DRM_AST) += ast/ diff --git a/drivers/gpu/drm/rockchip/Kconfig b/drivers/gpu/drm/rockchip/Kconfig new file mode 100644 index 000..7146c80 --- /dev/null +++ b/drivers/gpu/drm/rockchip/Kconfig @@ -0,0 +1,19 @@ +config DRM_ROCKCHIP + tristate DRM Support for Rockchip + depends on DRM ROCKCHIP_IOMMU + select ARM_DMA_USE_IOMMU + select IOMMU_API + select DRM_KMS_HELPER + select DRM_KMS_FB_HELPER + select DRM_PANEL + select FB_CFB_FILLRECT + select FB_CFB_COPYAREA + select FB_CFB_IMAGEBLIT + select VT_HW_CONSOLE_BINDING if FRAMEBUFFER_CONSOLE + select VIDEOMODE_HELPERS + help + Choose this option if you have a Rockchip soc chipset. + This driver provides kernel mode setting and buffer + management to userspace. This driver does not provides + 2D or 3D acceleration; acceleration is performed by other + IP found on the SoC. diff --git a/drivers/gpu/drm/rockchip/Makefile b/drivers/gpu/drm/rockchip/Makefile new file mode 100644 index 000..6e6d468 --- /dev/null +++ b/drivers/gpu/drm/rockchip/Makefile @@ -0,0 +1,10 @@ +# +# Makefile for the drm device driver. This driver provides support for the +# Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher. + +ccflags-y := -Iinclude/drm -Idrivers/gpu/drm/rockchip + +rockchipdrm-y := rockchip_drm_drv.o rockchip_drm_fb.o rockchip_drm_fbdev.o \ + rockchip_drm_gem.o rockchip_drm_vop.o + +obj-$(CONFIG_DRM_ROCKCHIP) += rockchipdrm.o diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c new file mode 100644 index 000..f84dcd8 ---