On Mon, Nov 16, 2009 at 6:09 PM, Dave Airlie <[email protected]> wrote:
> From: Dave Airlie <[email protected]>
>
> FB read/write really doesn't need to access the actual VRAM, we
> can just use a scratch area. This is required for using atom displayport
> calls later.
>
> Signed-off-by: Dave Airlie <[email protected]>

Acked-by: Alex Deucher <[email protected]>


> ---
>  drivers/gpu/drm/radeon/atom.c          |   32 
> ++++++++++++++++++++++++++++----
>  drivers/gpu/drm/radeon/atom.h          |    2 ++
>  drivers/gpu/drm/radeon/radeon_device.c |    2 ++
>  3 files changed, 32 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/atom.c b/drivers/gpu/drm/radeon/atom.c
> index d67c425..bbb2bc3 100644
> --- a/drivers/gpu/drm/radeon/atom.c
> +++ b/drivers/gpu/drm/radeon/atom.c
> @@ -263,10 +263,10 @@ static uint32_t atom_get_src_int(atom_exec_context 
> *ctx, uint8_t attr,
>        case ATOM_ARG_FB:
>                idx = U8(*ptr);
>                (*ptr)++;
> +               val = gctx->scratch[((gctx->fb_base + idx) / 4)];
>                if (print)
>                        DEBUG("FB[0x%02X]", idx);
> -               printk(KERN_INFO "FB access is not implemented.\n");
> -               return 0;
> +               break;
>        case ATOM_ARG_IMM:
>                switch (align) {
>                case ATOM_SRC_DWORD:
> @@ -488,9 +488,9 @@ static void atom_put_dst(atom_exec_context *ctx, int arg, 
> uint8_t attr,
>        case ATOM_ARG_FB:
>                idx = U8(*ptr);
>                (*ptr)++;
> +               gctx->scratch[((gctx->fb_base + idx) / 4)] = val;
>                DEBUG("FB[0x%02X]", idx);
> -               printk(KERN_INFO "FB access is not implemented.\n");
> -               return;
> +               break;
>        case ATOM_ARG_PLL:
>                idx = U8(*ptr);
>                (*ptr)++;
> @@ -1214,3 +1214,27 @@ void atom_parse_cmd_header(struct atom_context *ctx, 
> int index, uint8_t * frev,
>                *crev = CU8(idx + 3);
>        return;
>  }
> +
> +int atom_allocate_fb_scratch(struct atom_context *ctx)
> +{
> +       int index = GetIndexIntoMasterTable(DATA, VRAM_UsageByFirmware);
> +       uint16_t data_offset;
> +       int usage_bytes;
> +       struct _ATOM_VRAM_USAGE_BY_FIRMWARE *firmware_usage;
> +
> +       atom_parse_data_header(ctx, index, NULL, NULL, NULL, &data_offset);
> +
> +       firmware_usage = (struct _ATOM_VRAM_USAGE_BY_FIRMWARE *)(ctx->bios + 
> data_offset);
> +
> +       DRM_DEBUG("atom firmware requested %08x %dkb\n",
> +                 
> firmware_usage->asFirmwareVramReserveInfo[0].ulStartAddrUsedByFirmware,
> +                 
> firmware_usage->asFirmwareVramReserveInfo[0].usFirmwareUseInKb);
> +
> +       usage_bytes = 
> firmware_usage->asFirmwareVramReserveInfo[0].usFirmwareUseInKb * 1024;
> +       /* allocate some scratch memory */
> +
> +       ctx->scratch = kzalloc(usage_bytes, GFP_KERNEL);

At some point we may want to map the fb and copy the current scratch
info to the driver scratch area.  That would give us access to the
edids and such from the bios.

Alex

> +       if (!ctx->scratch)
> +               return -ENOMEM;
> +       return 0;
> +}
> diff --git a/drivers/gpu/drm/radeon/atom.h b/drivers/gpu/drm/radeon/atom.h
> index e6eb38f..6671848 100644
> --- a/drivers/gpu/drm/radeon/atom.h
> +++ b/drivers/gpu/drm/radeon/atom.h
> @@ -132,6 +132,7 @@ struct atom_context {
>        uint8_t shift;
>        int cs_equal, cs_above;
>        int io_mode;
> +       uint32_t *scratch;
>  };
>
>  extern int atom_debug;
> @@ -142,6 +143,7 @@ int atom_asic_init(struct atom_context *);
>  void atom_destroy(struct atom_context *);
>  void atom_parse_data_header(struct atom_context *ctx, int index, uint16_t 
> *size, uint8_t *frev, uint8_t *crev, uint16_t *data_start);
>  void atom_parse_cmd_header(struct atom_context *ctx, int index, uint8_t 
> *frev, uint8_t *crev);
> +int atom_allocate_fb_scratch(struct atom_context *ctx);
>  #include "atom-types.h"
>  #include "atombios.h"
>  #include "ObjectID.h"
> diff --git a/drivers/gpu/drm/radeon/radeon_device.c 
> b/drivers/gpu/drm/radeon/radeon_device.c
> index 0674d22..e4b3c77 100644
> --- a/drivers/gpu/drm/radeon/radeon_device.c
> +++ b/drivers/gpu/drm/radeon/radeon_device.c
> @@ -462,11 +462,13 @@ int radeon_atombios_init(struct radeon_device *rdev)
>
>        rdev->mode_info.atom_context = atom_parse(atom_card_info, rdev->bios);
>        radeon_atom_initialize_bios_scratch_regs(rdev->ddev);
> +       atom_allocate_fb_scratch(rdev->mode_info.atom_context);
>        return 0;
>  }
>
>  void radeon_atombios_fini(struct radeon_device *rdev)
>  {
> +       kfree(rdev->mode_info.atom_context->scratch);
>        kfree(rdev->mode_info.atom_context);
>        kfree(rdev->mode_info.atom_card_info);
>  }
> --
> 1.6.5.2
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> --
> _______________________________________________
> Dri-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/dri-devel
>

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to