diff options
Diffstat (limited to 'drivers/gpu/drm/emgd/emgd/video/topaz/topaz.c')
-rw-r--r-- | drivers/gpu/drm/emgd/emgd/video/topaz/topaz.c | 314 |
1 files changed, 0 insertions, 314 deletions
diff --git a/drivers/gpu/drm/emgd/emgd/video/topaz/topaz.c b/drivers/gpu/drm/emgd/emgd/video/topaz/topaz.c deleted file mode 100644 index 4186a955e1d7..000000000000 --- a/drivers/gpu/drm/emgd/emgd/video/topaz/topaz.c +++ /dev/null @@ -1,314 +0,0 @@ -/* -*- pse-c -*- - *----------------------------------------------------------------------------- - * Filename: topaz.c - * $Revision: 1.9 $ - *----------------------------------------------------------------------------- - * Copyright © 2002-2010, Intel Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * - *----------------------------------------------------------------------------- - * Description: - * - *----------------------------------------------------------------------------- - */ - -#include <io.h> -#include <pci.h> -#include <memmap.h> -#include <sched.h> - -#include <igd.h> -#include <igd_errno.h> -#include <igd_init.h> - -#include <context.h> -#include <intelpci.h> -#include <general.h> -#include <utils.h> -#include <topaz.h> -#include "topaz_hdr.h" - -#include <plb/regs.h> -#include <plb/context.h> - -void write_mtx_mem_multiple_setup(igd_context_t *context, - unsigned long addr) -{ - unsigned char *mmio = context->device_context.virt_mmadr; - unsigned long bank_size; - unsigned long ram_size; - unsigned long ram_id; - unsigned long reg; - unsigned long ctrl = 0; - - reg = EMGD_READ32(mmio + TNC_TOPAZ_MTX_DEBUG); - - reg = 0x0a0a0606; - bank_size = (reg & 0xf0000) >> 16; - - ram_size = (unsigned long) (1 << (bank_size + 2)); - ram_id = (addr - MTX_DATA_BASE) / ram_size; - - /* cmd id */ - ctrl = ((0x18 + ram_id) << 20) & 0x0ff00000; - /* Address to read */ - ctrl |= ((addr >> 2) << 2) & 0x000ffffc; - ctrl |= 0x02; - /*printk(KERN_INFO "write_mtx_multiple_setup: ctrl=0x%08x, addr=0x%08x", ctrl, addr);*/ - EMGD_WRITE32(ctrl, mmio + TNC_TOPAZ_MTX_RAM_ACCESS_CONTROL); - - return; -} - -void write_mtx_mem_multiple(igd_context_t *context, - unsigned long cmd) -{ - unsigned char *mmio = context->device_context.virt_mmadr; - - EMGD_WRITE32(cmd, mmio + TNC_TOPAZ_MTX_RAM_ACCESS_DATA_TRANSFER); -} - -/* - * This is the function that actually passes the message to the MTX - * firmware. The contents of the message are opaque to this function. - * - * Currently, the only supported message type is RENDER. - */ -int mtx_send_tnc(igd_context_t *context, unsigned long *msg) -{ - struct topaz_cmd_header *cur_cmd_header = - (struct topaz_cmd_header *) msg; - unsigned long cmd_size = cur_cmd_header->size; - unsigned long read_index, write_index; - const unsigned long *cmd_pointer = (unsigned long *)msg; - tnc_topaz_priv_t *topaz_priv; - platform_context_tnc_t *platform; - int ret = 0; - - platform = (platform_context_tnc_t *)context->platform_context; - topaz_priv = &platform->tpz_private_data; - - write_index = topaz_priv->topaz_cmd_windex; - if (write_index + cmd_size + 1 > topaz_priv->topaz_ccb_size) - { - int free_space = topaz_priv->topaz_ccb_size - write_index; - - EMGD_DEBUG("TOPAZ: wrap CCB write point"); - if (free_space > 0) - { - struct topaz_cmd_header pad_cmd; - - pad_cmd.id = MTX_CMDID_NULL; - pad_cmd.size = free_space; - pad_cmd.seq = 0x7fff & topaz_priv->topaz_cmd_seq++; - - EMGD_DEBUG("TOPAZ: MTX_CMDID_NULL:" - " size(%d),seq (0x%04x)\n", - pad_cmd.size, pad_cmd.seq); - - TOPAZ_BEGIN_CCB(context); - TOPAZ_OUT_CCB(context, pad_cmd.val); - TOPAZ_END_CCB(context, 1); - } - POLL_WB_RINDEX(context, 0); - if (ret == 0) { - topaz_priv->topaz_cmd_windex = 0; - } else { - EMGD_ERROR("TOPAZ: poll rindex timeout\n"); - return ret; /* HW may hang, need reset */ - } - EMGD_DEBUG("TOPAZ: -------wrap CCB was done.\n"); - } - - read_index = CCB_CTRL_RINDEX(context);/* temperily use CCB CTRL */ - write_index = topaz_priv->topaz_cmd_windex; - - /*printk(KERN_INFO "TOPAZ: write index(%ld), read index(%ld,WB=%ld)\n", - write_index, read_index, WB_CCB_CTRL_RINDEX(context)); - printk(KERN_INFO "cmd size to kick %d",cmd_size); - for(count=0;count<cmd_size;count++){ - printk(KERN_INFO "value to kick 0x%08x", *(cmd_pointer+count)); - }*/ - - TOPAZ_BEGIN_CCB(context); - while (cmd_size > 0) { - TOPAZ_OUT_CCB(context, *cmd_pointer++); - --cmd_size; - } - TOPAZ_END_CCB(context, 1); - - /*POLL_WB_RINDEX(context, topaz_priv->topaz_cmd_windex); - printk(KERN_INFO "RI after kick =%ld", CCB_CTRL_RINDEX(context));*/ - - -#if 0 /* kept for memory callback test */ - for (i = 0; i < 100; i++) { - if (WB_CCB_CTRL_RINDEX(context) == topaz_priv->topaz_cmd_windex) - break; - else - OS_SLEEP(100); - } - if (WB_CCB_CTRL_RINDEX(context) != topaz_priv->topaz_cmd_windex) { - EMGD_ERROR("TOPAZ: poll rindex timeout\n"); - ret = -IGD_ERROR_HWERROR; - } -#endif - - return ret; -} - -void topaz_sync_tnc(igd_context_t *context) -{ - tnc_topaz_priv_t *topaz_priv; - platform_context_tnc_t *platform; - unsigned long sync_cmd[3]; - unsigned long *sync_p, temp_ret; - - platform = (platform_context_tnc_t *)context->platform_context; - topaz_priv = &platform->tpz_private_data; - sync_p = (unsigned long *)topaz_priv->topaz_sync_addr; - - /* insert a SYNC command here */ - topaz_priv->topaz_sync_cmd_seq = (1 << 15) | - topaz_priv->topaz_cmd_seq++; - sync_cmd[0] = (MTX_CMDID_SYNC << 1) | (3 << 8) | - (topaz_priv->topaz_sync_cmd_seq << 16); - sync_cmd[1] = topaz_priv->topaz_sync_offset; - sync_cmd[2] = topaz_priv->topaz_sync_cmd_seq; - temp_ret = mtx_send_tnc(context, sync_cmd); - if (0 != temp_ret){ - EMGD_DEBUG("TOPAZ: sync error: %ld\n", temp_ret); - } - - topaz_priv->topaz_frame_skip = CCB_CTRL_FRAMESKIP(context); - -#if 0 - /* debug code to make sure SYNC can be done */ - { - int count = 1000; - while (count && *sync_p != topaz_priv->topaz_sync_cmd_seq) { - OS_SLEEP(1000); - --count; - } - if ((count == 0) && (*sync_p != 0x45)) { - EMGD_ERROR("TOPAZ: wait sync timeout (0x%08x)," - "actual 0x%08x\n", - topaz_priv->topaz_sync_cmd_seq, *sync_p); - } - } -#endif - -} - - -/* - * To process this buffer, find the MTX firmware messages and send each - * one to the MTX firmware. - */ - -int process_encode_mtx_messages(igd_context_t *context, - unsigned long *mtx_buf, - unsigned long size) -{ - unsigned long *command = (unsigned long *) mtx_buf; - unsigned long cmd_size = size; - int ret = 0; - struct topaz_cmd_header *cur_cmd_header; - unsigned long cur_cmd_size, cur_cmd_id; - unsigned long codec; - tnc_topaz_priv_t *topaz_priv; - platform_context_tnc_t *platform; - int first_frame = 0; - - platform = (platform_context_tnc_t *)context->platform_context; - topaz_priv = &platform->tpz_private_data; - - cur_cmd_header = (struct topaz_cmd_header *) command; - cur_cmd_size = cur_cmd_header->size; - cur_cmd_id = cur_cmd_header->id; - - if(cur_cmd_id != MTX_CMDID_SW_NEW_CODEC){ - if( (topaz_priv->topaz_cur_codec == FW_H264_NO_RC) || - (topaz_priv->topaz_cur_codec == FW_MPEG4_NO_RC) || - (topaz_priv->topaz_cur_codec == FW_H263_NO_RC) ){ - topaz_priv->topaz_sync_val = topaz_priv->topaz_sync_cmd_seq; - } - }else{ - first_frame=1; - } - - while (cur_cmd_id != MTX_CMDID_NULL) { - - switch (cur_cmd_id) { - case MTX_CMDID_SW_NEW_CODEC: - codec = *((unsigned long *) mtx_buf + 1); - EMGD_DEBUG("TOPAZ: setup new codec %ld\n", codec); - if (topaz_setup_fw(context, codec)) { - EMGD_ERROR("TOPAZ: upload FW to HW failed\n"); - return -IGD_ERROR_INVAL; - } - topaz_priv->topaz_cur_codec = codec; - break; - case MTX_CMDID_SW_ENTER_LOWPOWER: - EMGD_DEBUG("TOPAZ: enter lowpower.... \n"); - EMGD_DEBUG("XXX: implement it\n"); - break; - case MTX_CMDID_SW_LEAVE_LOWPOWER: - EMGD_DEBUG("TOPAZ: leave lowpower... \n"); - EMGD_DEBUG("XXX: implement it\n"); - break; - /* ordinary commmand */ - case MTX_CMDID_START_PIC: - /* XXX: specially handle START_PIC hw command */ - CCB_CTRL_SET_QP(context, - *(command + cur_cmd_size - 1)); - /* strip the QP parameter (it's software arg) */ - cur_cmd_header->size--; - default: - cur_cmd_header->seq = 0x7fff & - topaz_priv->topaz_cmd_seq++; - EMGD_DEBUG("TOPAZ: %ld: size(%ld), seq (0x%04x)\n", - cur_cmd_id, cur_cmd_size, cur_cmd_header->seq); - ret = mtx_send_tnc(context, command); - if (ret) { - EMGD_ERROR("TOPAZ: error -- ret(%d)\n", ret); - return -IGD_ERROR_INVAL; - } - break; - } - /* save frame skip flag for query */ - /*topaz_priv->topaz_frame_skip = 0; CCB_CTRL_FRAMESKIP(context);*/ - /* current command done */ - command += cur_cmd_size; - cmd_size -= cur_cmd_size; - - /* Get next command */ - cur_cmd_header = (struct topaz_cmd_header *) command; - cur_cmd_size = cur_cmd_header->size; - cur_cmd_id = cur_cmd_header->id; - } - topaz_sync_tnc(context); - - if(first_frame){ - /* For no rate-control, POLL special for first frame */ - if( (topaz_priv->topaz_cur_codec == FW_H264_NO_RC) || - (topaz_priv->topaz_cur_codec == FW_MPEG4_NO_RC) || - (topaz_priv->topaz_cur_codec == FW_H263_NO_RC) ){ - topaz_priv->topaz_sync_val = topaz_priv->topaz_sync_cmd_seq; - } - } - - return 0; -} |