Exemplo n.º 1
0
int wlan_tx(txfifo_t *tx_fifo, msg_q_t *msg_q, int cnt)
{
	int tx_cnt, i, ret;
	tx_msg_t *msg;
	tx_cnt = 0;
	for (i = 0; i < cnt; i++) {
		msg = msg_get(msg_q);
		if (NULL == msg) {
			break;
		}
		ret = tx_fifo_in(tx_fifo, msg);
		if (TX_FIFO_FULL == ret) {
			ret = TX_FIFO_FULL;
			break;
		}
		trans_up();
		if (HOST_SC2331_CMD == msg->hdr.type) {
			if ((msg->slice[0].len > 0)
			    && (NULL != msg->slice[0].data))
				kfree(msg->slice[0].data);
		} else if (HOST_SC2331_PKT == msg->hdr.type) {
			if ((NULL != msg->p))
				dev_kfree_skb((struct sk_buff *)(msg->p));
		} else {
		}

		memset((unsigned char *)msg, 0, sizeof(tx_msg_t));
		msg_free(msg_q, msg);
		tx_cnt++;
	}
	return tx_cnt ? tx_cnt : ret;
}
Exemplo n.º 2
0
void wlan_rx_chn_isr(int chn)
{
	static unsigned int cnt = 1;
	printkp("[irq][%d]\n", cnt);
	cnt++;
	trans_up();
}
Exemplo n.º 3
0
void wakeup_timer_func(unsigned long data)
{
	if ((g_wlan.wlan_trans.sem.count <= 0) && (0 == g_wlan.hw.can_sleep)) {
		printkd("timer[3]\n");
		g_wlan.hw.can_sleep = 1;
		trans_up();
		return;
	}
	printkd("timer[2]\n");
	mod_timer(&(g_wlan.hw.wakeup_timer),
		  jiffies + msecs_to_jiffies(g_wlan.hw.wakeup_time));
}
Exemplo n.º 4
0
void Engine::init_scene() {
    Node* scene = nodes["scene"] = new Node(NULL);

    // shaders //

    // "simple_shader"
    shaders["simple_shader"] = make_shader("shaders/p_v.glsl",
                                           "shaders/unicolor_f.glsl");

    // "light1"
    {
        Shader* shader = shaders["light1"] =
                make_shader("shaders/pn_v.glsl", "shaders/light1_f.glsl");

        // TODO put uniforms in "material"-class or something?
        set_uniform(shader, "mycolor", glm::vec4(1.f));
        set_uniform(shader, "ambient_intensity", glm::vec4(.1f,.1f,.1f,1.f));
        set_uniform(shader, "diffuse_color", glm::vec4(.5f,.5f,.5f,1.f));
        set_uniform(shader, "specular_color", glm::vec4(1.f,1.f,1.f,1.f));

        set_uniform(shader, "atten_k", .04f);
        set_uniform(shader, "gauss_k", .1f);
    }

    // objects //

    // grid
    {
        Shader* shader = shaders["simple_shader"];

        Node* node = nodes["grid"] = new Node(scene);

        int no = 5;
        glm::vec3 scale = glm::vec3(20.f);
        VAO* vao = create_grid(no, scale);

        std::vector<Uniform*> material;

        glm::vec4 white = glm::vec4(1.f);
        StoredUniform<glm::vec4>* mycolor =
                new StoredUniform<glm::vec4>(shader, "mycolor", white);
        material.push_back(mycolor);

        renderables.push_back(
                    new BasicRenderObject(shader, node, vao, material));

        // mem
        vaos.push_back(vao);
        uniforms.push_back(mycolor);
    }

    // redcube
    {
        Shader* shader = shaders["light1"];

        Node* node = nodes["redcube"] = new Node(scene);
        node->position = glm::vec3(.5f,.5f,-1.7f);

        glm::vec3 scale = glm::vec3(.05f);
        VAO* vao = create_cube_with_normals(scale);

        std::vector<Uniform*> material;

        glm::vec4 red = glm::vec4(1.f,0.f,.5f,1.f);
        StoredUniform<glm::vec4>* mycolor =
                new StoredUniform<glm::vec4>(shader, "mycolor", red);
        material.push_back(mycolor);

        renderables.push_back(
                new LitRenderObject(shader, node, vao, material));


        // physics
        btCollisionShape* cube_shape = new btBoxShape(from_vec3(scale/2.f));

        float mass = 0.f;
        redcube_rb = create_rigid_body(mass, node, cube_shape);
        physics->add_rigid_body(redcube_rb);


        // mem
        vaos.push_back(vao);
        uniforms.push_back(mycolor);
        collision_shapes.push_back(cube_shape);
    }

    make_litcube("cyancube",
                 glm::vec4(0.f, 1.f, 1.f, 1.f),
                 glm::vec3(0.05f));
    nodes["cyancube"]->orientation =
            glm::angleAxis(glm::radians(45.f),
                           glm::normalize(glm::vec3(-1.f, 1.f, 1.f)));

    make_litcube("yellowcube",
                 glm::vec4(1.f, 1.f, 0.f, 1.f),
                 glm::vec3(0.05f));
    nodes["yellowcube"]->orientation = nodes["cyancube"]->orientation;

    make_litcube("bluecube",
                 glm::vec4(0.f, 0.f, 1.f, 1.f),
                 glm::vec3(1.f),
                 30.f,
                 glm::vec3(0.f, 1.5f, -5.f));

    // lightcube
    {
        Shader* shader = shaders["simple_shader"];

        Node* node = nodes["lightcube"] = new Node(scene);
        node->position = glm::vec3(0.f, 1.f, 0.f);

        glm::vec3 scale = glm::vec3(.3f,.3f,.3f);
        VAO* vao = create_cube(scale);

        std::vector<Uniform*> material;

        glm::vec4 white = glm::vec4(1.f,1.f,1.f,1.f);
        StoredUniform<glm::vec4>* mycolor =
                new StoredUniform<glm::vec4>(shader, "mycolor", white);
        material.push_back(mycolor);

        renderables.push_back(
                new BasicRenderObject(shader, node, vao, material));

        // sync point light with position
        PointLight light0(node, glm::vec4(.7f,.7f,.7f,1.f));
        set_uniform(shaders["light1"], "light.position",
                    glm::vec3(light0.get_position()));
        set_uniform(shaders["light1"], "light.intensity",
                    light0.get_intensity());

        // mem
        vaos.push_back(vao);
        uniforms.push_back(mycolor);
    }

    // plane
    {
        Shader* shader = shaders["light1"];

        Node* node = nodes["plane"] = new Node(scene);
        node->position = glm::vec3(0.f, -.5f, 0.f);

        glm::vec3 scale = glm::vec3(20.f, 1.f, 20.f);
        VAO* vao = create_cube_with_normals(scale);

        std::vector<Uniform*> material;

        glm::vec4 goldish = glm::vec4(1.f,1.f,0.f,1.f);
        StoredUniform<glm::vec4>* mycolor =
                new StoredUniform<glm::vec4>(shader, "mycolor", goldish);
        material.push_back(mycolor);

        renderables.push_back(
                new LitRenderObject(shader, node, vao, material));

        // physics
        btCollisionShape* shape = new btBoxShape(from_vec3(scale/2.f));

        float mass = 0.f;
        btRigidBody* rigid_body = create_rigid_body(mass, node, shape);
        physics->add_rigid_body(rigid_body);

        // mem
        uniforms.push_back(mycolor);
        vaos.push_back(vao);
        collision_shapes.push_back(shape);
    }

    // bound
    {
        Shader* shader = shaders["light1"];

        Node* node = nodes["bound"] = new Node(scene);

        glm::vec3 scale = glm::vec3(20.f);
        bool face_inward = true;
        VAO* vao = create_cube_with_normals(scale, face_inward);

        std::vector<Uniform*> material;

        glm::vec4 greenblueish = glm::vec4(0.f,1.f,1.f,1.f);
        StoredUniform<glm::vec4>* mycolor =
            new StoredUniform<glm::vec4>(shader, "mycolor", greenblueish);
        material.push_back(mycolor);

        renderables.push_back(
                new LitRenderObject(shader, node, vao, material));

        // mem
        vaos.push_back(vao);
        uniforms.push_back(mycolor);
    }

    // roboarm
    {
        nodes["roboarm0"] = new Node(scene);
        nodes["roboarm1"] = new Node(scene);
        nodes["roboarm2"] = new Node(scene);
        nodes["roboarm3"] = new Node(scene);

        glm::vec3 scale = glm::vec3(0.1f, 0.4f, 0.1f);

        nodes["roboarm0"]->position = glm::vec3(0.f, 1.f, -2.f);
        //nodes["roboarm0"]->orientation =
        //        glm::angleAxis(glm::radians(180.f), glm::vec3(1.f, 0.f, 0.f));

        nodes["roboarm1"]->position = nodes["roboarm0"]->position +
            nodes["roboarm0"]->orientation * glm::vec3(0.f, scale.y, 0.f);
        nodes["roboarm1"]->orientation = nodes["roboarm0"]->orientation;

        nodes["roboarm2"]->position = nodes["roboarm1"]->position +
            nodes["roboarm1"]->orientation * glm::vec3(0.f, scale.y, 0.f);
        nodes["roboarm2"]->orientation = nodes["roboarm1"]->orientation;

        nodes["roboarm3"]->position = nodes["roboarm2"]->position +
            nodes["roboarm2"]->orientation * glm::vec3(0.f, scale.y, 0.f);
        nodes["roboarm3"]->orientation = nodes["roboarm2"]->orientation;

        // render
        {
            Shader* shader = shaders["light1"];

            glm::vec4 black = glm::vec4(0.f,0.f,0.f,1.f);
            StoredUniform<glm::vec4>* mycolor =
                    new StoredUniform<glm::vec4>(shader, "mycolor", black);

            std::vector<Uniform*> material;
            material.push_back(mycolor);

            // TODO use rounder shapes...
            VAO* vao = create_cube_with_normals(scale);

            auto make_renderable =
                [&shader, &material, &vao] (Node* node) {
                    return new LitRenderObject(shader, node, vao, material);
                };

            renderables.insert(renderables.end(),
                {
                    make_renderable(nodes["roboarm0"]),
                    make_renderable(nodes["roboarm1"]),
                    make_renderable(nodes["roboarm2"]),
                    make_renderable(nodes["roboarm3"]),
                }
            );

            // mem
            uniforms.push_back(mycolor);
            vaos.push_back(vao);
        }

        btCollisionShape *shape = new btBoxShape(from_vec3(scale/2.f));
        float density = 1000.f,
              volume = scale.x * scale.y * scale.z,
              mass = density * volume;

        // mem
        collision_shapes.push_back(shape);


        btRigidBody *rb0 = create_rigid_body(0.f, nodes["roboarm0"], shape),
                    *rb1 = create_rigid_body(mass, nodes["roboarm1"], shape),
                    *rb2 = create_rigid_body(mass, nodes["roboarm2"], shape),
                    *rb3 = create_rigid_body(mass, nodes["roboarm3"], shape);

        rb1->setActivationState(DISABLE_DEACTIVATION);
        rb2->setActivationState(DISABLE_DEACTIVATION);
        rb3->setActivationState(DISABLE_DEACTIVATION);

        physics->add_rigid_body(rb0);
        physics->add_rigid_body(rb1);
        physics->add_rigid_body(rb2);
        physics->add_rigid_body(rb3);

        btMatrix3x3 rot;
        rot.setIdentity();

        btTransform trans_up(rot, btVector3(0.f, scale.y/2, 0.f)),
                    trans_down(rot, btVector3(0.f, -scale.y/2, 0.f));

        rc1 = new btHingeConstraint(*rb0, *rb1,
                                    trans_up, trans_down);

        rc2 = new btHingeConstraint(*rb1, *rb2,
                                    trans_up, trans_down);

        rc3 = new btHingeConstraint(*rb2, *rb3,
                                    trans_up, trans_down);

        float pi = glm::pi<float>();

        rc1->setLimit(-pi/2, pi/2);
        rc2->setLimit(-pi/2, pi/2);
        rc3->setLimit(-pi/2, pi/2);

        bool intercollision = false;
        physics->add_constraint(rc1, intercollision);
        physics->add_constraint(rc2, intercollision);
        physics->add_constraint(rc3, intercollision);

        roboarm0 = new KinematicChain(nullptr, rb0, nullptr);
        roboarm1 = new KinematicChain(roboarm0, rb1, rc1);
        roboarm2 = new KinematicChain(roboarm1, rb2, rc2);
        roboarm3 = new KinematicChain(roboarm2, rb3, rc3);
    }
}