Re: [Intel-gfx] [PATCH v2 1/3] drm/i915/gvt: Add framebuffer decoder support
On 2017.07.17 11:06:24 +0800, Tina Zhang wrote: > Framebuffer decoder returns guest framebuffer information. > Guest framebuffer includes primary, cursor and sprite plane. > > Signed-off-by: Xiaoguang Chen > Signed-off-by: Tina Zhang > --- > drivers/gpu/drm/i915/gvt/Makefile | 3 +- > drivers/gpu/drm/i915/gvt/display.c| 2 +- > drivers/gpu/drm/i915/gvt/display.h| 2 + > drivers/gpu/drm/i915/gvt/fb_decoder.c | 429 > ++ > drivers/gpu/drm/i915/gvt/fb_decoder.h | 175 ++ > drivers/gpu/drm/i915/gvt/gvt.h| 1 + > 6 files changed, 610 insertions(+), 2 deletions(-) > create mode 100644 drivers/gpu/drm/i915/gvt/fb_decoder.c > create mode 100644 drivers/gpu/drm/i915/gvt/fb_decoder.h > > diff --git a/drivers/gpu/drm/i915/gvt/Makefile > b/drivers/gpu/drm/i915/gvt/Makefile > index f5486cb9..019d596 100644 > --- a/drivers/gpu/drm/i915/gvt/Makefile > +++ b/drivers/gpu/drm/i915/gvt/Makefile > @@ -1,7 +1,8 @@ > GVT_DIR := gvt > GVT_SOURCE := gvt.o aperture_gm.o handlers.o vgpu.o trace_points.o > firmware.o \ > interrupt.o gtt.o cfg_space.o opregion.o mmio.o display.o edid.o \ > - execlist.o scheduler.o sched_policy.o render.o cmd_parser.o > + execlist.o scheduler.o sched_policy.o render.o cmd_parser.o \ > + fb_decoder.o > > ccflags-y+= -I$(src) -I$(src)/$(GVT_DIR) > i915-y += $(addprefix $(GVT_DIR)/, > $(GVT_SOURCE)) > diff --git a/drivers/gpu/drm/i915/gvt/display.c > b/drivers/gpu/drm/i915/gvt/display.c > index 2deb05f..58d90cf 100644 > --- a/drivers/gpu/drm/i915/gvt/display.c > +++ b/drivers/gpu/drm/i915/gvt/display.c > @@ -67,7 +67,7 @@ static int edp_pipe_is_enabled(struct intel_vgpu *vgpu) > return 1; > } > > -static int pipe_is_enabled(struct intel_vgpu *vgpu, int pipe) > +int pipe_is_enabled(struct intel_vgpu *vgpu, int pipe) > { > struct drm_i915_private *dev_priv = vgpu->gvt->dev_priv; > > diff --git a/drivers/gpu/drm/i915/gvt/display.h > b/drivers/gpu/drm/i915/gvt/display.h > index d73de22..b46b868 100644 > --- a/drivers/gpu/drm/i915/gvt/display.h > +++ b/drivers/gpu/drm/i915/gvt/display.h > @@ -179,4 +179,6 @@ int intel_vgpu_init_display(struct intel_vgpu *vgpu, u64 > resolution); > void intel_vgpu_reset_display(struct intel_vgpu *vgpu); > void intel_vgpu_clean_display(struct intel_vgpu *vgpu); > > +int pipe_is_enabled(struct intel_vgpu *vgpu, int pipe); > + > #endif > diff --git a/drivers/gpu/drm/i915/gvt/fb_decoder.c > b/drivers/gpu/drm/i915/gvt/fb_decoder.c > new file mode 100644 > index 000..2bd5b3c > --- /dev/null > +++ b/drivers/gpu/drm/i915/gvt/fb_decoder.c > @@ -0,0 +1,429 @@ > +/* > + * Copyright(c) 2011-2016 Intel Corporation. All rights reserved. > + * > + * Permission is hereby granted, free of charge, to any person obtaining a > + * copy of this software and associated documentation files (the "Software"), > + * to deal in the Software without restriction, including without limitation > + * the rights to use, copy, modify, merge, publish, distribute, sublicense, > + * and/or sell copies of the Software, and to permit persons to whom the > + * Software is furnished to do so, subject to the following conditions: > + * > + * The above copyright notice and this permission notice (including the next > + * paragraph) shall be included in all copies or substantial portions of the > + * Software. > + * > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING > FROM, > + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN > THE > + * SOFTWARE. > + * > + * Authors: > + *Kevin Tian > + * > + * Contributors: > + *Bing Niu > + *Xu Han > + *Ping Gao > + *Xiaoguang Chen > + *Yang Liu > + *Tina Zhang > + * > + */ > + > +#include > +#include "i915_drv.h" > +#include "gvt.h" > + > +#define PRIMARY_FORMAT_NUM 16 > +struct pixel_format { > + int drm_format; /* Pixel format in DRM definition */ > + int bpp;/* Bits per pixel, 0 indicates invalid */ > + char *desc; /* The description */ > +}; > + > +/* non-supported format has bpp default to 0 */ > +static struct pixel_format bdw_pixel_formats[PRIMARY_FORMAT_NUM] = { > + [0x2] = {DRM_FORMAT_C8, 8, "8-bit Indexed"}, > + [0x5] = {DRM_FORMAT_RGB565, 16, "16-bit BGRX (5:6:5 MSB-R:G:B)"}, > + [0x6] = {DRM_FORMAT_XRGB, 32, > + "32-bit BGRX (8:8:8:8 MSB-X:R:G:B)"}, > + [0x8] = {DRM_FORMAT_XBGR2101010, 32, > + "32-bit RGBX (2:10:10:10 MSB-X:B:G:R)"}, > + [0xa] = {DRM_FORMAT_XRGB2101010,
[Intel-gfx] [PATCH v2 1/3] drm/i915/gvt: Add framebuffer decoder support
Framebuffer decoder returns guest framebuffer information. Guest framebuffer includes primary, cursor and sprite plane. Signed-off-by: Xiaoguang Chen Signed-off-by: Tina Zhang --- drivers/gpu/drm/i915/gvt/Makefile | 3 +- drivers/gpu/drm/i915/gvt/display.c| 2 +- drivers/gpu/drm/i915/gvt/display.h| 2 + drivers/gpu/drm/i915/gvt/fb_decoder.c | 429 ++ drivers/gpu/drm/i915/gvt/fb_decoder.h | 175 ++ drivers/gpu/drm/i915/gvt/gvt.h| 1 + 6 files changed, 610 insertions(+), 2 deletions(-) create mode 100644 drivers/gpu/drm/i915/gvt/fb_decoder.c create mode 100644 drivers/gpu/drm/i915/gvt/fb_decoder.h diff --git a/drivers/gpu/drm/i915/gvt/Makefile b/drivers/gpu/drm/i915/gvt/Makefile index f5486cb9..019d596 100644 --- a/drivers/gpu/drm/i915/gvt/Makefile +++ b/drivers/gpu/drm/i915/gvt/Makefile @@ -1,7 +1,8 @@ GVT_DIR := gvt GVT_SOURCE := gvt.o aperture_gm.o handlers.o vgpu.o trace_points.o firmware.o \ interrupt.o gtt.o cfg_space.o opregion.o mmio.o display.o edid.o \ - execlist.o scheduler.o sched_policy.o render.o cmd_parser.o + execlist.o scheduler.o sched_policy.o render.o cmd_parser.o \ + fb_decoder.o ccflags-y += -I$(src) -I$(src)/$(GVT_DIR) i915-y += $(addprefix $(GVT_DIR)/, $(GVT_SOURCE)) diff --git a/drivers/gpu/drm/i915/gvt/display.c b/drivers/gpu/drm/i915/gvt/display.c index 2deb05f..58d90cf 100644 --- a/drivers/gpu/drm/i915/gvt/display.c +++ b/drivers/gpu/drm/i915/gvt/display.c @@ -67,7 +67,7 @@ static int edp_pipe_is_enabled(struct intel_vgpu *vgpu) return 1; } -static int pipe_is_enabled(struct intel_vgpu *vgpu, int pipe) +int pipe_is_enabled(struct intel_vgpu *vgpu, int pipe) { struct drm_i915_private *dev_priv = vgpu->gvt->dev_priv; diff --git a/drivers/gpu/drm/i915/gvt/display.h b/drivers/gpu/drm/i915/gvt/display.h index d73de22..b46b868 100644 --- a/drivers/gpu/drm/i915/gvt/display.h +++ b/drivers/gpu/drm/i915/gvt/display.h @@ -179,4 +179,6 @@ int intel_vgpu_init_display(struct intel_vgpu *vgpu, u64 resolution); void intel_vgpu_reset_display(struct intel_vgpu *vgpu); void intel_vgpu_clean_display(struct intel_vgpu *vgpu); +int pipe_is_enabled(struct intel_vgpu *vgpu, int pipe); + #endif diff --git a/drivers/gpu/drm/i915/gvt/fb_decoder.c b/drivers/gpu/drm/i915/gvt/fb_decoder.c new file mode 100644 index 000..2bd5b3c --- /dev/null +++ b/drivers/gpu/drm/i915/gvt/fb_decoder.c @@ -0,0 +1,429 @@ +/* + * Copyright(c) 2011-2016 Intel Corporation. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Authors: + *Kevin Tian + * + * Contributors: + *Bing Niu + *Xu Han + *Ping Gao + *Xiaoguang Chen + *Yang Liu + *Tina Zhang + * + */ + +#include +#include "i915_drv.h" +#include "gvt.h" + +#define PRIMARY_FORMAT_NUM 16 +struct pixel_format { + int drm_format; /* Pixel format in DRM definition */ + int bpp;/* Bits per pixel, 0 indicates invalid */ + char *desc; /* The description */ +}; + +/* non-supported format has bpp default to 0 */ +static struct pixel_format bdw_pixel_formats[PRIMARY_FORMAT_NUM] = { + [0x2] = {DRM_FORMAT_C8, 8, "8-bit Indexed"}, + [0x5] = {DRM_FORMAT_RGB565, 16, "16-bit BGRX (5:6:5 MSB-R:G:B)"}, + [0x6] = {DRM_FORMAT_XRGB, 32, + "32-bit BGRX (8:8:8:8 MSB-X:R:G:B)"}, + [0x8] = {DRM_FORMAT_XBGR2101010, 32, + "32-bit RGBX (2:10:10:10 MSB-X:B:G:R)"}, + [0xa] = {DRM_FORMAT_XRGB2101010, 32, + "32-bit BGRX (2:10:10:10 MSB-X:R:G:B)"}, + [0xe] = {DRM_FORMAT_XBGR, 32, + "32-bit RGBX (8:8:8:8 MSB-X:B:G:R)"}, +}; + +/* non-supported format has bpp default to 0 */ +static struct pixel_format skl_pixel_formats[] = { +