示例#1
0
/*
 * Initializes the memory pool used to allocate card memory.
 *
 * Returns nonzero if there was a failure.
 */
int tl880_init_memory(struct tl880_dev *tl880dev) /* {{{ */
{
	int result;

	if(CHECK_NULL(tl880dev) || TL_ASSERT(tl880dev->pool == NULL)) {
		return -EINVAL;
	}

	tl880dev->pool = gen_pool_create(6, -1);
	if(TL_ASSERT(tl880dev->pool != NULL)) {
		return -ENOMEM;
	}

	/* Should I specify a specific NUMA node here ever? */
	/* The pool starts at 0x11000 because earlier points in RAM are used for something already */
	/* XXX:TODO: Changed to 0x100000 temporarily to allow the ALSA driver to use the memory without allocating it */
	if(TL_ASSERT((result = gen_pool_add(tl880dev->pool, 0x100000, tl880dev->memlen - 0x11000, -1)) == 0)) {
		printk(KERN_ERR "tl880: Failed to add card %d's memory to its memory pool\n", tl880dev->id);
		gen_pool_destroy(tl880dev->pool);
		tl880dev->pool = NULL;
		return result;
	}

	return 0;
} /* }}} */
示例#2
0
	void Rectangle::GetRotatedPosArray(Vector2* pArray) const
	{
		TL_ASSERT(pArray != NULL);

		Matrix mat = Matrix::CreateRotationZ(mthToRadians(rotation));

		Vector2 &topLeft = pArray[0];
		Vector2 &topRight = pArray[1];
		Vector2 &botRight = pArray[2];
		Vector2 &botLeft = pArray[3];

		Vector2 pos = GetPos();

		if(anchorInCenter) {
			topLeft = pos + mat.Translate(Vector2(-w/2.0f, -h/2.0f));
			topRight = pos + mat.Translate(Vector2(w/2.0f, -h/2.0f));
			botRight = pos + mat.Translate(Vector2(w/2.0f, h/2.0f));
			botLeft = pos + mat.Translate(Vector2(-w/2.0f, h/2.0f));
		} else {
			topLeft = pos;
			topRight = pos + mat.Translate(Vector2(w, 0.0f));
			botRight = pos + mat.Translate(Vector2(w, h));
			botLeft = pos + mat.Translate(Vector2(0.0f, h));
		}
	}
示例#3
0
	Vector2 Render::GetTextSize(const Font& font, const std::string& text) {
		float totalW = 0;
		float totalH = 0;

		float cx = 0;
		float cy = 0;
		unsigned long len = text.size();

		for (unsigned long i = 0; i < len; i++) {
			char l = text[i];

			texture_glyph_t* glyph = texture_font_get_glyph(font.FontHandle, (wchar_t)text[i]);
			if (glyph == null) {
				TL_ASSERT(false);
				return Vector2::Zero;
			}

			if (i > 0) {
				cx += texture_glyph_get_kerning(glyph, text[i - 1]);
			}

			if (l == '\n') {
				cy += font.FontHandle->height;
				cx = 0;
				continue;
			}

			cx += glyph->advance_x;
			if (cx > totalW) totalW = cx;
			if (cy + font.FontHandle->height > totalH) totalH = cy + font.FontHandle->height;
		}

		return Vector2(totalW, totalH);
	}
	// Removes a font from the engine
	void CTLXEngineMod::RemoveFont
		(
			const	IFont* pFont
			)
	{
		TL_FN("RemoveFont");

		TL_ASSERT(pFont, "Attempt to remove null font");

		TFontListIter itFont = find(m_Fonts.begin(), m_Fonts.end(), pFont);
		TL_ASSERT(itFont != m_Fonts.end(), "Font not found")

			m_Fonts.erase(itFont);
		delete pFont;

		TL_ENDFN;
	}
	// Removes a sprite from the scene
	void CTLXEngineMod::RemoveSprite
		(
			const	ISprite* pSprite
			)
	{
		TL_FN("RemoveSprite");

		TL_ASSERT(pSprite, "Attempt to remove null sprite");

		TSpriteListIter itSprite = find(m_Sprites.begin(), m_Sprites.end(), pSprite);
		TL_ASSERT(itSprite != m_Sprites.end(), "Font not found")

			m_Sprites.erase(itSprite);
		delete pSprite;

		TL_ENDFN;
	}
	// Removes a mesh from the system, also removes any models in the
	// scene that use the mesh.
	void CTLXEngineMod::RemoveMesh
		(
			const	IMesh*	pMesh
			)
	{
		TL_FN("RemoveMesh");

		TL_ASSERT(pMesh, "Attempt to remove null mesh");

		TMeshListIter itMesh = find(m_Meshes.begin(), m_Meshes.end(), pMesh);
		TL_ASSERT(itMesh != m_Meshes.end(), "Mesh not found")
			m_Meshes.erase(itMesh);

		delete pMesh;

		TL_ENDFN;
	}
示例#7
0
	Vector2 Render::GetTextSize(char letter) {
		texture_glyph_t* glyph = texture_font_get_glyph(this->DefaultFont->FontHandle, (wchar_t)letter);
		if (glyph == null) {
			TL_ASSERT(false);
			return Vector2::Zero;
		}

		return Vector2((float)glyph->width, (float)glyph->height);
	}
	// Removes a light from the scene.
	void CTLXEngineMod::RemoveLight
		(
			const ILight* pLight
			)
	{
		TL_FN("RemoveLight");

		TL_ASSERT(pLight, "Attempt to remove null light");

		TLightListIter itLight =
			find(m_Lights.begin(), m_Lights.end(), pLight);
		TL_ASSERT(itLight != m_Lights.end(), "Camera not found")
			m_Lights.erase(itLight);

		delete pLight;

		TL_ENDFN;
	}
	// Removes a camera from the scene.
	void CTLXEngineMod::RemoveCamera
		(
			const	ICamera* pCamera
			)
	{
		TL_FN("RemoveCamera");

		TL_ASSERT(pCamera, "Attempt to remove null camera");

		TCameraListIter itCamera =
			find(m_Cameras.begin(), m_Cameras.end(), pCamera);
		TL_ASSERT(itCamera != m_Cameras.end(), "Camera not found")
			m_Cameras.erase(itCamera);

		delete pCamera;

		TL_ENDFN;
	}
示例#10
0
// Modified from drivers/media/video/msp3400-driver.c
int tl880_msp_write(struct tl880_dev *tl880dev, int dev, int addr, int val)
{
    int err;
    u8 buffer[5];
    struct i2c_client *client;

    if(CHECK_NULL(tl880dev) || CHECK_NULL(tl880dev->i2cbuses)) {
        return -1;
    }

    if(TL_ASSERT(tl880dev->msp_i2cclient >= 0)) {
        return -1;
    }

    client = tl880dev->i2cbuses[tl880dev->msp_i2cbus].i2c_clients[tl880dev->msp_i2cclient];

    if(CHECK_NULL(client)) {
        return -1;
    }

    buffer[0] = dev;
    buffer[1] = addr >> 8;
    buffer[2] = addr &  0xff;
    buffer[3] = val  >> 8;
    buffer[4] = val  &  0xff;

    printk(KERN_DEBUG "tl880: msp: write\n");
    for (err = 0; err < 3; err++) {
        if (i2c_master_send(client, buffer, 5) == 5)
            break;
        printk(KERN_WARNING "tl880: msp: I/O error #%d (write 0x%02x/0x%02x)\n", err,
               dev, addr);
        current->state = TASK_INTERRUPTIBLE;
        schedule_timeout(msecs_to_jiffies(10));
    }
    if (err == 3) {
        return -1;
    }
    printk(KERN_DEBUG "tl880: msp: finished write\n");
    return 0;
}
示例#11
0
void tl880_init_hardware_audio(struct tl880_dev *tl880dev, enum audio_mode_e audio_mode)
{
	if(CHECK_NULL(tl880dev)) {
		return;
	}

	tl880dev->audio_mode = audio_mode;

	if(tl880dev->iau_base == 0) {
		/*
		 * This used to be yGetTL850Memory(0x7800, 0) -- The second parameter seems to control
		 * where the memory comes from (top or bottom of pool).
		 */
		if(TL_ASSERT((tl880dev->iau_base = tl880_alloc_memory(tl880dev, 0x7800)) != 0)) {
			return;
		}
		/* tl880dev->iau_base = 0x196000; */
	}

	if(tl880dev->iec_buf == NULL) {
		/* g_IECbuf = ExAllocatePoolWithTag(NonPagedPool, 0x1800, 'W''d''m'' '); */
		/* Linux kernel memory is always non-paged */
		tl880dev->iec_buf = kmalloc(0x1800, GFP_KERNEL); // 0x1800 = 6144 - the size of an AC3-in-PCM frame
	}

	tl880_apu_init_ioc(tl880dev);
	tl880_apu_init_iau_reg(tl880dev);

	/*
	long iauP = 0;
	u32 iauCnt = 0;
	//SetSamplingClock(1);
	*/

	tl880_set_sampling_clock(tl880dev, 1);

	/*
	unsigned char startAC3 = 0;
	*/
}
示例#12
0
	void Texture::Use() {
		TL_ASSERT(this->RegisteredInGL);
		glBindTexture(GL_TEXTURE_2D, this->GLHandle);
	}
示例#13
0
	void Texture::Upload() {
		TL_ASSERT(this->RegisteredInGL);
		glBindTexture(GL_TEXTURE_2D, this->GLHandle);
		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, this->Width, this->Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, &this->PixelData[0]);
	}
示例#14
0
	void Render::Text(Font* font, const std::string& text, float x, float y, const Color& color) {
		if (color.A == 0) return;
		this->SetTexture(font->Atlas->id);
		this->SetShader(this->DefaultShaderText.ProgramHandle);

		x += this->_DrawOffset.X;
		y += this->_DrawOffset.Y;

		y -= font->FontHandle->height / 4;

		float cx = x;
		float cy = y;
		int len = (int)text.size();

		this->CheckSpace(len * 4, len * 6); // per square, 4 vertices and 6 indices

		float currentMaxLineHeight = 0;
		for (int i = 0; i < len; i++) {
			char l = text[i];

			texture_glyph_t* glyph = texture_font_get_glyph(font->FontHandle, (wchar_t)text[i]);
			if (glyph == null) {
				TL_ASSERT(false);
				return;
			}

			if (i > 0) {
				cx += texture_glyph_get_kerning(glyph, text[i - 1]);
			}

			if (l == '\n') {
				cy += font->FontHandle->height;
				cx = x;
				continue;
			}

			float w = (float)glyph->width;
			float h = (float)font->FontHandle->height;

			_vertexData a, b, c, d;

			float lw = cx + glyph->offset_x;
			float lh = cy + h - glyph->offset_y;

			float x1 = glyph->s0;
			float x2 = glyph->s1;
			float y1 = glyph->t0;
			float y2 = glyph->t1;

			float pixelWidth = 1.0f / this->DefaultFont->Atlas->width;
			float pixelHeight = 1.0f / this->DefaultFont->Atlas->height;

			a.Location.X = lw;
			a.Location.Y = lh;

			b.Location.X = lw + w;
			b.Location.Y = lh;

			c.Location.X = lw;
			c.Location.Y = lh + glyph->height;

			d.Location.X = lw + w;
			d.Location.Y = lh + glyph->height;

			a.TextureLocation.X = x1;
			a.TextureLocation.Y = y1;

			b.TextureLocation.X = x2;
			b.TextureLocation.Y = y1;

			c.TextureLocation.X = x1;
			c.TextureLocation.Y = y2;

			d.TextureLocation.X = x2;
			d.TextureLocation.Y = y2;


			if (this->ClippingEnabled) {
				if (lw < this->_ClippingPos.X) {
					// if the sign is fully outside of the clipping, then just skip it.
					if (lw + w < this->_ClippingPos.X) {
						cx += glyph->advance_x;
						continue;
					} else {
						// calculate the new screen and texture location
						float offset = this->_ClippingPos.X - lw;

						a.Location.X += offset;
						c.Location.X += offset;

						a.TextureLocation.X += offset * pixelWidth;
						c.TextureLocation.X += offset * pixelWidth;
					}
				}

				if (lw + w > this->_ClippingPos.X + this->_ClippingSize.X) {
					if (cx > this->_ClippingPos.X + this->_ClippingSize.X) {
						cx += glyph->advance_x;
						continue;
					} else {
						float offset = lw + w - this->_ClippingPos.X - this->_ClippingSize.X;

						b.Location.X -= offset;
						d.Location.X -= offset;

						b.TextureLocation.X -= offset * pixelWidth;
						d.TextureLocation.X -= offset * pixelWidth;
					}
				}

				if (a.Location.Y < this->_ClippingPos.Y) {
					if (d.Location.Y < this->_ClippingPos.Y) {
						cx += glyph->advance_x;
						continue;
					} else {
						float offset = this->_ClippingPos.Y - a.Location.Y;

						a.Location.Y += offset;
						b.Location.Y += offset;

						a.TextureLocation.Y += offset * pixelHeight;
						b.TextureLocation.Y += offset * pixelHeight;
					}
				}

				if (d.Location.Y > this->_ClippingPos.Y + this->_ClippingSize.Y) {
					if (b.Location.Y > this->_ClippingPos.Y + this->_ClippingSize.Y) {
						cx += glyph->advance_x;
						continue;
					} else {
						float offset = d.Location.Y - this->_ClippingPos.Y - this->_ClippingSize.Y;

						c.Location.Y -= offset;
						d.Location.Y -= offset;

						c.TextureLocation.Y -= offset * pixelHeight;
						d.TextureLocation.Y -= offset * pixelHeight;
					}
				}
			}

			a.Color = color;
			b.Color = color;
			c.Color = color;
			d.Color = color;

			unsigned int curVertices = this->VerticeDataCount;

			VERTICE_PUSH(a);
			VERTICE_PUSH(b);
			VERTICE_PUSH(c);
			VERTICE_PUSH(d);

			INDICE_PUSH(curVertices + 0);
			INDICE_PUSH(curVertices + 1);
			INDICE_PUSH(curVertices + 2);

			INDICE_PUSH(curVertices + 1);
			INDICE_PUSH(curVertices + 3);
			INDICE_PUSH(curVertices + 2);

			cx += glyph->advance_x;
		}
	}